Bug 1147911 Part 5: Fix tests to allow for window.open to return null. r=billm
☠☠ backed out by 2abf973bfdca ☠ ☠
authorBob Owen <bobowencode@gmail.com>
Wed, 23 Nov 2016 13:36:58 +0000
changeset 324084 17ac392560a7de83e968e00278c3e0abb6595c75
parent 324083 7dc106b5496086c1b25bc8e321432b26ae8114ea
child 324085 360c780c0a95e2a85ae2d82065638b4a2ea62299
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbillm
bugs1147911
milestone53.0a1
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);