Bug 770046 - 'test_ipc.html does not notice failures'. r=khuey.
authorBen Turner <bent.mozilla@gmail.com>
Mon, 27 Aug 2012 11:10:34 -0700
changeset 105626 28cbe2f75f5dd8d858c0ef72fbe11250c60ad822
parent 105625 c7e0c849fcdc8acb4a15687fabc17bd3033addf8
child 105627 e1b06ed3fc1e1ba124604ce407722c0b64ea2fb0
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewerskhuey
bugs770046
milestone17.0a1
Bug 770046 - 'test_ipc.html does not notice failures'. r=khuey.
dom/indexedDB/ipc/test_ipc.html
--- a/dom/indexedDB/ipc/test_ipc.html
+++ b/dom/indexedDB/ipc/test_ipc.html
@@ -25,71 +25,89 @@
 
       content.wrappedJSObject.RunSet.reloadAndRunAll({
         preventDefault: function() { },
         __exposedProps__: { preventDefault: 'r' }
       });
     }
 
     function iframeScriptSecond() {
+      let isMainProcess = content.wrappedJSObject.SpecialPowers.isMainProcess();
+
+      sendAsyncMessage("test:indexedDB:ipcProcessType",
+                       { isMainProcess: isMainProcess });
+
       let TestRunner = content.wrappedJSObject.TestRunner;
 
       let oldComplete = TestRunner.onComplete;
 
       TestRunner.onComplete = function() {
         TestRunner.onComplete = oldComplete;
 
-        sendAsyncMessage("test:indexedDB:ipcTestComplete", {
-          result: JSON.stringify(TestRunner._failedTests)
-        });
+        sendAsyncMessage("test:indexedDB:ipcTestComplete");
 
         if (oldComplete) {
           oldComplete();
         }
       };
 
-      let oldLog = TestRunner.log;
-      TestRunner.log = function(msg) {
+      function sendTestMessage(msg) {
         sendAsyncMessage("test:indexedDB:ipcTestMessage", { msg: msg });
       }
+
+      TestRunner.log = sendTestMessage;
+      TestRunner.error = sendTestMessage;
     }
 
     let regexString =
       "^(TEST-PASS|TEST-UNEXPECTED-PASS|TEST-KNOWN-FAIL|TEST-UNEXPECTED-FAIL" +
-      "|TEST-DEBUG-INFO) \\| ([^\\|]+) \\|(.*)";
+      "|TEST-DEBUG-INFO|TEST-INFO) \\| ([^\\|]+) \\|(.*)";
 
     let regex = new RegExp(regexString);
 
+    let seenTestMessage = false;
+
     function onTestMessage(data) {
-      let message = SpecialPowers.wrap(data).json.msg;
+      seenTestMessage = true;
+      let message = SpecialPowers.wrap(data).data.msg;
       let match = regex.exec(message);
       if (match) {
         let state = match[1];
         let details = match[2] + " | " + match[3];
 
         switch (state) {
           case "TEST-PASS":
           case "TEST-KNOWN-FAIL":
             ok(true, details);
             break;
 
           case "TEST-UNEXPECTED-FAIL":
           case "TEST-UNEXPECTED-PASS":
             ok(false, details);
             break;
 
+          case "TEST-INFO":
           case "TEST-DEBUG-INFO":
           default:
             info(details);
         }
       }
     }
 
+    let usingChildProcess = false;
+
+    function onProcessType(data) {
+      let isMainProcess = SpecialPowers.wrap(data).data.isMainProcess;
+      usingChildProcess = !isMainProcess;
+    }
+
     function onTestComplete() {
-      ok(true, "Got test complete message");
+      is(usingChildProcess, true, "Expecting to run in child process");
+      is(seenTestMessage, true, "Expecting to receive messages from child");
+      SpecialPowers.removePermission("browser", window.location.href);
       SimpleTest.executeSoon(function () { SimpleTest.finish(); });
     }
 
     function runTests() {
       let iframe = document.createElement("iframe");
       iframe.mozbrowser = true;
       iframe.id = "iframe";
       iframe.style.width = "100%";
@@ -118,16 +136,17 @@
 
         mm.addMessageListener("SPPrefService", spObserver);
         mm.addMessageListener("SPProcessCrashService", spObserver);
         mm.addMessageListener("SPPingService", spObserver);
         mm.addMessageListener("SpecialPowers.Quit", spObserver);
         mm.addMessageListener("SPPermissionManager", spObserver);
 
         mm.addMessageListener("test:indexedDB:ipcTestMessage", onTestMessage);
+        mm.addMessageListener("test:indexedDB:ipcProcessType", onProcessType);
         mm.addMessageListener("test:indexedDB:ipcTestComplete", onTestComplete);
 
         let specialPowersBase = "chrome://specialpowers/content/";
         mm.loadFrameScript(specialPowersBase + "MozillaLogger.js", false);
         mm.loadFrameScript(specialPowersBase + "specialpowersAPI.js", false);
         mm.loadFrameScript(specialPowersBase + "specialpowers.js", false);
 
         mm.loadFrameScript("data:,(" + iframeScriptFirst.toString() + ")();",
@@ -141,30 +160,19 @@
       href = href.substring(0, href.lastIndexOf('/'));
       href = href.substring(0, href.lastIndexOf('/'));
       iframe.src = href + "/test?consoleLevel=INFO";
 
       document.body.appendChild(iframe);
     }
 
     addEventListener("load", function() {
-      let whitelist;
-      try {
-        whitelist =
-          SpecialPowers.getCharPref("dom.mozBrowserFramesWhitelist") + ", ";
-      } catch (e) {
-        whitelist = "";
-      }
-
-      whitelist += window.location.protocol + "//" + window.location.host;
-
+      SpecialPowers.addPermission("browser", true, document);
       SpecialPowers.pushPrefEnv({
         "set": [
           ["dom.ipc.browser_frames.oop_by_default", true],
-          ["dom.mozBrowserFramesEnabled", true],
-          ["dom.mozBrowserFramesWhitelist", whitelist],
-          ["browser.pageThumbs.enabled", false]
+          ["dom.mozBrowserFramesEnabled", true]
         ]
       }, runTests);
     });
   </script>
 </body>
 </html>