Bug 1392202 - WebSocket CTOR should not try to look for the topmost window if the opener's top ancestor is equal to the current window top ancestor, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 12 Sep 2017 09:27:08 +0200
changeset 429763 5b048319e83005e1e95d22fac5a548626cd87eb3
parent 429739 65261dd25999fe586192298a25bdb69fd8fc63d4
child 429764 ec45cf34da3c7580be94b263f0a7e9671f3c347e
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1392202
milestone57.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 1392202 - WebSocket CTOR should not try to look for the topmost window if the opener's top ancestor is equal to the current window top ancestor, r=smaug
dom/base/WebSocket.cpp
dom/base/test/frame_bug1384658.html
dom/base/test/mochitest.ini
dom/base/test/test_bug1384658.html
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -1702,16 +1702,21 @@ WebSocketImpl::Init(JSContext* aCx,
             error.SuppressException();
             return NS_ERROR_DOM_SECURITY_ERR;
           }
 
           if (!parentWindow) {
             break;
           }
 
+          if (parentWindow->GetScriptableTop() ==
+                innerWindow->GetScriptableTop()) {
+            break;
+          }
+
           currentInnerWindow = parentWindow->GetCurrentInnerWindow();
           if (NS_WARN_IF(!currentInnerWindow)) {
             return NS_ERROR_DOM_SECURITY_ERR;
           }
 
           if (currentInnerWindow == innerWindow) {
             // The opener may be the same outer window as the parent.
             break;
new file mode 100644
--- /dev/null
+++ b/dom/base/test/frame_bug1384658.html
@@ -0,0 +1,14 @@
+<html>
+<body>
+  <form action="file_bug1384658.html" method="GET" id="form">
+    <input type='submit' name='y'>
+    <input type='hidden' name='x'>
+  </form>
+  <script>
+onload = function() {
+  document.getElementById("form").submit();
+};
+  </script>
+</body>
+</html>
+
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -244,16 +244,17 @@ support-files =
   iframe2_bug426646.html
   file1_setting_opener.html
   file2_setting_opener.html
   file3_setting_opener.html
   file4_setting_opener.html
   PASS.html
   FAIL.html
   window_bug1384658.html
+  frame_bug1384658.html
 
 [test_anchor_area_referrer.html]
 [test_anchor_area_referrer_changing.html]
 [test_anchor_area_referrer_invalid.html]
 [test_anchor_area_referrer_rel.html]
 [test_anonymousContent_api.html]
 [test_anonymousContent_append_after_reflow.html]
 [test_anonymousContent_canvas.html]
--- a/dom/base/test/test_bug1384658.html
+++ b/dom/base/test/test_bug1384658.html
@@ -7,31 +7,39 @@ https://bugzilla.mozilla.org/show_bug.cg
   <meta charset="utf-8">
   <title>Test for Bug 1384658</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
   /** Test for Bug 1384658 **/
 
-  SimpleTest.waitForExplicitFinish();
+function test_frameset() {
+  var bc = new BroadcastChannel("test_channel");
+  bc.postMessage("go");
+  bc.onmessage = ev => {
+    ok(ev.data.success, "We didn't hang");
+    bc.close();
+    test_window();
+  };
+}
+
+function test_window() {
   var win = window.open("http://example.com/tests/dom/base/test/window_bug1384658.html",
                         "_blank", "width=100,height=100");
   var bc = new BroadcastChannel("test_channel");
   bc.onmessage = ev => {
     ok(ev.data.success, "We didn't hang");
     bc.close();
     win.close();
     SimpleTest.finish();
   };
+}
+
+SimpleTest.waitForExplicitFinish();
+test_frameset();
 
   </script>
 </head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1384658">Mozilla Bug 1384658</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-</pre>
-</body>
+<frameset id="frame_set" cols="25%,75%" frameborder="yes" border="5" bordercolor="#008800">
+  <frame id="test_frame" name="test_frame" src="frame_bug1384658.html" marginwidth="20" marginheight="20">
+</frameset>
 </html>