| OLD | NEW |
| 1 <script> | 1 <!-- |
| 2 // Content settings API test | 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this |
| 3 // Run with browser_tests --gtest_filter=ExtensionApiTest.PreferenceSessionOnlyI
ncognito | 3 * source code is governed by a BSD-style license that can be found in the |
| 4 | 4 * LICENSE file. |
| 5 var pw = chrome.experimental.privacy.websites; | 5 --> |
| 6 function expect(expected, message) { | 6 <script src="test.js"></script> |
| 7 return chrome.test.callbackPass(function(value) { | |
| 8 chrome.test.assertNoLastError(); | |
| 9 chrome.test.assertEq(expected, value, message); | |
| 10 }); | |
| 11 } | |
| 12 chrome.test.runTests([ | |
| 13 function getRegular() { | |
| 14 pw.thirdPartyCookiesAllowed.get( | |
| 15 {}, | |
| 16 expect({ 'value': true, | |
| 17 'levelOfControl': "controllable_by_this_extension" }, | |
| 18 "third-party cookies should not be blocked")); | |
| 19 }, | |
| 20 function getIncognito() { | |
| 21 pw.thirdPartyCookiesAllowed.get( | |
| 22 { 'incognito': true }, | |
| 23 expect({ 'value': true, | |
| 24 'incognitoSpecific': false, | |
| 25 'levelOfControl': "controllable_by_this_extension" }, | |
| 26 "third-party cookies should not be blocked in incognito mode")); | |
| 27 }, | |
| 28 function set() { | |
| 29 pw.thirdPartyCookiesAllowed.set( | |
| 30 { 'scope': 'incognito_persistent', 'value': false }, | |
| 31 chrome.test.callbackPass()); | |
| 32 }, | |
| 33 function getRegular2() { | |
| 34 pw.thirdPartyCookiesAllowed.get( | |
| 35 {}, | |
| 36 expect({ 'value': true, | |
| 37 'levelOfControl': "controllable_by_this_extension" }, | |
| 38 "third-party cookies should not be blocked")); | |
| 39 }, | |
| 40 function getIncognito2() { | |
| 41 pw.thirdPartyCookiesAllowed.get( | |
| 42 { 'incognito': true }, | |
| 43 expect({ 'value': false, | |
| 44 'incognitoSpecific': true, | |
| 45 'levelOfControl': "controlled_by_this_extension" }, | |
| 46 "third-party cookies should be blocked in incognito mode")); | |
| 47 }, | |
| 48 // We cannot set session_only_persistent preferences if there is no incognito | |
| 49 // session. | |
| 50 function set2() { | |
| 51 pw.thirdPartyCookiesAllowed.set( | |
| 52 { 'scope': 'incognito_session_only', 'value': true }, | |
| 53 chrome.test.callbackFail("You cannot set a preference with scope " + | |
| 54 "'incognito_session_only' when no incognito " + | |
| 55 "window is open.")); | |
| 56 }, | |
| 57 function openIncognito() { | |
| 58 chrome.windows.create({incognito: true}, chrome.test.callbackPass()); | |
| 59 }, | |
| 60 // session_only_persistent overrides incognito_persistent. | |
| 61 function set3() { | |
| 62 pw.thirdPartyCookiesAllowed.set( | |
| 63 { 'scope': 'incognito_session_only', 'value': true }, | |
| 64 chrome.test.callbackPass()); | |
| 65 }, | |
| 66 function getRegular3() { | |
| 67 pw.thirdPartyCookiesAllowed.get( | |
| 68 {}, | |
| 69 expect({ 'value': true, | |
| 70 'levelOfControl': "controllable_by_this_extension" }, | |
| 71 "third-party cookies should not be blocked")); | |
| 72 }, | |
| 73 function getIncognito3() { | |
| 74 pw.thirdPartyCookiesAllowed.get( | |
| 75 { 'incognito': true }, | |
| 76 expect({ 'value': true, | |
| 77 'incognitoSpecific': true, | |
| 78 'levelOfControl': "controlled_by_this_extension" }, | |
| 79 "third-party cookies should be blocked in incognito mode")); | |
| 80 }, | |
| 81 ]); | |
| 82 </script> | |
| OLD | NEW |