Bug 1330822 - Remove CPOWs from browser_loadURI.js. r=Felipe draft
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 30 Nov 2016 18:00:06 -0800
changeset 460337 60a342489768eca956ca76e3a9b14a5e5b402c43
parent 460336 ba0c03529030860fc914021b826d515560a414b3
child 460338 597a9ca8d74832b053b8f38f1fa5ba01b270be85
push id41373
push userbmo:mrbkap@mozilla.com
push dateFri, 13 Jan 2017 00:11:03 +0000
reviewersFelipe
bugs1330822
milestone53.0a1
Bug 1330822 - Remove CPOWs from browser_loadURI.js. r=Felipe
docshell/test/browser/browser_loadURI.js
--- a/docshell/test/browser/browser_loadURI.js
+++ b/docshell/test/browser/browser_loadURI.js
@@ -20,26 +20,15 @@ function test() {
 
   var postStream = Cc["@mozilla.org/network/mime-input-stream;1"].
                    createInstance(Ci.nsIMIMEInputStream);
   postStream.addHeader("Content-Type", "application/x-www-form-urlencoded");
   postStream.addContentLength = true;
   postStream.setData(dataStream);
 
   tab.linkedBrowser.loadURIWithFlags("http://mochi.test:8888/browser/docshell/test/browser/print_postdata.sjs", 0, null, null, postStream);
-  onTabLoad(tab, function (doc) {
-    var bodyText = doc.body.textContent;
-    is(bodyText, gPostData, "post data was submitted correctly");
-    finish();
+  BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
+    ContentTask.spawn(tab.linkedBrowser, gPostData, function(postData) {
+      var bodyText = content.document.body.textContent;
+      is(bodyText, postData, "post data was submitted correctly");
+    }).then(() => { finish(); });
   });
 }
-
-function onTabLoad(tab, cb) {
-  tab.linkedBrowser.addEventListener("load", function listener(event) {
-    if (event.originalTarget != tab.linkedBrowser.contentDocument ||
-        event.target.location.href == "about:blank") {
-      info("skipping spurious load event");
-      return;
-    }
-    tab.linkedBrowser.removeEventListener("load", listener, true);
-    cb(tab.linkedBrowser.contentDocument);
-  }, true);
-}