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