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 350757 79247eb8ce1f6c5e4444c196983cf7630fa62e9c
parent 350756 1ad4ab26875c6512b577f8f6974260fcd76d35b6
child 350758 d69e6eb5d19f81e22ddd026857e2b5b7b57d37b5
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMossop, test-only
bugs1149162
milestone50.0
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);