Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/angular2/src/web_workers/ui/event_serializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ final Set<String> NODES_WITH_VALUE = new Set<String>.from([
"li",
"meter",
"progress",
"param"
"param",
"textarea"
]);

Map<String, dynamic> serializeGenericEvent(dynamic e) {
Expand Down
4 changes: 2 additions & 2 deletions modules/angular2/src/web_workers/ui/event_serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const TRANSITION_EVENT_PROPERTIES = ['propertyName', 'elapsedTime', 'pseudoEleme

const EVENT_PROPERTIES = ['type', 'bubbles', 'cancelable'];

const NODES_WITH_VALUE =
new Set(["input", "select", "option", "button", "li", "meter", "progress", "param"]);
const NODES_WITH_VALUE = new Set(
["input", "select", "option", "button", "li", "meter", "progress", "param", "textarea"]);

export function serializeGenericEvent(e: Event): {[key: string]: any} {
return serializeEvent(e, EVENT_PROPERTIES);
Expand Down
3 changes: 3 additions & 0 deletions modules/playground/e2e_test/web_workers/input/input_spec.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library playground.e2e_test.web_workers.input_spec;

main() {}
59 changes: 59 additions & 0 deletions modules/playground/e2e_test/web_workers/input/input_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {verifyNoBrowserErrors} from 'angular2/src/testing/e2e_util';

describe('WebWorkers Input', function() {
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
const selector = 'input-app';
const URL = 'playground/src/web_workers/input/index.html';
const VALUE = 'test val';

it('should bootstrap', () => {
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);

waitForBootstrap();
let elem = element(by.css(selector + ' h2'));
expect(elem.getText()).toEqual('Input App');
});

it('should bind to input value', () => {
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);

waitForBootstrap();
let elem = element(by.css(selector + ' h2'));

let input = element(by.css(selector + ' input'));
input.sendKeys(VALUE);
let displayElem = element(by.css(selector + ' .input-val'));
const expectedVal = `Input val is ${VALUE}.`;
browser.wait(protractor.until.elementTextIs(displayElem, expectedVal), 5000);
expect(displayElem.getText()).toEqual(expectedVal);
});

it('should bind to textarea value', () => {
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);

waitForBootstrap();
let elem = element(by.css(selector + ' h2'));

let input = element(by.css(selector + ' textarea'));
input.sendKeys(VALUE);
let displayElem = element(by.css(selector + ' .textarea-val'));
const expectedVal = `Textarea val is ${VALUE}.`;
browser.wait(protractor.until.elementTextIs(displayElem, expectedVal), 5000);
expect(displayElem.getText()).toEqual(expectedVal);
});

function waitForBootstrap() {
browser.wait(protractor.until.elementLocated(by.css(selector + ' h2')), 15000);
let elem = element(by.css(selector + ' h2'));
browser.wait(protractor.until.elementTextIs(elem, 'Input App'), 5000);
}
});
2 changes: 2 additions & 0 deletions modules/playground/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ transformers:
- web/src/web_workers/todo/server_index.dart
- web/src/web_workers/router/index.dart
- web/src/web_workers/router/background_index.dart
- web/src/web_workers/input/index.dart
- web/src/web_workers/input/background_index.dart
- web/src/zippy_component/index.dart
- angular2/transform/deferred_rewriter:
# No playground apps use deferred imports, but in general
Expand Down
13 changes: 13 additions & 0 deletions modules/playground/src/web_workers/input/background_index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
library playground.src.web_workers.input.background_index;

import "index_common.dart" show InputCmp;
import "dart:isolate";
import "package:angular2/platform/worker_app.dart";
import "package:angular2/core.dart";

@AngularEntrypoint()
main(List<String> args, SendPort replyTo) {
platform([WORKER_APP_PLATFORM, new Provider(RENDER_SEND_PORT, useValue: replyTo)])
.application([WORKER_APP_APPLICATION])
.bootstrap(InputCmp);
}
7 changes: 7 additions & 0 deletions modules/playground/src/web_workers/input/background_index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {InputCmp} from "./index_common";
import {platform} from "angular2/core";
import {WORKER_APP_PLATFORM, WORKER_APP_APPLICATION} from "angular2/platform/worker_app";

export function main() {
platform([WORKER_APP_PLATFORM]).application([WORKER_APP_APPLICATION]).bootstrap(InputCmp);
}
10 changes: 10 additions & 0 deletions modules/playground/src/web_workers/input/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library angular2.examples.web_workers.input.index;

import "package:angular2/platform/worker_render.dart";
import "package:angular2/core.dart";

@AngularEntrypoint()
main() {
platform([WORKER_RENDER_PLATFORM])
.asyncApplication(initIsolate("background_index.dart"));
}
13 changes: 13 additions & 0 deletions modules/playground/src/web_workers/input/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html>
<title>WebWorker Input Tests</title>
<style>
</style>
<body>
<input-app>
Loading...
</input-app>

$SCRIPTS$
</body>
</html>
9 changes: 9 additions & 0 deletions modules/playground/src/web_workers/input/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {platform, Provider} from 'angular2/core';
import {
WORKER_RENDER_APPLICATION,
WORKER_RENDER_PLATFORM,
WORKER_SCRIPT
} from 'angular2/platform/worker_render';

platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
24 changes: 24 additions & 0 deletions modules/playground/src/web_workers/input/index_common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {Component} from 'angular2/core';

@Component({
selector: 'input-app',
template: `
<h2>Input App</h2>
<div id="input-container">
<input type="text" (input)="inputChanged($event)">
<textarea (input)="textAreaChanged($event)"></textarea>
<div class="input-val">Input val is {{inputVal}}.</div>
<div class="textarea-val">Textarea val is {{textareaVal}}.</div>
</div>
<div id="ng-model-container">
</div>
`
})
export class InputCmp {
inputVal = "";
textareaVal = "";

inputChanged(e) { this.inputVal = e.target.value; }

textAreaChanged(e) { this.textareaVal = e.target.value; }
}
17 changes: 17 additions & 0 deletions modules/playground/src/web_workers/input/loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$SCRIPTS$

System.config({
baseURL: '/',
defaultJSExtensions: true
});

System.import("playground/src/web_workers/input/background_index")
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });
3 changes: 2 additions & 1 deletion tools/broccoli/trees/browser_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ const kServedPaths = [
'playground/src/web_workers/todo',
'playground/src/web_workers/images',
'playground/src/web_workers/message_broker',
'playground/src/web_workers/router'
'playground/src/web_workers/router',
'playground/src/web_workers/input'
];


Expand Down