Bug 1147911 Part 5: Fix tests to allow for window.open to return null. r=billm
☠☠ backed out by 68de7c76d5d3 ☠ ☠
authorBob Owen <bobowencode@gmail.com>
Thu, 17 Nov 2016 15:48:52 +0000
changeset 323041 514e9bc447233b00baac5e4112db32993a5278aa
parent 323040 67b1290aa7ca5b222b665f24db45acdbe1a82f1d
child 323042 1a72c49193716fb43d032d756f873bc7d284cce1
push id84033
push userbobowencode@gmail.com
push dateThu, 17 Nov 2016 15:49:15 +0000
treeherdermozilla-inbound@a5c68edf3788 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1147911
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1147911 Part 5: Fix tests to allow for window.open to return null. r=billm These tests open a parent browser from the child, which means that the returned window isn't actually the real one anyway. Soon we will return null in this scenario.
toolkit/components/extensions/test/mochitest/test_ext_background_generated_url.html
toolkit/components/extensions/test/mochitest/test_ext_content_security_policy.html
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_generated_url.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_background_generated_url.html
@@ -29,19 +29,26 @@ add_task(function* test_url_of_generated
     files: {
       "bg.js": backgroundScript,
     },
   });
 
   yield extension.startup();
   const EXPECTED_URL = yield extension.awaitMessage("script done");
 
-  let win = window.open(EXPECTED_URL);
-  ok(win, "Should open new tab at URL: " + EXPECTED_URL);
+  // We are opening a window in a different process which will return null, so
+  // using a try catch to test whether the window.open worked.
+  let succeeded;
+  try {
+    window.open(EXPECTED_URL);
+    succeeded = true;
+  } catch (e) {
+    succeeded = false;
+  }
+  ok(succeeded, "Should open new tab at URL: " + EXPECTED_URL);
   yield extension.awaitMessage("script done");
-  win.close();
 
   yield extension.unload();
 });
 
 </script>
 </body>
 </html>
--- a/toolkit/components/extensions/test/mochitest/test_ext_content_security_policy.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_content_security_policy.html
@@ -111,17 +111,17 @@ function* testPolicy(customCSP = null) {
 
   info(`Testing CSP for policy: ${content_security_policy}`);
 
   yield extension.startup();
 
   baseURL = yield extension.awaitMessage("base-url");
 
 
-  let win1 = window.open(`${baseURL}/tab.html`);
+  window.open(`${baseURL}/tab.html`);
 
   let frame = document.createElement("iframe");
   frame.src = `${baseURL}/content.html`;
   document.body.appendChild(frame);
 
   yield new Promise(resolve => {
     frame.onload = resolve;
   });
@@ -131,18 +131,16 @@ function* testPolicy(customCSP = null) {
   checkCSP(backgroundCSP, "background page");
 
   let tabCSP = yield extension.awaitMessage("tab-csp");
   checkCSP(tabCSP, "tab page");
 
   let contentCSP = getCSP(frame.contentWindow);
   checkCSP(contentCSP, "content frame");
 
-
-  win1.close();
   frame.remove();
 
   yield extension.unload();
 }
 
 add_task(function* testCSP() {
   yield testPolicy(null);