Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: chrome/test/data/extensions/api_test/preference/session_only_incognito/test.html

Issue 7298005: Expose privacy-relevant preferences via Chrome's extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <script> 1 <script>
2 // Content settings API test 2 // Content settings API test
3 // Run with browser_tests --gtest_filter=ExtensionApiTest.SessionOnlyIncognitoCo ntentSettings 3 // Run with browser_tests --gtest_filter=ExtensionApiTest.PreferenceSessionOnlyI ncognito
4 4
5 var cs = chrome.experimental.contentSettings; 5 var pw = chrome.experimental.privacy.websites;
6 function expect(expected, message) { 6 function expect(expected, message) {
7 return chrome.test.callbackPass(function(value) { 7 return chrome.test.callbackPass(function(value) {
8 chrome.test.assertNoLastError(); 8 chrome.test.assertNoLastError();
9 chrome.test.assertEq(expected, value, message); 9 chrome.test.assertEq(expected, value, message);
10 }); 10 });
11 } 11 }
12 chrome.test.runTests([ 12 chrome.test.runTests([
13 function getRegular() { 13 function getRegular() {
14 cs.global.thirdPartyCookiesAllowed.get( 14 pw.thirdPartyCookiesAllowed.get(
15 {}, 15 {},
16 expect({ 'value': true, 16 expect({ 'value': true,
17 'levelOfControl': "controllable_by_this_extension" }, 17 'levelOfControl': "controllable_by_this_extension" },
18 "third-party cookies should not be blocked")); 18 "third-party cookies should not be blocked"));
19 }, 19 },
20 function getIncognito() { 20 function getIncognito() {
21 cs.global.thirdPartyCookiesAllowed.get( 21 pw.thirdPartyCookiesAllowed.get(
22 { 'incognito': true }, 22 { 'incognito': true },
23 expect({ 'value': true, 23 expect({ 'value': true,
24 'incognitoSpecific': false, 24 'incognitoSpecific': false,
25 'levelOfControl': "controllable_by_this_extension" }, 25 'levelOfControl': "controllable_by_this_extension" },
26 "third-party cookies should not be blocked in incognito mode")); 26 "third-party cookies should not be blocked in incognito mode"));
27 }, 27 },
28 function set() { 28 function set() {
29 cs.global.thirdPartyCookiesAllowed.set( 29 pw.thirdPartyCookiesAllowed.set(
30 { 'scope': 'incognito_persistent', 'value': false }, 30 { 'scope': 'incognito_persistent', 'value': false },
31 chrome.test.callbackPass()); 31 chrome.test.callbackPass());
32 }, 32 },
33 function getRegular2() { 33 function getRegular2() {
34 cs.global.thirdPartyCookiesAllowed.get( 34 pw.thirdPartyCookiesAllowed.get(
35 {}, 35 {},
36 expect({ 'value': true, 36 expect({ 'value': true,
37 'levelOfControl': "controllable_by_this_extension" }, 37 'levelOfControl': "controllable_by_this_extension" },
38 "third-party cookies should not be blocked")); 38 "third-party cookies should not be blocked"));
39 }, 39 },
40 function getIncognito2() { 40 function getIncognito2() {
41 cs.global.thirdPartyCookiesAllowed.get( 41 pw.thirdPartyCookiesAllowed.get(
42 { 'incognito': true }, 42 { 'incognito': true },
43 expect({ 'value': false, 43 expect({ 'value': false,
44 'incognitoSpecific': true, 44 'incognitoSpecific': true,
45 'levelOfControl': "controlled_by_this_extension" }, 45 'levelOfControl': "controlled_by_this_extension" },
46 "third-party cookies should be blocked in incognito mode")); 46 "third-party cookies should be blocked in incognito mode"));
47 }, 47 },
48 // We cannot set session_only_persistent preferences if there is no incognito 48 // We cannot set session_only_persistent preferences if there is no incognito
49 // session. 49 // session.
50 function set2() { 50 function set2() {
51 cs.global.thirdPartyCookiesAllowed.set( 51 pw.thirdPartyCookiesAllowed.set(
52 { 'scope': 'incognito_session_only', 'value': true }, 52 { 'scope': 'incognito_session_only', 'value': true },
53 chrome.test.callbackFail("You cannot set a preference with scope " + 53 chrome.test.callbackFail("You cannot set a preference with scope " +
54 "'incognito_session_only' when no incognito " + 54 "'incognito_session_only' when no incognito " +
55 "window is open.")); 55 "window is open."));
56 }, 56 },
57 function openIncognito() { 57 function openIncognito() {
58 chrome.windows.create({incognito: true}, chrome.test.callbackPass()); 58 chrome.windows.create({incognito: true}, chrome.test.callbackPass());
59 }, 59 },
60 // session_only_persistent overrides incognito_persistent. 60 // session_only_persistent overrides incognito_persistent.
61 function set3() { 61 function set3() {
62 cs.global.thirdPartyCookiesAllowed.set( 62 pw.thirdPartyCookiesAllowed.set(
63 { 'scope': 'incognito_session_only', 'value': true }, 63 { 'scope': 'incognito_session_only', 'value': true },
64 chrome.test.callbackPass()); 64 chrome.test.callbackPass());
65 }, 65 },
66 function getRegular3() { 66 function getRegular3() {
67 cs.global.thirdPartyCookiesAllowed.get( 67 pw.thirdPartyCookiesAllowed.get(
68 {}, 68 {},
69 expect({ 'value': true, 69 expect({ 'value': true,
70 'levelOfControl': "controllable_by_this_extension" }, 70 'levelOfControl': "controllable_by_this_extension" },
71 "third-party cookies should not be blocked")); 71 "third-party cookies should not be blocked"));
72 }, 72 },
73 function getIncognito3() { 73 function getIncognito3() {
74 cs.global.thirdPartyCookiesAllowed.get( 74 pw.thirdPartyCookiesAllowed.get(
75 { 'incognito': true }, 75 { 'incognito': true },
76 expect({ 'value': true, 76 expect({ 'value': true,
77 'incognitoSpecific': true, 77 'incognitoSpecific': true,
78 'levelOfControl': "controlled_by_this_extension" }, 78 'levelOfControl': "controlled_by_this_extension" },
79 "third-party cookies should be blocked in incognito mode")); 79 "third-party cookies should be blocked in incognito mode"));
80 }, 80 },
81 ]); 81 ]);
82 </script> 82 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698