test: tweak the proxied properties tests.
This commit is contained in:
parent
a1469d6f17
commit
7a247f56f2
|
@ -9,16 +9,48 @@ describe("browser-polyfill", () => {
|
||||||
it("should proxy getters and setters", () => {
|
it("should proxy getters and setters", () => {
|
||||||
const fakeChrome = {
|
const fakeChrome = {
|
||||||
runtime: {myprop: "previous-value"},
|
runtime: {myprop: "previous-value"},
|
||||||
nowrapns: {nowrapkey: "previous-value"},
|
nowrapns: {
|
||||||
|
nowrapkey: "previous-value",
|
||||||
|
nowrapkey2: "previous-value",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
return setupTestDOMWindow(fakeChrome).then(window => {
|
return setupTestDOMWindow(fakeChrome).then(window => {
|
||||||
|
// Check that the property values on the generated wrapper.
|
||||||
|
assert.equal(window.browser.runtime.myprop, "previous-value",
|
||||||
|
"Got the expected result from setting a wrapped property name");
|
||||||
|
assert.equal(window.browser.nowrapns.nowrapkey, "previous-value",
|
||||||
|
"Got the expected result from setting a wrapped property name");
|
||||||
|
|
||||||
|
// Update the properties on the generated wrapper.
|
||||||
const setResult = window.browser.runtime.myprop = "new-value";
|
const setResult = window.browser.runtime.myprop = "new-value";
|
||||||
const setResult2 = window.browser.nowrapns.nowrapkey = "new-value";
|
const setResult2 = window.browser.nowrapns.nowrapkey = "new-value";
|
||||||
|
|
||||||
|
// Check the results of setting the new value of the wrapped properties.
|
||||||
assert.equal(setResult, "new-value",
|
assert.equal(setResult, "new-value",
|
||||||
"Got the expected result from setting a wrapped property name");
|
"Got the expected result from setting a wrapped property name");
|
||||||
assert.equal(setResult2, "new-value",
|
assert.equal(setResult2, "new-value",
|
||||||
"Got the expected result from setting a wrapped property name");
|
"Got the expected result from setting a wrapped property name");
|
||||||
|
|
||||||
|
// Verify that the wrapped properties has been updated.
|
||||||
|
assert.equal(window.browser.runtime.myprop, "new-value",
|
||||||
|
"Got the expected updated value from the browser property");
|
||||||
|
assert.equal(window.browser.nowrapns.nowrapkey, "new-value",
|
||||||
|
"Got the expected updated value from the browser property");
|
||||||
|
|
||||||
|
// Verify that the target properties has been updated.
|
||||||
|
assert.equal(window.chrome.runtime.myprop, "new-value",
|
||||||
|
"Got the expected updated value on the related chrome property");
|
||||||
|
assert.equal(window.chrome.nowrapns.nowrapkey, "new-value",
|
||||||
|
"Got the expected updated value on the related chrome property");
|
||||||
|
|
||||||
|
// Set a property multiple times before read.
|
||||||
|
window.browser.nowrapns.nowrapkey2 = "new-value2";
|
||||||
|
window.browser.nowrapns.nowrapkey2 = "new-value3";
|
||||||
|
|
||||||
|
assert.equal(window.chrome.nowrapns.nowrapkey2, "new-value3",
|
||||||
|
"Got the expected updated value on the related chrome property");
|
||||||
|
assert.equal(window.browser.nowrapns.nowrapkey2, "new-value3",
|
||||||
|
"Got the expected updated value on the wrapped property");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue