Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* Any copyright is dedicated to the public domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 // Bug 806127 - Test that cookies set by <iframe mozbrowser> are not considered
5 // third-party.
6 "use strict";
8 SimpleTest.waitForExplicitFinish();
9 browserElementTestHelpers.setEnabledPref(true);
10 browserElementTestHelpers.addPermission();
12 function runTest() {
13 const innerPage = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_CookiesNotThirdParty.html';
15 var iframe = document.createElement('iframe');
16 SpecialPowers.wrap(iframe).mozbrowser = true;
18 iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
19 if (e.detail.message == 'next') {
20 iframe.src = innerPage + '?step=2';
21 return;
22 }
24 if (e.detail.message.startsWith('success:')) {
25 ok(true, e.detail.message);
26 return;
27 }
29 if (e.detail.message.startsWith('failure:')) {
30 ok(false, e.detail.message);
31 return;
32 }
34 if (e.detail.message == 'finish') {
35 SimpleTest.finish();
36 }
37 });
39 // innerPage will set a cookie and then alert('next'). We'll load
40 // innerPage?step=2. That page will check that the cooke exists (despite the
41 // fact that we've disabled third-party cookies) and alert('success:') or
42 // alert('failure:'), as appropriate. Finally, the page will
43 // alert('finish');
44 iframe.src = innerPage;
45 document.body.appendChild(iframe);
46 }
48 // Disable third-party cookies for this test.
49 addEventListener('testready', function() {
50 SpecialPowers.pushPrefEnv({'set': [['network.cookie.cookieBehavior', 1]]}, runTest);
51 });