OLD | NEW |
1 <script> | 1 <script> |
2 // Content settings API test | 2 // Content settings API test |
3 // Run with browser_tests --gtest_filter=ExtensionApiTest.ContentSettingsOnChang
e | 3 // Run with browser_tests --gtest_filter=ExtensionApiTest.ContentSettingsOnChang
e |
4 | 4 |
5 // Listen until |event| has fired with all of the values in |expected|. | 5 // Listen until |event| has fired with all of the values in |expected|. |
6 function listenUntil(event, expected) { | 6 function listenUntil(event, expected) { |
7 var done = chrome.test.listenForever(event, function(value) { | 7 var done = chrome.test.listenForever(event, function(value) { |
8 for (var i = 0; i < expected.length; i++) { | 8 for (var i = 0; i < expected.length; i++) { |
9 if (chrome.test.checkDeepEq(expected[i], value)) { | 9 if (chrome.test.checkDeepEq(expected[i], value)) { |
10 expected.splice(i, 1); | 10 expected.splice(i, 1); |
(...skipping 17 matching lines...) Expand all Loading... |
28 }, | 28 }, |
29 { | 29 { |
30 'value': true, | 30 'value': true, |
31 'incognitoSpecific': false, | 31 'incognitoSpecific': false, |
32 'levelOfControl': 'ControlledByThisExtension' | 32 'levelOfControl': 'ControlledByThisExtension' |
33 }]); | 33 }]); |
34 cs.misc.blockThirdPartyCookies.set({ | 34 cs.misc.blockThirdPartyCookies.set({ |
35 'value':true | 35 'value':true |
36 }, chrome.test.callbackPass()); | 36 }, chrome.test.callbackPass()); |
37 }, | 37 }, |
38 // TODO(battre): re-enable when incognito is available again. | |
39 /* | |
40 function changeIncognitoOnly() { | 38 function changeIncognitoOnly() { |
41 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{ | 39 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{ |
42 'value': false, | 40 'value': false, |
43 'incognitoSpecific': true, | 41 'incognitoSpecific': true, |
44 'levelOfControl': 'ControlledByThisExtension' | 42 'levelOfControl': 'ControlledByThisExtension' |
45 }]); | 43 }]); |
46 cs.misc.blockThirdPartyCookies.set({ | 44 cs.misc.blockThirdPartyCookies.set({ |
47 'value': false, | 45 'value': false, |
48 'incognito': true | 46 'scope': 'incognito_persistent' |
49 }, chrome.test.callbackPass()); | 47 }, chrome.test.callbackPass()); |
50 }, | 48 }, |
51 */ | |
52 function changeDefaultOnly() { | 49 function changeDefaultOnly() { |
53 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{ | 50 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{ |
54 'value': false, | 51 'value': false, |
55 'levelOfControl': 'ControlledByThisExtension' | 52 'levelOfControl': 'ControlledByThisExtension' |
56 }]); | 53 }]); |
57 cs.misc.blockThirdPartyCookies.set({ | 54 cs.misc.blockThirdPartyCookies.set({ |
58 'value': false | 55 'value': false |
59 }, chrome.test.callbackPass()); | 56 }, chrome.test.callbackPass()); |
60 }, | 57 }, |
61 // TODO(battre): re-enable when incognito is available again. | |
62 /* | |
63 function changeIncognitoOnlyBack() { | 58 function changeIncognitoOnlyBack() { |
64 // Change the incognito setting back to true so that we get an event when | 59 // Change the incognito setting back to true so that we get an event when |
65 // clearing the value. | 60 // clearing the value. |
66 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{ | 61 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{ |
67 'value': true, | 62 'value': true, |
68 'incognitoSpecific': true, | 63 'incognitoSpecific': true, |
69 'levelOfControl': 'ControlledByThisExtension' | 64 'levelOfControl': 'ControlledByThisExtension' |
70 }]); | 65 }]); |
71 cs.misc.blockThirdPartyCookies.set({ | 66 cs.misc.blockThirdPartyCookies.set({ |
72 'value': true, | 67 'value': true, |
73 'incognito': true | 68 'scope': 'incognito_persistent' |
74 }, chrome.test.callbackPass()); | 69 }, chrome.test.callbackPass()); |
75 }, | 70 }, |
76 function clearIncognito() { | 71 function clearIncognito() { |
77 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{ | 72 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{ |
78 'value': false, | 73 'value': false, |
79 'incognitoSpecific': false, | 74 'incognitoSpecific': false, |
80 'levelOfControl': 'ControlledByThisExtension' | 75 'levelOfControl': 'ControlledByThisExtension' |
81 }]); | 76 }]); |
82 cs.misc.blockThirdPartyCookies.clear({ | 77 cs.misc.blockThirdPartyCookies.clear({ |
83 'incognito': true | 78 'scope': 'incognito_persistent' |
84 }, chrome.test.callbackPass()); | 79 }, chrome.test.callbackPass()); |
85 }, | 80 }, |
86 */ | |
87 function clearDefault() { | 81 function clearDefault() { |
88 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{ | 82 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{ |
89 'value': false, | 83 'value': false, |
90 'levelOfControl': 'ControllableByThisExtension' | 84 'levelOfControl': 'ControllableByThisExtension' |
91 }, | 85 }, |
92 { | 86 { |
93 'value': false, | 87 'value': false, |
94 'incognitoSpecific': false, | 88 'incognitoSpecific': false, |
95 'levelOfControl': 'ControllableByThisExtension' | 89 'levelOfControl': 'ControllableByThisExtension' |
96 }]); | 90 }]); |
97 cs.misc.blockThirdPartyCookies.clear({}, chrome.test.callbackPass()); | 91 cs.misc.blockThirdPartyCookies.clear({}, chrome.test.callbackPass()); |
98 } | 92 } |
99 ]); | 93 ]); |
100 | 94 |
101 </script> | 95 </script> |
OLD | NEW |