fix(WebWorker): Fix textarea value not being sent to the worker
Closes #7439 Closes #7828
This commit is contained in:
parent
fc496813e2
commit
a5d6b6db8b
|
@ -13,7 +13,8 @@ final Set<String> NODES_WITH_VALUE = new Set<String>.from([
|
||||||
"li",
|
"li",
|
||||||
"meter",
|
"meter",
|
||||||
"progress",
|
"progress",
|
||||||
"param"
|
"param",
|
||||||
|
"textarea"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Map<String, dynamic> serializeGenericEvent(dynamic e) {
|
Map<String, dynamic> serializeGenericEvent(dynamic e) {
|
||||||
|
|
|
@ -36,8 +36,8 @@ const TRANSITION_EVENT_PROPERTIES = ['propertyName', 'elapsedTime', 'pseudoEleme
|
||||||
|
|
||||||
const EVENT_PROPERTIES = ['type', 'bubbles', 'cancelable'];
|
const EVENT_PROPERTIES = ['type', 'bubbles', 'cancelable'];
|
||||||
|
|
||||||
const NODES_WITH_VALUE =
|
const NODES_WITH_VALUE = new Set(
|
||||||
new Set(["input", "select", "option", "button", "li", "meter", "progress", "param"]);
|
["input", "select", "option", "button", "li", "meter", "progress", "param", "textarea"]);
|
||||||
|
|
||||||
export function serializeGenericEvent(e: Event): {[key: string]: any} {
|
export function serializeGenericEvent(e: Event): {[key: string]: any} {
|
||||||
return serializeEvent(e, EVENT_PROPERTIES);
|
return serializeEvent(e, EVENT_PROPERTIES);
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
library playground.e2e_test.web_workers.input_spec;
|
||||||
|
|
||||||
|
main() {}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
});
|
|
@ -43,6 +43,8 @@ transformers:
|
||||||
- web/src/web_workers/todo/server_index.dart
|
- web/src/web_workers/todo/server_index.dart
|
||||||
- web/src/web_workers/router/index.dart
|
- web/src/web_workers/router/index.dart
|
||||||
- web/src/web_workers/router/background_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
|
- web/src/zippy_component/index.dart
|
||||||
- angular2/transform/deferred_rewriter:
|
- angular2/transform/deferred_rewriter:
|
||||||
# No playground apps use deferred imports, but in general
|
# No playground apps use deferred imports, but in general
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
|
@ -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"));
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<title>WebWorker Input Tests</title>
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<input-app>
|
||||||
|
Loading...
|
||||||
|
</input-app>
|
||||||
|
|
||||||
|
$SCRIPTS$
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -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"})]);
|
|
@ -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; }
|
||||||
|
}
|
|
@ -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); });
|
|
@ -61,7 +61,8 @@ const kServedPaths = [
|
||||||
'playground/src/web_workers/todo',
|
'playground/src/web_workers/todo',
|
||||||
'playground/src/web_workers/images',
|
'playground/src/web_workers/images',
|
||||||
'playground/src/web_workers/message_broker',
|
'playground/src/web_workers/message_broker',
|
||||||
'playground/src/web_workers/router'
|
'playground/src/web_workers/router',
|
||||||
|
'playground/src/web_workers/input'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue