Bug 1292522 - Add test for bug 1292522 - the same domain host with different port numbers must be treated as the same domain. r=smaug a=lizzard
authorDragana Damjanovic <dd.mozilla@gmail.com>
Tue, 16 Aug 2016 09:44:00 -0400
changeset 349857 e6bbc936ae4ab1c5880c5ea3ad48839c748b5262
parent 349856 b559173b179738169662cc2203d1831cd7ec9a7b
child 349858 2a0981531355dc77614e72c72fda7498bb074ffe
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, lizzard
bugs1292522
milestone50.0a2
Bug 1292522 - Add test for bug 1292522 - the same domain host with different port numbers must be treated as the same domain. r=smaug a=lizzard
dom/html/test/bug1292522_iframe.html
dom/html/test/bug1292522_page.html
dom/html/test/mochitest.ini
dom/html/test/test_bug1292522_same_domain_with_different_port_number.html
new file mode 100644
--- /dev/null
+++ b/dom/html/test/bug1292522_iframe.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html><head><title>iframe</title></head>
+  <body> 
+    <p>var testvar = "testiframe"</p>
+    <script>
+      document.domain='example.org';
+      var testvar = "testiframe";
+    </script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/html/test/bug1292522_page.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Test for Bug 1292522</title>
+    <script>
+      var check_var = function() {
+        opener.postMessage(document.getElementsByTagName('iframe')[0].contentWindow.testvar, "http://mochi.test:8888");
+      }
+    </script>
+  </head>
+  <body>
+    <iframe src="http://test2.example.org:80/tests/dom/html/test/bug1292522_iframe.html" onload="document.domain='example.org';check_var();"></iframe>
+  </body>
+</html>
--- a/dom/html/test/mochitest.ini
+++ b/dom/html/test/mochitest.ini
@@ -33,16 +33,18 @@ support-files =
   bug448564-iframe-2.html
   bug448564-iframe-3.html
   bug448564-submit.js
   bug499092.html
   bug499092.xml
   bug514856_iframe.html
   bug1260704_iframe.html
   bug1260704_iframe_empty.html
+  bug1292522_iframe.html
+  bug1292522_page.html
   ../../plugins/test/mochitest/plugin-utils.js
   test_non-ascii-cookie.html^headers^
   file_bug209275_1.html
   file_bug209275_2.html
   file_bug209275_3.html
   file_bug297761.html
   file_bug417760.png
   file_bug893537.html
@@ -622,8 +624,9 @@ skip-if = buildapp == 'mulet' || buildap
 [test_bug1261673.html]
 skip-if = (os != 'win' && os != 'linux')
 [test_bug1261674-1.html]
 skip-if = (os != 'win' && os != 'linux')
 [test_bug1261674-2.html]
 skip-if = (os != 'win' && os != 'linux')
 [test_bug1260704.html]
 [test_allowMedia.html]
+[test_bug1292522_same_domain_with_different_port_number.html]
new file mode 100644
--- /dev/null
+++ b/dom/html/test/test_bug1292522_same_domain_with_different_port_number.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1292522
+If we set domain using document.domain = "...", a page and iframe must be
+treated as the same domain if they differ in port number,
+e.g. test1.example.org:8000 and test2.example.org:80 are the same domain if
+document.domain = "example.org".
+-->
+<head>
+  <title>Test for Bug 1292522</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+  <body>
+    <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1292522">Mozilla Bug 1292522</a>
+    <p id="display"></p>
+
+    <pre id="test">
+      <script class="testbody" type="text/javascript">
+
+        if (navigator.platform.startsWith("Linux")) {
+          SimpleTest.expectAssertions(0, 1);
+        }
+        SimpleTest.waitForExplicitFinish();
+        window.addEventListener("message", onMessageReceived, false);
+
+        var page;
+
+        function onMessageReceived(event)
+        {
+          is(event.data, "testiframe", "Must be able to access the variable," +
+                                       " because page and iframe are the " +
+                                       "same domain.");
+          page.close();
+          SimpleTest.finish();
+        }
+
+        page = window.open("http://test1.example.org:8000/tests/dom/html/test/bug1292522_page.html");
+      </script>
+    </pre>
+  </body>
+</html>