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

Side by Side Diff: chrome/test/data/extensions/api_test/content_settings/onchange/test.html

Issue 6596044: Add onChange event to preference extension APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 9 years, 9 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
(Empty)
1 <script>
2 // Content settings API test
3 // Run with browser_tests --gtest_filter=ExtensionApiTest.ContentSettingsOnChang e
4
5 // Listen until |event| has fired with all of the values in |expected|.
6 function listenUntil(event, expected) {
battre 2011/03/10 13:07:28 add a comment that listenForever subscribes to bot
Bernhard Bauer 2011/03/10 14:51:15 I think we already explain that sufficiently below
7 var done = chrome.test.listenForever(event, function(value) {
8 for (var i = 0; i < expected.length; i++) {
9 if (chrome.test.checkDeepEq(expected[i], value)) {
10 expected.splice(i, 1);
11 if (expected.length == 0)
12 done();
13 return;
14 }
15 }
16 chrome.test.fail("Unexpected event: " + JSON.stringify(value));
17 });
18 }
19
20 var cs = chrome.experimental.contentSettings;
21 chrome.test.runTests([
22 function changeDefault() {
battre 2011/03/10 13:07:28 add comment // Setting the value for the first tim
Bernhard Bauer 2011/03/10 14:51:15 Done.
23 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{
24 'value': true,
25 'levelOfControl': 'ControlledByThisExtension'
26 },
27 {
28 'value': true,
29 'incognitoSpecific': false,
30 'levelOfControl': 'ControlledByThisExtension'
31 }]);
32 cs.misc.blockThirdPartyCookies.set({
33 'value':true
34 }, chrome.test.callbackPass());
35 },
36 function changeIncognitoOnly() {
37 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{
38 'value': false,
39 'incognitoSpecific': true,
40 'levelOfControl': 'ControlledByThisExtension'
41 }]);
42 cs.misc.blockThirdPartyCookies.set({
43 'value': false,
44 'incognito': true
45 }, chrome.test.callbackPass());
46 },
47 function changeDefaultOnly() {
48 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{
49 'value': false,
50 'levelOfControl': 'ControlledByThisExtension'
51 }]);
52 cs.misc.blockThirdPartyCookies.set({
53 'value': false
54 }, chrome.test.callbackPass());
55 },
56 function changeIncognitoOnlyBack() {
57 // Change the incognito setting back to true so that we get an event when
58 // clearing the value.
59 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{
60 'value': true,
61 'incognitoSpecific': true,
62 'levelOfControl': 'ControlledByThisExtension'
63 }]);
64 cs.misc.blockThirdPartyCookies.set({
65 'value': true,
66 'incognito': true
67 }, chrome.test.callbackPass());
68 },
69 function clearIncognito() {
70 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{
71 'value': false,
72 'incognitoSpecific': false,
73 'levelOfControl': 'ControlledByThisExtension'
74 }]);
75 cs.misc.blockThirdPartyCookies.clear({
76 'incognito': true
77 }, chrome.test.callbackPass());
78 },
79 function clearDefault() {
80 listenUntil(cs.misc.blockThirdPartyCookies.onChange, [{
81 'value': false,
82 'levelOfControl': 'ControllableByThisExtension'
83 },
84 {
85 'value': false,
86 'incognitoSpecific': false,
87 'levelOfControl': 'ControllableByThisExtension'
88 }]);
89 cs.misc.blockThirdPartyCookies.clear({}, chrome.test.callbackPass());
90 }
91 ]);
92
93 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698