summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authorbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-09 18:50:50 +0000
committerbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-09 18:50:50 +0000
commitea37c98a7798893cdee1aa4a89672a053aca59d6 (patch)
tree98d0fefc2e9af933857f26a38478c924825b0505 /native_client_sdk
parentad8e142e4a60a3097c9cefc8892b16db4b2c82f6 (diff)
downloadchromium_src-ea37c98a7798893cdee1aa4a89672a053aca59d6.zip
chromium_src-ea37c98a7798893cdee1aa4a89672a053aca59d6.tar.gz
chromium_src-ea37c98a7798893cdee1aa4a89672a053aca59d6.tar.bz2
[NaCl SDK] Don't exit from nacl_io_test before posting message to JS.
In the nacl_io_test there's a race condition between the NaCl module exiting and a posted message from the module being handled by JavaScript. To fix it, when running in the browser, we wait indefinitely and assume the JavaScript will kill the module when it is ready. (This fixes a flake that can be seen in http://build.chromium.org/p/client.nacl.sdk/builders/mac-sdk-multi/builds/5838/steps/Run%20Tests/logs/stdio BUG=none R=sbc@chromium.org Review URL: https://codereview.chromium.org/23531034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222065 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rw-r--r--native_client_sdk/src/resources/common.js9
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/example.js9
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/main.cc10
3 files changed, 27 insertions, 1 deletions
diff --git a/native_client_sdk/src/resources/common.js b/native_client_sdk/src/resources/common.js
index dc5328f..6a78d42 100644
--- a/native_client_sdk/src/resources/common.js
+++ b/native_client_sdk/src/resources/common.js
@@ -238,6 +238,14 @@ var common = (function() {
}
/**
+ * Remove the NaCl module from the page.
+ */
+ function removeModule() {
+ common.naclModule.parentNode.removeChild(common.naclModule);
+ common.naclModule = null;
+ }
+
+ /**
* Return true when |s| starts with the string |prefix|.
*
* @param {string} s The string to search.
@@ -376,6 +384,7 @@ var common = (function() {
domContentLoaded: domContentLoaded,
createNaClModule: createNaClModule,
hideModule: hideModule,
+ removeModule: removeModule,
logMessage: logMessage,
updateStatus: updateStatus
};
diff --git a/native_client_sdk/src/tests/nacl_io_test/example.js b/native_client_sdk/src/tests/nacl_io_test/example.js
index 3a65c89..829a490 100644
--- a/native_client_sdk/src/tests/nacl_io_test/example.js
+++ b/native_client_sdk/src/tests/nacl_io_test/example.js
@@ -46,6 +46,15 @@ function endCommand(testName, testResult) {
function testendCommand() {
testsFinished = true;
+ common.removeModule();
+
+ if (failedTests) {
+ common.updateStatus('FAILED');
+ document.getElementById('statusField').classList.add('failed');
+ } else {
+ common.updateStatus('OK');
+ document.getElementById('statusField').classList.add('ok');
+ }
}
function handleMessage(event) {
diff --git a/native_client_sdk/src/tests/nacl_io_test/main.cc b/native_client_sdk/src/tests/nacl_io_test/main.cc
index 9df6d4b..7722670 100644
--- a/native_client_sdk/src/tests/nacl_io_test/main.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/main.cc
@@ -60,7 +60,15 @@ int example_main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
::testing::UnitTest::GetInstance()->listeners()
.Append(new GTestEventListener());
- return RUN_ALL_TESTS();
+ int result = RUN_ALL_TESTS();
+
+ // When running as an automated test, we don't want the final message
+ // ("testend") to be dropped, so don't exit. The web page will kill the
+ // plugin if it needs to.
+ while(1);
+
+ // Silence the warning.
+ return result;
}
// Register the function to call once the Instance Object is initialized.