Bug 1330822 - Remove CPOWs from browser_loadURI.js. r=Felipe
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 30 Nov 2016 18:00:06 -0800
changeset 463633 ef6ee3788c6bbe3c6c96f23054b0901ea09cd325
parent 463632 a66860c81eaf8f83e38ab184c1d1fa9e5564edcc
child 463634 e4a95dce8bb83f2d8d83ee72e8c060bd4ffada33
push id42137
push userjichen@mozilla.com
push dateThu, 19 Jan 2017 15:08:06 +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);
-}