Bug 806127 - Test that cookies from pages inside <iframe mozbrowser> are not considered third-party. r=bz
☠☠ backed out by df6cbf360b25 ☠ ☠
authorJustin Lebar <justin.lebar@gmail.com>
Tue, 30 Oct 2012 15:55:05 -0400
changeset 111800 a844765fb5d9ea82f44d90690a71bb6cb05e556d
parent 111799 7fa2f2eff658e41e55b3c6a35231afbfad571b7d
child 111801 fcf7daa9437367ef9cc4d6b26c776b72cbd3406c
push id17263
push userjlebar@mozilla.com
push dateTue, 30 Oct 2012 20:01:56 +0000
treeherdermozilla-inbound@4eba57a286d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs806127, 806168
milestone19.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 806127 - Test that cookies from pages inside <iframe mozbrowser> are not considered third-party. r=bz The test for the other change in bug 806127 (which affects IndexedDB) is in bug 806168.
dom/browser-element/mochitest/Makefile.in
dom/browser-element/mochitest/browserElement_CookiesNotThirdParty.js
dom/browser-element/mochitest/file_browserElement_CookiesNotThirdParty.html
dom/browser-element/mochitest/test_browserElement_inproc_CookiesNotThirdParty.html
dom/browser-element/mochitest/test_browserElement_oop_CookiesNotThirdParty.html
--- a/dom/browser-element/mochitest/Makefile.in
+++ b/dom/browser-element/mochitest/Makefile.in
@@ -85,16 +85,19 @@ MOCHITEST_FILES = \
 		file_browserElement_ForwardName.html \
 		browserElement_TargetBlank.js \
 		test_browserElement_inproc_TargetBlank.html \
 		file_browserElement_TargetBlank.html \
 		browserElement_PromptCheck.js \
 		test_browserElement_inproc_PromptCheck.html \
 		browserElement_PromptConfirm.js \
 		test_browserElement_inproc_PromptConfirm.html \
+		browserElement_CookiesNotThirdParty.js \
+		file_browserElement_CookiesNotThirdParty.html \
+		test_browserElement_inproc_CookiesNotThirdParty.html \
 		browserElement_Close.js \
 		test_browserElement_inproc_Close.html \
 		browserElement_CloseFromOpener.js \
 		test_browserElement_inproc_CloseFromOpener.html \
 		file_browserElement_CloseFromOpener.html \
 		browserElement_CloseApp.js \
 		test_browserElement_inproc_CloseApp.html \
 		file_browserElement_CloseApp.html \
@@ -189,16 +192,17 @@ MOCHITEST_FILES += \
 		test_browserElement_oop_FirstPaint.html \
 		test_browserElement_oop_Alert.html \
 		test_browserElement_oop_AlertInFrame.html \
 		test_browserElement_oop_TargetTop.html \
 		test_browserElement_oop_ForwardName.html \
 		test_browserElement_oop_TargetBlank.html \
 		test_browserElement_oop_PromptCheck.html \
 		test_browserElement_oop_PromptConfirm.html \
+		test_browserElement_oop_CookiesNotThirdParty.html \
 		test_browserElement_oop_Close.html \
 		test_browserElement_oop_CloseFromOpener.html \
 		test_browserElement_oop_CloseApp.html \
 		test_browserElement_oop_OpenWindow.html \
 		test_browserElement_oop_OpenWindowInFrame.html \
 		test_browserElement_oop_OpenWindowRejected.html \
 		test_browserElement_oop_OpenWindowDifferentOrigin.html \
 		test_browserElement_oop_OpenNamed.html \
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/browserElement_CookiesNotThirdParty.js
@@ -0,0 +1,50 @@
+/* Any copyright is dedicated to the public domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Bug 806127 - Test that cookies set by <iframe mozbrowser> are not considered
+// third-party.
+"use strict";
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+  browserElementTestHelpers.setEnabledPref(true);
+  browserElementTestHelpers.addPermission();
+
+  const innerPage = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_CookiesNotThirdParty.html';
+
+  var iframe = document.createElement('iframe');
+  iframe.mozbrowser = true;
+
+  iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
+    if (e.detail.message == 'next') {
+      iframe.src = innerPage + '?step=2';
+      return;
+    }
+
+    if (e.detail.message.startsWith('success:')) {
+      ok(true, e.detail.message);
+      return;
+    }
+
+    if (e.detail.message.startsWith('failure:')) {
+      ok(false, e.detail.message);
+      return;
+    }
+
+    if (e.detail.message == 'finish') {
+      SimpleTest.finish();
+    }
+  });
+
+  // innerPage will set a cookie and then alert('next').  We'll load
+  // innerPage?step=2.  That page will check that the cooke exists (despite the
+  // fact that we've disabled third-party cookies) and alert('success:') or
+  // alert('failure:'), as appropriate.  Finally, the page will
+  // alert('finish');
+  iframe.src = innerPage;
+  document.body.appendChild(iframe);
+}
+
+// Disable third-party cookies for this test.
+SpecialPowers.pushPrefEnv({'set': [['network.cookie.cookieBehavior', 1]]}, runTest);
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/file_browserElement_CookiesNotThirdParty.html
@@ -0,0 +1,25 @@
+<html>
+<body>
+file_browserElement_CookiesNotThirdParty.html
+
+<script type='text/javascript;version=1.7'>
+if (location.search != '?step=2') {
+  // Step 1: Set a cookie.
+  document.cookie = 'file_browserElement_CookiesNotThirdParty';
+  alert('next');
+}
+else {
+  // Step 2: Read the cookie.
+  if (document.cookie == 'file_browserElement_CookiesNotThirdParty') {
+    alert('success: got the correct cookie');
+  }
+  else {
+    alert('failure: got unexpected cookie: "' + document.cookie + '"');
+  }
+
+  alert('finish');
+}
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/test_browserElement_inproc_CookiesNotThirdParty.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for Bug 806127</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script type="application/javascript;version=1.7" src="browserElement_CookiesNotThirdParty.js">
+</script>
+</body>
+</html>
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/test_browserElement_oop_CookiesNotThirdParty.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for Bug 806127</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script type="application/javascript;version=1.7" src="browserElement_CookiesNotThirdParty.js">
+</script>
+</body>
+</html>
\ No newline at end of file