fix: Added missing chrome privacy api settings (#205)
This commit is contained in:
parent
b8e374a37a
commit
87bdfa844d
|
@ -259,6 +259,9 @@ if (typeof browser === "undefined" || Object.getPrototypeOf(browser) !== Object.
|
||||||
// of. Create a sub-object wrapper for it with the appropriate child
|
// of. Create a sub-object wrapper for it with the appropriate child
|
||||||
// metadata.
|
// metadata.
|
||||||
value = wrapObject(value, wrappers[prop], metadata[prop]);
|
value = wrapObject(value, wrappers[prop], metadata[prop]);
|
||||||
|
} else if (hasOwnProperty(metadata, "*")) {
|
||||||
|
// Wrap all properties in * namespace.
|
||||||
|
value = wrapObject(value, wrappers[prop], metadata["*"]);
|
||||||
} else {
|
} else {
|
||||||
// We don't need to do any wrapping for this property,
|
// We don't need to do any wrapping for this property,
|
||||||
// so just forward all access to the underlying object.
|
// so just forward all access to the underlying object.
|
||||||
|
@ -492,17 +495,9 @@ if (typeof browser === "undefined" || Object.getPrototypeOf(browser) !== Object.
|
||||||
set: {minArgs: 1, maxArgs: 1},
|
set: {minArgs: 1, maxArgs: 1},
|
||||||
};
|
};
|
||||||
apiMetadata.privacy = {
|
apiMetadata.privacy = {
|
||||||
network: {
|
network: {"*": settingMetadata},
|
||||||
networkPredictionEnabled: settingMetadata,
|
services: {"*": settingMetadata},
|
||||||
webRTCIPHandlingPolicy: settingMetadata,
|
websites: {"*": settingMetadata},
|
||||||
},
|
|
||||||
services: {
|
|
||||||
passwordSavingEnabled: settingMetadata,
|
|
||||||
},
|
|
||||||
websites: {
|
|
||||||
hyperlinkAuditingEnabled: settingMetadata,
|
|
||||||
referrersEnabled: settingMetadata,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return wrapObject(extensionAPIs, staticWrappers, apiMetadata);
|
return wrapObject(extensionAPIs, staticWrappers, apiMetadata);
|
||||||
|
|
|
@ -181,4 +181,36 @@ describe("browser-polyfill", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Privacy API", () => {
|
||||||
|
it("Should wrap chrome.privacy.* API", () => {
|
||||||
|
let lazyInitCount = 0;
|
||||||
|
|
||||||
|
const fakeChrome = {
|
||||||
|
privacy: {
|
||||||
|
get network() {
|
||||||
|
++lazyInitCount;
|
||||||
|
const networkPredictionEnabled = {
|
||||||
|
get: () => {},
|
||||||
|
set: () => {},
|
||||||
|
clear: () => {},
|
||||||
|
};
|
||||||
|
return {networkPredictionEnabled};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return setupTestDOMWindow(fakeChrome).then(window => {
|
||||||
|
equal(lazyInitCount, 0, "chrome.privacy.network is not accessed first");
|
||||||
|
const {get, set, clear} = window.browser.privacy.network.networkPredictionEnabled;
|
||||||
|
equal(get({}).then !== undefined, true, "Privacy API get method is a Promise");
|
||||||
|
equal(set({}).then !== undefined, true, "Privacy API set method is a Promise");
|
||||||
|
equal(clear({}).then !== undefined, true, "Privacy API clear method is a Promise");
|
||||||
|
equal(lazyInitCount, 1, "chrome.privacy.network should be accessed only once");
|
||||||
|
|
||||||
|
window.browser.privacy.network.networkPredictionEnabled.get({});
|
||||||
|
equal(lazyInitCount, 1, "chrome.privacy.network should be accessed only once");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue