|
1 /* Any copyright is dedicated to the public domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Bug 806127 - Test that cookies set by <iframe mozbrowser> are not considered |
|
5 // third-party. |
|
6 "use strict"; |
|
7 |
|
8 SimpleTest.waitForExplicitFinish(); |
|
9 browserElementTestHelpers.setEnabledPref(true); |
|
10 browserElementTestHelpers.addPermission(); |
|
11 |
|
12 function runTest() { |
|
13 const innerPage = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_CookiesNotThirdParty.html'; |
|
14 |
|
15 var iframe = document.createElement('iframe'); |
|
16 SpecialPowers.wrap(iframe).mozbrowser = true; |
|
17 |
|
18 iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { |
|
19 if (e.detail.message == 'next') { |
|
20 iframe.src = innerPage + '?step=2'; |
|
21 return; |
|
22 } |
|
23 |
|
24 if (e.detail.message.startsWith('success:')) { |
|
25 ok(true, e.detail.message); |
|
26 return; |
|
27 } |
|
28 |
|
29 if (e.detail.message.startsWith('failure:')) { |
|
30 ok(false, e.detail.message); |
|
31 return; |
|
32 } |
|
33 |
|
34 if (e.detail.message == 'finish') { |
|
35 SimpleTest.finish(); |
|
36 } |
|
37 }); |
|
38 |
|
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 } |
|
47 |
|
48 // Disable third-party cookies for this test. |
|
49 addEventListener('testready', function() { |
|
50 SpecialPowers.pushPrefEnv({'set': [['network.cookie.cookieBehavior', 1]]}, runTest); |
|
51 }); |