summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authorbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-26 23:21:08 +0000
committerbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-26 23:21:08 +0000
commit5bfc7ede2fe571137ca3afade6e2fbab2e457490 (patch)
treebbfd87b09e3da7a9b2e8e229d55862b737eae348 /native_client_sdk
parent1b985495e47a0f19fae1c02072c2c0a2d0afdfd8 (diff)
downloadchromium_src-5bfc7ede2fe571137ca3afade6e2fbab2e457490.zip
chromium_src-5bfc7ede2fe571137ca3afade6e2fbab2e457490.tar.gz
chromium_src-5bfc7ede2fe571137ca3afade6e2fbab2e457490.tar.bz2
[NaCl SDK] Fix examples/api/core test flake on Host builds.
Host builds (i.e. trusted plugins) of the examples were not waiting for modules to load before running tests. This is because a trusted plugins do not send progress events. The host builds were still dispatching a fake 'load' event (after an arbitrary time of 100ms), so moduleDidLoad was being called. This could happen after the tests started to run. If so, the common.naclModule variable would not be set when the tests were being run, which would cause the common.naclModule.postMessage() call to fail. The fix is to send more fake events: 'loadstart', 'load', 'loadend', and set the readyState variable correctly. Now, before running the tests, we can wait for host plugins in the same way we wait for NaCl modules. BUG=none R=sbc@chromium.org Review URL: https://codereview.chromium.org/23471002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219638 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rw-r--r--native_client_sdk/src/examples/common.js19
1 files changed, 8 insertions, 11 deletions
diff --git a/native_client_sdk/src/examples/common.js b/native_client_sdk/src/examples/common.js
index 79687d5..dc5328f 100644
--- a/native_client_sdk/src/examples/common.js
+++ b/native_client_sdk/src/examples/common.js
@@ -84,11 +84,9 @@ var common = (function() {
/**
* Run all tests for this example.
*
- * @param {bool} waitForModule True if the tests should wait for the module
- * to load. This is not necessary for trusted plugins (i.e. host plugins).
* @param {Object} moduleEl The module DOM element.
*/
- function runTests(waitForModule, moduleEl) {
+ function runTests(moduleEl) {
console.log('runTests()');
common.tester = new Tester();
@@ -107,9 +105,7 @@ var common = (function() {
window.addTests();
}
- if (waitForModule) {
- common.tester.waitFor(moduleEl);
- }
+ common.tester.waitFor(moduleEl);
common.tester.run();
}
@@ -155,9 +151,11 @@ var common = (function() {
var isHost = isHostToolchain(tool);
if (isHost) {
window.setTimeout(function() {
- var evt = document.createEvent('Event');
- evt.initEvent('load', true, true); // bubbles, cancelable
- moduleEl.dispatchEvent(evt);
+ moduleEl.readyState = 1;
+ moduleEl.dispatchEvent(new CustomEvent('loadstart'));
+ moduleEl.readyState = 4;
+ moduleEl.dispatchEvent(new CustomEvent('load'));
+ moduleEl.dispatchEvent(new CustomEvent('loadend'));
}, 100); // 100 ms
}
@@ -165,8 +163,7 @@ var common = (function() {
if (isTest) {
var loadNaClTest = function() {
injectScript('nacltest.js', function() {
- var waitForModule = !isHost;
- runTests(waitForModule, moduleEl);
+ runTests(moduleEl);
});
};