Skip to content

Commit a5d6b6d

Browse files
jteplitzRobert Messerle
authored andcommitted
fix(WebWorker): Fix textarea value not being sent to the worker
Closes angular#7439 Closes angular#7828
1 parent fc49681 commit a5d6b6d

File tree

13 files changed

+163
-4
lines changed

13 files changed

+163
-4
lines changed

modules/angular2/src/web_workers/ui/event_serializer.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ final Set<String> NODES_WITH_VALUE = new Set<String>.from([
1313
"li",
1414
"meter",
1515
"progress",
16-
"param"
16+
"param",
17+
"textarea"
1718
]);
1819

1920
Map<String, dynamic> serializeGenericEvent(dynamic e) {

modules/angular2/src/web_workers/ui/event_serializer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const TRANSITION_EVENT_PROPERTIES = ['propertyName', 'elapsedTime', 'pseudoEleme
3636

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

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

4242
export function serializeGenericEvent(e: Event): {[key: string]: any} {
4343
return serializeEvent(e, EVENT_PROPERTIES);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
library playground.e2e_test.web_workers.input_spec;
2+
3+
main() {}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import {verifyNoBrowserErrors} from 'angular2/src/testing/e2e_util';
2+
3+
describe('WebWorkers Input', function() {
4+
afterEach(() => {
5+
verifyNoBrowserErrors();
6+
browser.ignoreSynchronization = false;
7+
});
8+
const selector = 'input-app';
9+
const URL = 'playground/src/web_workers/input/index.html';
10+
const VALUE = 'test val';
11+
12+
it('should bootstrap', () => {
13+
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
14+
browser.ignoreSynchronization = true;
15+
browser.get(URL);
16+
17+
waitForBootstrap();
18+
let elem = element(by.css(selector + ' h2'));
19+
expect(elem.getText()).toEqual('Input App');
20+
});
21+
22+
it('should bind to input value', () => {
23+
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
24+
browser.ignoreSynchronization = true;
25+
browser.get(URL);
26+
27+
waitForBootstrap();
28+
let elem = element(by.css(selector + ' h2'));
29+
30+
let input = element(by.css(selector + ' input'));
31+
input.sendKeys(VALUE);
32+
let displayElem = element(by.css(selector + ' .input-val'));
33+
const expectedVal = `Input val is ${VALUE}.`;
34+
browser.wait(protractor.until.elementTextIs(displayElem, expectedVal), 5000);
35+
expect(displayElem.getText()).toEqual(expectedVal);
36+
});
37+
38+
it('should bind to textarea value', () => {
39+
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
40+
browser.ignoreSynchronization = true;
41+
browser.get(URL);
42+
43+
waitForBootstrap();
44+
let elem = element(by.css(selector + ' h2'));
45+
46+
let input = element(by.css(selector + ' textarea'));
47+
input.sendKeys(VALUE);
48+
let displayElem = element(by.css(selector + ' .textarea-val'));
49+
const expectedVal = `Textarea val is ${VALUE}.`;
50+
browser.wait(protractor.until.elementTextIs(displayElem, expectedVal), 5000);
51+
expect(displayElem.getText()).toEqual(expectedVal);
52+
});
53+
54+
function waitForBootstrap() {
55+
browser.wait(protractor.until.elementLocated(by.css(selector + ' h2')), 15000);
56+
let elem = element(by.css(selector + ' h2'));
57+
browser.wait(protractor.until.elementTextIs(elem, 'Input App'), 5000);
58+
}
59+
});

modules/playground/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ transformers:
4343
- web/src/web_workers/todo/server_index.dart
4444
- web/src/web_workers/router/index.dart
4545
- web/src/web_workers/router/background_index.dart
46+
- web/src/web_workers/input/index.dart
47+
- web/src/web_workers/input/background_index.dart
4648
- web/src/zippy_component/index.dart
4749
- angular2/transform/deferred_rewriter:
4850
# No playground apps use deferred imports, but in general
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
library playground.src.web_workers.input.background_index;
2+
3+
import "index_common.dart" show InputCmp;
4+
import "dart:isolate";
5+
import "package:angular2/platform/worker_app.dart";
6+
import "package:angular2/core.dart";
7+
8+
@AngularEntrypoint()
9+
main(List<String> args, SendPort replyTo) {
10+
platform([WORKER_APP_PLATFORM, new Provider(RENDER_SEND_PORT, useValue: replyTo)])
11+
.application([WORKER_APP_APPLICATION])
12+
.bootstrap(InputCmp);
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {InputCmp} from "./index_common";
2+
import {platform} from "angular2/core";
3+
import {WORKER_APP_PLATFORM, WORKER_APP_APPLICATION} from "angular2/platform/worker_app";
4+
5+
export function main() {
6+
platform([WORKER_APP_PLATFORM]).application([WORKER_APP_APPLICATION]).bootstrap(InputCmp);
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
library angular2.examples.web_workers.input.index;
2+
3+
import "package:angular2/platform/worker_render.dart";
4+
import "package:angular2/core.dart";
5+
6+
@AngularEntrypoint()
7+
main() {
8+
platform([WORKER_RENDER_PLATFORM])
9+
.asyncApplication(initIsolate("background_index.dart"));
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html>
3+
<title>WebWorker Input Tests</title>
4+
<style>
5+
</style>
6+
<body>
7+
<input-app>
8+
Loading...
9+
</input-app>
10+
11+
$SCRIPTS$
12+
</body>
13+
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {platform, Provider} from 'angular2/core';
2+
import {
3+
WORKER_RENDER_APPLICATION,
4+
WORKER_RENDER_PLATFORM,
5+
WORKER_SCRIPT
6+
} from 'angular2/platform/worker_render';
7+
8+
platform([WORKER_RENDER_PLATFORM])
9+
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);

0 commit comments

Comments
 (0)