| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Content settings API test | 5 // Content settings API test |
| 6 // Run with browser_tests --gtest_filter=ExtensionApiTest.PreferenceOnChange | 6 // Run with browser_tests --gtest_filter=ExtensionApiTest.PreferenceOnChange |
| 7 | 7 |
| 8 // Listen until |event| has fired with all of the values in |expected|. | 8 // Listen until |event| has fired with all of the values in |expected|. |
| 9 function listenUntil(event, expected) { | 9 function listenUntil(event, expected) { |
| 10 var done = chrome.test.listenForever(event, function(value) { | 10 var done = chrome.test.listenForever(event, function(value) { |
| 11 for (var i = 0; i < expected.length; i++) { | 11 for (var i = 0; i < expected.length; i++) { |
| 12 if (chrome.test.checkDeepEq(expected[i], value)) { | 12 if (chrome.test.checkDeepEq(expected[i], value)) { |
| 13 expected.splice(i, 1); | 13 expected.splice(i, 1); |
| 14 if (expected.length == 0) | 14 if (expected.length == 0) |
| 15 done(); | 15 done(); |
| 16 return; | 16 return; |
| 17 } | 17 } |
| 18 } | 18 } |
| 19 chrome.test.fail("Unexpected event: " + JSON.stringify(value)); | 19 chrome.test.fail("Unexpected event: " + JSON.stringify(value)); |
| 20 }); | 20 }); |
| 21 } | 21 } |
| 22 | 22 |
| 23 var pw = chrome.experimental.privacy.websites; | 23 var pw = chrome.privacy.websites; |
| 24 chrome.test.runTests([ | 24 chrome.test.runTests([ |
| 25 function changeDefault() { | 25 function changeDefault() { |
| 26 // Changing the regular settings when no incognito-specific settings are | 26 // Changing the regular settings when no incognito-specific settings are |
| 27 // defined should fire two events. | 27 // defined should fire two events. |
| 28 listenUntil(pw.thirdPartyCookiesAllowed.onChange, [{ | 28 listenUntil(pw.thirdPartyCookiesAllowed.onChange, [{ |
| 29 'value': false, | 29 'value': false, |
| 30 'levelOfControl': 'controlled_by_this_extension' | 30 'levelOfControl': 'controlled_by_this_extension' |
| 31 }, | 31 }, |
| 32 { | 32 { |
| 33 'value': false, | 33 'value': false, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 'levelOfControl': 'controllable_by_this_extension' | 87 'levelOfControl': 'controllable_by_this_extension' |
| 88 }, | 88 }, |
| 89 { | 89 { |
| 90 'value': true, | 90 'value': true, |
| 91 'incognitoSpecific': false, | 91 'incognitoSpecific': false, |
| 92 'levelOfControl': 'controllable_by_this_extension' | 92 'levelOfControl': 'controllable_by_this_extension' |
| 93 }]); | 93 }]); |
| 94 pw.thirdPartyCookiesAllowed.clear({}, chrome.test.callbackPass()); | 94 pw.thirdPartyCookiesAllowed.clear({}, chrome.test.callbackPass()); |
| 95 } | 95 } |
| 96 ]); | 96 ]); |
| OLD | NEW |