fix: Prevent 'Previous API instantiation failed' errors on runtime.sendMessage API calls (#64)

This commit is contained in:
Luca Greco 2017-10-11 15:51:43 +02:00 committed by GitHub
parent 09d05cc073
commit 47ddfbfddb
2 changed files with 5 additions and 5 deletions

View File

@ -348,10 +348,10 @@ if (typeof browser === "undefined") {
},
};
// Create an object that has the real target as its prototype
// Create a new empty object and copy the properties of the original chrome object
// to prevent a Proxy violation exception for the devtools API getter
// (which is a read-only non-configurable property on the original target).
const targetObject = Object.create(chrome);
const targetObject = Object.assign({}, chrome);
return wrapObject(targetObject, staticWrappers, apiMetadata);
};

View File

@ -8,8 +8,10 @@ const {setupTestDOMWindow} = require("./setup");
describe("browser-polyfill", () => {
describe("proxies non-configurable read-only properties", () => {
it("creates a proxy that doesn't raise a Proxy violation exception", () => {
const fakeChrome = {};
const fakeChrome = {"devtools": {}};
// Override the property to make it non-configurable (needed to be sure that
// the polyfill is correctly workarounding the Proxy TypeError).
Object.defineProperty(fakeChrome, "devtools", {
enumarable: true,
configurable: false,
@ -22,8 +24,6 @@ describe("browser-polyfill", () => {
});
return setupTestDOMWindow(fakeChrome).then(window => {
window.browser.devtools; // eslint-disable-line
ok(window.browser.devtools.inspectedWindow,
"The non-configurable read-only property can be accessed");