Closed Bug 1149158 Opened 10 years ago Closed 7 years ago

[e10s] test-page-mod.js causes unsafe CPOW usage warnings

Categories

(Add-on SDK Graveyard :: General, defect, P3)

defect

Tracking

(e10s+)

RESOLVED INCOMPLETE
Tracking Status
e10s + ---

People

(Reporter: mconley, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [unsafe-cpow-usage] test, triaged)

Attachments

(1 file)

Mined from test logs In addon-sdk/source/test/tabs/test-page-mod.js: https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l108 function createPageModTest(include, expectedMatch) { // Create an 'onload' test function... asserts.push(function(test, win) { var matches = include in win.localStorage; <-- causes unsafe CPOW usage warning assert.ok(expectedMatch ? matches : !matches, "'" + include + "' match test, expected: " + expectedMatch); }); // ...and corresponding PageMod options return { include: include, contentScript: 'new ' + function() { self.on("message", function(msg) { window.localStorage[msg] = true; }); }, // The testPageMod callback with test assertions is called on 'end', // and we want this page mod to be attached before it gets called, // so we attach it on 'start'. contentScriptWhen: 'start', onAttach: function(worker) { worker.postMessage(this.include[0]); } }; } ... https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l138 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l142 testPageMod(assert, done, testPageURI, [ createPageModTest("*", false), createPageModTest("*.google.com", false), createPageModTest("resource:*", true), createPageModTest("resource:", false), createPageModTest(testPageURI, true) ], function (win, done) { waitUntil(() => win.localStorage[testPageURI], <-- causes unsafe CPOW usage warning testPageURI + " page-mod to be executed") .then(() => { asserts.forEach(fn => fn(assert, win)); win.localStorage.clear(); <-- causes unsafe CPOW usage warning done(); }); }); ... https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l153 function createPageModTest(include, exclude, expectedMatch) { // Create an 'onload' test function... asserts.push(function(test, win) { var matches = JSON.stringify([include, exclude]) in win.localStorage; <-- causes unsafe CPOW usage warning assert.ok(expectedMatch ? matches : !matches, "[include, exclude] = [" + include + ", " + exclude + "] match test, expected: " + expectedMatch); }); // ...and corresponding PageMod options return { include: include, exclude: exclude, contentScript: 'new ' + function() { self.on("message", function(msg) { // The key in localStorage is "[<include>, <exclude>]". window.localStorage[JSON.stringify(msg)] = true; }); }, // The testPageMod callback with test assertions is called on 'end', // and we want this page mod to be attached before it gets called, // so we attach it on 'start'. contentScriptWhen: 'start', onAttach: function(worker) { worker.postMessage([this.include[0], this.exclude[0]]); } }; } ... https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l185 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l189 testPageMod(assert, done, testPageURI, [ createPageModTest("*", testPageURI, false), createPageModTest(testPageURI, testPageURI, false), createPageModTest(testPageURI, "resource://*", false), createPageModTest(testPageURI, "*.google.com", true) ], function (win, done) { waitUntil(() => win.localStorage[JSON.stringify([testPageURI, "*.google.com"])], <-- causes unsafe CPOW usage warning testPageURI + " page-mod to be executed") .then(() => { asserts.forEach(fn => fn(assert, win)); win.localStorage.clear(); <-- causes unsafe CPOW usage warning done(); }); }); ... https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1061 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1063 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1066 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1069 exports.testPageModCss = function(assert, done) { let [pageMod] = testPageMod(assert, done, 'data:text/html;charset=utf-8,<div style="background: silver">css test</div>', [{ include: ["*", "data:*"], contentStyle: "div { height: 100px; }", contentStyleFile: [data.url("include-file.css"), "./border-style.css"] }], function(win, done) { let div = win.document.querySelector("div"); <-- causes unsafe CPOW usage warning assert.equal(div.clientHeight, 100, <-- causes unsafe CPOW usage warning "PageMod contentStyle worked"); assert.equal(div.offsetHeight, 120, <-- causes unsafe CPOW usage warning "PageMod contentStyleFile worked"); assert.equal(win.getComputedStyle(div).borderTopStyle, "dashed", <-- causes unsafe CPOW usage warning "PageMod contentStyleFile with relative path worked"); done(); } ); }; ... https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1096 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1097 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1100 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1106 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1112 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1118 function(win, done) { let div = win.document.querySelector("div"), <-- causes unsafe CPOW usage warning style = win.getComputedStyle(div); <-- causes unsafe CPOW usage warning assert.equal( div.clientHeight, <-- causes unsafe CPOW usage warning 100, "PageMod contentStyle list works and is evaluated after contentStyleFile" ); assert.equal( div.offsetHeight, <-- causes unsafe CPOW usage warning 120, "PageMod contentStyleFile list works" ); assert.equal( style.width, <-- causes unsafe CPOW usage warning "320px", "PageMod add-on author/page author style sheet precedence works" ); assert.equal( style.maxWidth, <-- causes unsafe CPOW usage warning "480px", "PageMod add-on author/page author style sheet precedence with !important works" ); done(); } ... https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1138 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1139 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1142 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1153 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1160 onReady: function onReady(tab) { let browserWindow = getMostRecentBrowserWindow(); let win = getTabContentWindow(getActiveTab(browserWindow)); let div = win.document.querySelector("div"); <-- causes unsafe CPOW usage warning let style = win.getComputedStyle(div); <-- causes unsafe CPOW usage warning assert.equal( style.width, <-- causes unsafe CPOW usage warning "200px", "PageMod contentStyle is current before page-mod applies" ); let pageMod = loader.require("sdk/page-mod").PageMod({ include: "data:*", contentStyle: "div { width: 100px!important; }", attachTo: ["top", "existing"], onAttach: function(worker) { assert.equal( style.width, <-- causes unsafe CPOW usage warning "100px", "PageMod contentStyle worked" ); worker.once('detach', () => { assert.equal( style.width, <-- causes unsafe CPOW usage warning "200px", "PageMod contentStyle is removed after page-mod destroy" ); tab.close(done); }); pageMod.destroy(); } }); } ... https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1185 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1186 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1189 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1200 https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1213 onReady: function onReady(tab) { let browserWindow = getMostRecentBrowserWindow(); let win = getTabContentWindow(getActiveTab(browserWindow)); let div = win.document.querySelector("div"); <-- causes unsafe CPOW usage warning let style = win.getComputedStyle(div); <-- causes unsafe CPOW usage warning assert.equal( style.width, <-- causes unsafe CPOW usage warning "200px", "PageMod contentStyle is current before page-mod applies" ); let pageMod = loader.require("sdk/page-mod").PageMod({ include: "data:*", contentStyle: "div { width: 100px!important; }", attachTo: ["top", "existing"], onAttach: function(worker) { assert.equal( style.width, <-- causes unsafe CPOW usage warning "100px", "PageMod contentStyle worked" ); // Wait for a second page-mod to attach to be sure the unload // message has made it to the child let pageMod2 = PageMod({ include: "data:*", contentStyle: "div { width: 100px!important; }", attachTo: ["top", "existing"], onAttach: function(worker) { assert.equal( style.width, <-- causes unsafe CPOW usage warning "200px", "PageMod contentStyle is removed after page-mod destroy" ); pageMod2.destroy(); tab.close(done); } }); loader.unload(); } }); } ... https://hg.mozilla.org/projects/holly/file/50e197279ad5/addon-sdk/source/test/test-page-mod.js#l1437 exports.testEvents = function(assert, done) { let content = "<script>\n new " + function DocumentScope() { window.addEventListener("ContentScriptEvent", function () { window.document.body.setAttribute("receivedEvent", true); }, false); } + "\n</script>"; let url = "data:text/html;charset=utf-8," + encodeURIComponent(content); testPageMod(assert, done, url, [{ include: "data:*", contentScript: 'new ' + function WorkerScope() { let evt = document.createEvent("Event"); evt.initEvent("ContentScriptEvent", true, true); document.body.dispatchEvent(evt); } }], function(win, done) { assert.ok( win.document.body.getAttribute("receivedEvent"), <-- causes unsafe CPOW usage warning "Content script sent an event and document received it" ); done(); }, 100 ); };
(In reply to Mike Conley (:mconley) - Needinfo me! from comment #0) > Mined from test logs > > In addon-sdk/source/test/tabs/test-page-mod.js: > Sorry, that's addon-sdk/source/test/test-page-mod.js
Assignee: nobody → evold
Just Part 1, the devtools debugging related tests are more tricky, but I thought I'd put this up for now to get started.
Attachment #8615061 - Flags: review?(dtownsend)
Attachment #8615061 - Flags: review?(dtownsend) → review+
Commits pushed to master at https://github.com/mozilla/addon-sdk https://github.com/mozilla/addon-sdk/commit/c55af6ada95c4dbc80248e395f5f85d77b264cc1 Bug 1149158 Part 1: Removing some CPOW usage in test-page-mod.js https://github.com/mozilla/addon-sdk/commit/736dde2fe046086ab8a585f3441228bac1465687 Merge pull request #2006 from erikvold/1149158p1 Bug 1149158 Part 1: Removing some CPOW usage in test-page-mod.js r=mossop
tracking-e10s: m8+ → ---
Whiteboard: [unsafe-cpow-usage]
Hey Mossop - it looks like some fixes here got landed on June 4, according to comment 3... do you know if this takes care of them all, or if there were a few other patches in flight?
Flags: needinfo?(dtownsend)
I have no idea, let's look after an uplift.
Flags: needinfo?(dtownsend)
This is test only.
tracking-e10s: --- → +
luca checking if changes landed
Flags: needinfo?(lgreco)
The changes from Comment 3 has been landed, but this test file still uses cpows, e.g. (besides most of the ones pointed out in Comment 0, which are still there), there are more in the testConsole and in a page-mod test helpers that is used by a number of tests in this file: - https://dxr.mozilla.org/mozilla-central/source/addon-sdk/source/test/page-mod/helpers.js#49 - https://dxr.mozilla.org/mozilla-central/rev/56b3f2c6f53e72698fea6c25130efceef2a26548/addon-sdk/source/test/test-page-mod.js#1818 and so there are also tests in this files that are using cpows indirectly (e.g. the testExistingFrameOn etc.).
Flags: needinfo?(lgreco)
comment 8 explains where it is right now. not working on beyond landing what was already there. Luca landing what is there.
Assignee: evold → lgreco
Priority: P1 → P3
Whiteboard: [unsafe-cpow-usage] → [unsafe-cpow-usage] test
Whiteboard: [unsafe-cpow-usage] test → [unsafe-cpow-usage] test, triaged
Unassigning, this won't be getting fixed any more given bug 1371065.
Assignee: lgreco → nobody
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: