Skip to content

Commit

Permalink
chore: added inline comment to explain the changes needed on one of t…
Browse files Browse the repository at this point in the history
…he existent tests

In the "deletes proxy getter/setter that are not wrapped" test case from
the "test-proxied-properties.js" test file, we ensure that when we can a
getter/setter for a non wrapped property, the getter and setter is going
to affect the original target object, unfortunately this in not true
anymore for the root object (the `chrome` API object) because we are
using an empty object (which has the `chrome` API object as its
prototype and it is not exposed outside of the polyfill sources)
as the target of the Proxy instance related to it.

Changing the target of the Proxy has been needed to prevent the
TypeError exception raised by the Proxy instance when we try to access
the "devtools" property (which is non-configurable and read-only on the
`chrome` API object).
  • Loading branch information
rpl committed Sep 25, 2017
1 parent 810d4d7 commit 97695a3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/test-proxied-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ describe("browser-polyfill", () => {
it("deletes proxy getter/setter that are not wrapped", () => {
const fakeChrome = {runtime: {}};
return setupTestDOMWindow(fakeChrome).then(window => {
// Test getter/setter behavior for non wrapped properties on
// an API namespace (because the root target of the Proxy object
// is an empty object which has the chrome API object as its
// prototype and the empty object is not exposed outside of the
// polyfill sources).
window.browser.runtime.newns = {newkey: "test-value"};

ok("newns" in window.browser.runtime, "The custom namespace is in the wrapper");
Expand Down

0 comments on commit 97695a3

Please sign in to comment.