Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the public domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | // Bug 806127 - Test that cookies set by <iframe mozbrowser> are not considered |
michael@0 | 5 | // third-party. |
michael@0 | 6 | "use strict"; |
michael@0 | 7 | |
michael@0 | 8 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 9 | browserElementTestHelpers.setEnabledPref(true); |
michael@0 | 10 | browserElementTestHelpers.addPermission(); |
michael@0 | 11 | |
michael@0 | 12 | function runTest() { |
michael@0 | 13 | const innerPage = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_CookiesNotThirdParty.html'; |
michael@0 | 14 | |
michael@0 | 15 | var iframe = document.createElement('iframe'); |
michael@0 | 16 | SpecialPowers.wrap(iframe).mozbrowser = true; |
michael@0 | 17 | |
michael@0 | 18 | iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { |
michael@0 | 19 | if (e.detail.message == 'next') { |
michael@0 | 20 | iframe.src = innerPage + '?step=2'; |
michael@0 | 21 | return; |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | if (e.detail.message.startsWith('success:')) { |
michael@0 | 25 | ok(true, e.detail.message); |
michael@0 | 26 | return; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | if (e.detail.message.startsWith('failure:')) { |
michael@0 | 30 | ok(false, e.detail.message); |
michael@0 | 31 | return; |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | if (e.detail.message == 'finish') { |
michael@0 | 35 | SimpleTest.finish(); |
michael@0 | 36 | } |
michael@0 | 37 | }); |
michael@0 | 38 | |
michael@0 | 39 | // innerPage will set a cookie and then alert('next'). We'll load |
michael@0 | 40 | // innerPage?step=2. That page will check that the cooke exists (despite the |
michael@0 | 41 | // fact that we've disabled third-party cookies) and alert('success:') or |
michael@0 | 42 | // alert('failure:'), as appropriate. Finally, the page will |
michael@0 | 43 | // alert('finish'); |
michael@0 | 44 | iframe.src = innerPage; |
michael@0 | 45 | document.body.appendChild(iframe); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | // Disable third-party cookies for this test. |
michael@0 | 49 | addEventListener('testready', function() { |
michael@0 | 50 | SpecialPowers.pushPrefEnv({'set': [['network.cookie.cookieBehavior', 1]]}, runTest); |
michael@0 | 51 | }); |