Bug 1149162 - Remove CPOW shim usage in SDK test-tab test related to tab.readyState. r=Mossop, a=test-only
authorLuca Greco <lgreco@mozilla.com>
Mon, 29 Aug 2016 20:03:42 +0200
changeset 356229 188c28fdb1aadfbed95a18811eb1476fb50ff3db
parent 356228 39299d2a7f1abbce866a25e2b64b60e639de4f8a
child 356230 47b221aee73a3db561df68622c14b1008123656c
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMossop, test-only
bugs1149162
milestone51.0a2
Bug 1149162 - Remove CPOW shim usage in SDK test-tab test related to tab.readyState. r=Mossop, a=test-only MozReview-Commit-ID: Cg0koZxzSxp
addon-sdk/source/test/test-tab.js
--- a/addon-sdk/source/test/test-tab.js
+++ b/addon-sdk/source/test/test-tab.js
@@ -197,19 +197,32 @@ exports["test tab.readyState"] = (assert
     },
     onLoad: (tab) => {
       assert.equal(tab.readyState, "complete", "tab is complete onLoad");
       tab.close(defer(done));
     }
   });
 }
 
-exports["test tab.readyState for existent tabs"] = (assert) => {
+exports["test tab.readyState for existent tabs"] = function* (assert) {
   assert.equal(tabs.length, 1, "tabs contains an existent tab");
 
+  function frameScript() {
+    sendAsyncMessage("test:contentDocument.readyState", content.document.readyState);
+  }
+
   for (let tab of tabs) {
     let browserForTab = getBrowserForTab(viewFor(tab));
-    assert.equal(browserForTab.contentDocument.readyState, tab.readyState,
-                 "tab.readyState has the same value of the associated contentDocument.readyState CPOW");
+    let mm = browserForTab.messageManager;
+
+    yield new Promise((resolve) => {
+      mm.addMessageListener("test:contentDocument.readyState", function listener(evt) {
+        mm.removeMessageListener("test:contentDocument.readyState", listener);
+        assert.equal(evt.data, tab.readyState,
+                     "tab.readyState has the same value of the associated contentDocument.readyState CPOW");
+        resolve();
+      });
+      mm.loadFrameScript(`data:,new ${frameScript};`, false);
+    });
   }
 }
 
 require("sdk/test").run(module.exports);