Closed Bug 2016161 Opened 8 months ago Closed 8 months ago

Fix browser_ext_tabs_content.js and browser_ext_windows_create_popup_cookieStoreId.js tests, to not rely on a deprecated pref

Categories

(Thunderbird :: Add-Ons: General, task)

task

Tracking

(Not tracked)

RESOLVED FIXED
149 Branch

People

(Reporter: robwu, Assigned: john)

References

Details

Attachments

(8 external files)

To get tests that broke by bug 2011234 to pass, bug 2016020 flipped a newly introduced preference in the affected unit tests.

That preference is temporary, and going to be removed in the 152 cycle (in bug 2015559), so the tests should be updated to not require the pref flip.

I left a comment with pointers in the patch at https://phabricator.services.mozilla.com/D282760#inline-1540690

No longer depends on: 2016020
See Also: → 2015559

Hey Rob, thanks for your feedback, we will follow your suggestion shortly. However, we have one remaining puzzle to solve, which I described in https://phabricator.services.mozilla.com/D282760#inline-1541035.

We keep investigating, but are open to any ideas you might have.

As observed in https://phabricator.services.mozilla.com/D282760#inline-1541035, our behavior
differs from Firefox when for loading about:blank. As pointed out by Rob Wu, we use the wrong
principal when opening about pages or moz-extension pages.

This patch fixes the principal used by the windows API to allow content scripts in
about:blank without using the preference which re-enabled the deprecated behavior.

Assignee: nobody → john
Status: NEW → ASSIGNED

After disallowing content script injections into moz-extension://* pages in Bug 2011234,
most of the tasks in browser_ext_tabs_content.js are obsolete since they test deprecated
behavior.

The last task in that test is testing to load content pages via WebExtension APIs into tabs,
and has nothing to do with content scripts. All other tasks are removed and the file is
renamed.

A new test for the deprecated behavior will be added in a follow-up (Part 5 of this stack).

While investigating our remaining content script tests in browser_ext_contentScripts.js
we learned that it is only testing tabs which have been created by Thunderbird itself via
window.openContentTab(). This is insufficient and needs to be extended to also test tabs
and popups which have been created by the WebExtension API.

This patch refactors the test to de-duplicate code and extend its testing capabilities to
WebExtension tabs and popups, while injecting content scripts into web-pages and also into
about:blank.

The triggering principal used by the tabs API is fixed in the same way as the first patch
in this stack is fixing it for the windows API, allowing the updated test to pass when
injecting into about:blank.

Extend the new test file added in the parent patch to also test WebExtension popups.

Attachment #9544912 - Attachment description: Bug 2016161 - Part 3: Extend content script tests in browser_ext_contentScripts.js. r=#thunderbird-reviewers → Bug 2016161 - Part 4: Extend content script tests in browser_ext_contentScripts.js. r=#thunderbird-reviewers

Test that injecting content scripts into moz-extension://* pages fails,
after it had been deprecated in bug 2011234.

The tests in browser_ext_contentScripts_mv3.js should test the same as the updated
Manifest V2 variant in browser_ext_contentScripts.js, but with the modularized approach
it is now much easier to to run all tests in the same file.

The tests for registering content scripts in the manifest remain and the file is renamed.

  • log the manifest version of each sub test
Target Milestone: --- → 149 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/2c536968336a
Part 1: Fix browser_ext_windows_create_popup_cookieStoreId.js by using the correct triggeringPrincipal. r=darktrojan,robwu
https://hg.mozilla.org/comm-central/rev/7791e966854e
Part 2: Remove content script tests from browser_ext_tabs_content.js. r=darktrojan
https://hg.mozilla.org/comm-central/rev/c65f2bd8c063
Part 3: Extend tests in browser_ext_content_pages.js. r=darktrojan
https://hg.mozilla.org/comm-central/rev/e933e3dc11fb
Part 4: Extend content script tests in browser_ext_contentScripts.js. r=darktrojan
https://hg.mozilla.org/comm-central/rev/de5d86b31ada
Part 5: Extend browser_ext_contentScripts.js to test deprecated behavior. r=darktrojan
https://hg.mozilla.org/comm-central/rev/9f298f73edb9
Part 6: De-duplicate MV3 tests from browser_ext_contentScripts_mv3.js into browser_ext_contentScripts.js. r=darktrojan
https://hg.mozilla.org/comm-central/rev/b4f823632b84
Part 7: Move Manifest V2 content script register tests into browser_ext_contentScripts_register.js. r=darktrojan
https://hg.mozilla.org/comm-central/rev/1785d4a7a06b
Part 8: Cleanup. r=darktrojan

Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: