diff --git a/modules/angular2/src/web_workers/ui/event_serializer.dart b/modules/angular2/src/web_workers/ui/event_serializer.dart index 88a2394917..aae5379b88 100644 --- a/modules/angular2/src/web_workers/ui/event_serializer.dart +++ b/modules/angular2/src/web_workers/ui/event_serializer.dart @@ -13,7 +13,8 @@ final Set NODES_WITH_VALUE = new Set.from([ "li", "meter", "progress", - "param" + "param", + "textarea" ]); Map serializeGenericEvent(dynamic e) { diff --git a/modules/angular2/src/web_workers/ui/event_serializer.ts b/modules/angular2/src/web_workers/ui/event_serializer.ts index 7fb743dc8a..6396354ce0 100644 --- a/modules/angular2/src/web_workers/ui/event_serializer.ts +++ b/modules/angular2/src/web_workers/ui/event_serializer.ts @@ -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); diff --git a/modules/playground/e2e_test/web_workers/input/input_spec.dart b/modules/playground/e2e_test/web_workers/input/input_spec.dart new file mode 100644 index 0000000000..ac6b852b05 --- /dev/null +++ b/modules/playground/e2e_test/web_workers/input/input_spec.dart @@ -0,0 +1,3 @@ +library playground.e2e_test.web_workers.input_spec; + +main() {} diff --git a/modules/playground/e2e_test/web_workers/input/input_spec.ts b/modules/playground/e2e_test/web_workers/input/input_spec.ts new file mode 100644 index 0000000000..e66bbfe123 --- /dev/null +++ b/modules/playground/e2e_test/web_workers/input/input_spec.ts @@ -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); + } +}); \ No newline at end of file diff --git a/modules/playground/pubspec.yaml b/modules/playground/pubspec.yaml index 4a243836c6..deb98d894f 100644 --- a/modules/playground/pubspec.yaml +++ b/modules/playground/pubspec.yaml @@ -43,6 +43,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 diff --git a/modules/playground/src/web_workers/input/background_index.dart b/modules/playground/src/web_workers/input/background_index.dart new file mode 100644 index 0000000000..58d7ecebb7 --- /dev/null +++ b/modules/playground/src/web_workers/input/background_index.dart @@ -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 args, SendPort replyTo) { + platform([WORKER_APP_PLATFORM, new Provider(RENDER_SEND_PORT, useValue: replyTo)]) + .application([WORKER_APP_APPLICATION]) + .bootstrap(InputCmp); +} diff --git a/modules/playground/src/web_workers/input/background_index.ts b/modules/playground/src/web_workers/input/background_index.ts new file mode 100644 index 0000000000..84ec3dc468 --- /dev/null +++ b/modules/playground/src/web_workers/input/background_index.ts @@ -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); +} diff --git a/modules/playground/src/web_workers/input/index.dart b/modules/playground/src/web_workers/input/index.dart new file mode 100644 index 0000000000..b6008efc27 --- /dev/null +++ b/modules/playground/src/web_workers/input/index.dart @@ -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")); +} diff --git a/modules/playground/src/web_workers/input/index.html b/modules/playground/src/web_workers/input/index.html new file mode 100644 index 0000000000..cca8f50fa6 --- /dev/null +++ b/modules/playground/src/web_workers/input/index.html @@ -0,0 +1,13 @@ + + + WebWorker Input Tests + + + + Loading... + + + $SCRIPTS$ + + diff --git a/modules/playground/src/web_workers/input/index.ts b/modules/playground/src/web_workers/input/index.ts new file mode 100644 index 0000000000..e158157e5f --- /dev/null +++ b/modules/playground/src/web_workers/input/index.ts @@ -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"})]); diff --git a/modules/playground/src/web_workers/input/index_common.ts b/modules/playground/src/web_workers/input/index_common.ts new file mode 100644 index 0000000000..487c974dd0 --- /dev/null +++ b/modules/playground/src/web_workers/input/index_common.ts @@ -0,0 +1,24 @@ +import {Component} from 'angular2/core'; + +@Component({ + selector: 'input-app', + template: ` +

Input App

+
+ + +
Input val is {{inputVal}}.
+
Textarea val is {{textareaVal}}.
+
+
+
+ ` +}) +export class InputCmp { + inputVal = ""; + textareaVal = ""; + + inputChanged(e) { this.inputVal = e.target.value; } + + textAreaChanged(e) { this.textareaVal = e.target.value; } +} diff --git a/modules/playground/src/web_workers/input/loader.js b/modules/playground/src/web_workers/input/loader.js new file mode 100644 index 0000000000..647f1c577b --- /dev/null +++ b/modules/playground/src/web_workers/input/loader.js @@ -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); }); diff --git a/tools/broccoli/trees/browser_tree.ts b/tools/broccoli/trees/browser_tree.ts index 4f36a8bb93..9502253432 100644 --- a/tools/broccoli/trees/browser_tree.ts +++ b/tools/broccoli/trees/browser_tree.ts @@ -61,7 +61,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' ];