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

Unified Diff: chrome/test/data/extensions/api_test/native_bindings/extension/background.js

Issue 2718543004: [Extensions Bindings] Add ChromeSetting custom type (Closed)
Patch Set: rebase Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/native_bindings/extension/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/native_bindings/extension/background.js
diff --git a/chrome/test/data/extensions/api_test/native_bindings/extension/background.js b/chrome/test/data/extensions/api_test/native_bindings/extension/background.js
index ef260c44ac3bfa5efd2a464576df49de57b6e834..43128091ca427ce4ce72a0f54907a5dfd848aa4d 100644
--- a/chrome/test/data/extensions/api_test/native_bindings/extension/background.js
+++ b/chrome/test/data/extensions/api_test/native_bindings/extension/background.js
@@ -156,6 +156,56 @@ var tests = [
// browserAction.setIcon uses a custom hook that calls sendRequest().
chrome.browserAction.setIcon({path: 'icon.png'}, chrome.test.succeed);
},
+ function testChromeSetting() {
+ chrome.test.assertTrue(!!chrome.privacy, 'privacy');
+ chrome.test.assertTrue(!!chrome.privacy.websites, 'websites');
+ var cookiePolicy = chrome.privacy.websites.thirdPartyCookiesAllowed;
+ chrome.test.assertTrue(!!cookiePolicy, 'cookie policy');
+ chrome.test.assertTrue(!!cookiePolicy.get, 'get');
+ chrome.test.assertTrue(!!cookiePolicy.set, 'set');
+ chrome.test.assertTrue(!!cookiePolicy.clear, 'clear');
+ chrome.test.assertTrue(!!cookiePolicy.onChange, 'onchange');
+
+ // The JSON spec for ChromeSettings is weird, because it claims it allows
+ // any type for <val> in ChromeSetting.set({value: <val>}), but this is just
+ // a hack in our schema generation because we curry in the different types
+ // of restrictions. Trying to pass in the wrong type for value should fail
+ // (synchronously).
+ var caught = false;
+ try {
+ cookiePolicy.set({value: 'not a bool'});
+ } catch (e) {
+ caught = true;
+ }
+ chrome.test.assertTrue(caught, 'caught');
+
+ var listenerPromise = new Promise((resolve, reject) => {
+ cookiePolicy.onChange.addListener(function listener(details) {
+ chrome.test.assertTrue(!!details, 'listener details');
+ chrome.test.assertEq(false, details.value);
+ cookiePolicy.onChange.removeListener(listener);
+ resolve();
+ });
+ });
+
+ var methodPromise = new Promise((resolve, reject) => {
+ cookiePolicy.get({}, (details) => {
+ chrome.test.assertTrue(!!details, 'get details');
+ chrome.test.assertTrue(details.value, 'details value true');
+ cookiePolicy.set({value: false}, () => {
+ cookiePolicy.get({}, (details) => {
+ chrome.test.assertTrue(!!details, 'get details');
+ chrome.test.assertFalse(details.value, 'details value false');
+ resolve();
+ });
+ });
+ });
+ });
+
+ Promise.all([listenerPromise, methodPromise]).then(() => {
+ chrome.test.succeed();
+ });
+ },
];
chrome.test.getConfig(config => {
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/native_bindings/extension/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698