summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorncbray@chromium.org <ncbray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-06 22:47:42 +0000
committerncbray@chromium.org <ncbray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-06 22:47:42 +0000
commit52d6a08986d0aaafbc3d263962fbeb3ca690cf35 (patch)
tree2ee62356648d66ae427f63d4713afd49f6a86d4b /ppapi
parent042c83c9ca6069c7b580dea742186112b1969517 (diff)
downloadchromium_src-52d6a08986d0aaafbc3d263962fbeb3ca690cf35.zip
chromium_src-52d6a08986d0aaafbc3d263962fbeb3ca690cf35.tar.gz
chromium_src-52d6a08986d0aaafbc3d263962fbeb3ca690cf35.tar.bz2
PPAPI: make browser tests to fail fast if a NaCl module does not load.
BUG= 164493 Review URL: https://chromiumcodereview.appspot.com/11447019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171616 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/tests/test_case.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/ppapi/tests/test_case.html b/ppapi/tests/test_case.html
index 6c53f88..96d3a38 100644
--- a/ppapi/tests/test_case.html
+++ b/ppapi/tests/test_case.html
@@ -117,6 +117,18 @@ function LogHTML(html) {
window.document.getElementById("console").innerHTML += html;
}
+// If something goes really wrong, the test running inside the plugin may not
+// terminate. For example, if the plugin does not load, the test will never
+// send "PASS" to the browser. In this case we should explicitly use the
+// automation controller to terminate the test.
+function InternalError(msg) {
+ LogHTML("<p>" + msg);
+ if (window.domAutomationController) {
+ domAutomationController.setAutomationId(0);
+ domAutomationController.send(msg);
+ }
+}
+
function SetCookie(key_value_string) {
window.document.cookie = key_value_string + "; path=/";
}
@@ -236,11 +248,22 @@ onload = function() {
var container = document.getElementById("container");
container.addEventListener("message", handleTestingMessage, true);
+ // "error" and "crash" events will only fire for NaCl, but adding these
+ // listeners doesn't hurt in the non-NaCl cases.
+ obj.addEventListener("error", function() {
+ InternalError("Plugin did not load. '" + obj.lastError + "'");
+ }, true);
+ obj.addEventListener("crash", function() {
+ InternalError("Plugin crashed. '" + obj.lastError + "'");
+ }, true);
// Register a bad dispatchEvent to make sure it isn't used. See 'EVIL' note
// below.
+ var original = obj.dispatchEvent;
obj.dispatchEvent = function() {
LogHTML("<p>Bad dispatchEvent called! " +
"see <a href='http://crbug.com/109775'>crbug.com/109775</a>)");
+ // Pass it on anyways, we need the event to detect load errors.
+ original.apply(obj, arguments);
}
container.appendChild(obj);
}