Commit Graph

5182 Commits

Author SHA1 Message Date
Luca Greco
a61a2d97ac Bug 1770288 - Fix intermittent failure on unrelated unexpected console message in test_ext_extension_page_navigated.js. r=willdurand
The intermittent failure triggered by this test is due to use of the wrong type signature for the AddonTestUtils.checkMessages
`forbidden` option, which expects the regular expression to be set as the value of the console message property that should be
checked against the regular expression.

Differential Revision: https://phabricator.services.mozilla.com/D146935
2022-05-23 17:19:38 +00:00
Mathieu Leplatre
d4a89f2c4b Bug 1702759 - Remove bucket name preference r=robwu
This introduces a breaking change: the buckets cannot be changed via preferences anymore.

Before landing this patch, we should have a released a new version of the Remote Settings DevTools that is compatible with this new API.

Differential Revision: https://phabricator.services.mozilla.com/D145455
2022-05-23 16:24:57 +00:00
Luca Greco
07a8ac1f65 Bug 1739114 - Moved privileged WebExtensions permissions in their own JSONSchema type and added a new custom privileged keyword on each privileged manifest fields. r=robwu,mixedpuppy
This patch includes only the subset of D145687 changes related to the reworked JSONSchema data, plus some minor changes to Schemas.jsm to take the new
JSONSchema type ("PrivilegedPermissions") and the new custom JSONSchema keyword (the boolean "privileged" property used to identify manifest fields
only allowed in privileged extensions).

Besides the changes to the schema data, this patch is not expected to introduce any difference in behavior and so it could also land on its own
if needed (and the rest of the changes landed separately).

Differential Revision: https://phabricator.services.mozilla.com/D146800
2022-05-20 08:55:03 +00:00
Marian-Vasile Laza
460357b17b Backed out changeset d3577f741ef5 (bug 1739114) for causing xpcshell failures on test_ext_permissions.js. CLOSED TREE 2022-05-19 23:35:07 +03:00
Luca Greco
1915f507fa Bug 1768522 - ExtensionBaseContextChild instances should not be active after navigating it to a page running in another process under fission. r=robwu
This patch is making sure that `context.active` is going to be `false` when an extension page
has been moved into the bfcache because the `browser` element where it was loading into has been navigated
to a page that needs to run in a different process.

This also match the expected behavior for a same process navigation (e.g. an extension page being navigated
to another extension page) and the changes in this patch do also fix Bug 1499129 which was already happening
for same process navigations (and it does the same also for an extension page moved to the bfcache because
of a cross-process navigation case tracked by this bug).

The test case included in this patch cover both same-process and cross-process navigations under fission
and non fissions jobs.

Differential Revision: https://phabricator.services.mozilla.com/D145919
2022-05-19 18:51:35 +00:00
Luca Greco
7568f932a6 Bug 1739114 - Moved privileged WebExtensions permissions in their own JSONSchema type and added a new custom privileged keyword on each privileged manifest fields. r=robwu,mixedpuppy
This patch includes only the subset of D145687 changes related to the reworked JSONSchema data, plus some minor changes to Schemas.jsm to take the new
JSONSchema type ("PrivilegedPermissions") and the new custom JSONSchema keyword (the boolean "privileged" property used to identify manifest fields
only allowed in privileged extensions).

Besides the changes to the schema data, this patch is not expected to introduce any difference in behavior and so it could also land on its own
if needed (and the rest of the changes landed separately).

Differential Revision: https://phabricator.services.mozilla.com/D146800
2022-05-19 18:20:59 +00:00
Tom Schuster
aa9abf5dc5 Bug 1740263 - Continue to allow WASM by default in Webextensions v2. r=mixedpuppy,robwu
Differential Revision: https://phabricator.services.mozilla.com/D142953
2022-05-19 14:13:51 +00:00
Iulian Moraru
979c59be19 Backed out 6 changesets (bug 1740263) for causing bp-hybrid bustages on nsScriptSecurityManager. CLOSED TREE
Backed out changeset 2f5ec6ad0f81 (bug 1740263)
Backed out changeset a1e7766cdb94 (bug 1740263)
Backed out changeset 3978ccb95455 (bug 1740263)
Backed out changeset e34ba774b3f8 (bug 1740263)
Backed out changeset 8365b10be28e (bug 1740263)
Backed out changeset d923462c9cd0 (bug 1740263)
2022-05-19 03:28:08 +03:00
Tom Schuster
d5bd140683 Bug 1740263 - Continue to allow WASM by default in Webextensions v2. r=mixedpuppy,robwu
Differential Revision: https://phabricator.services.mozilla.com/D142953
2022-05-18 21:39:30 +00:00
William Durand
98d292d632 Bug 1769707 - Update in-tree docs to mention privileged extensions and link to xpi-manifest repo. r=rpl DONTBUILD
List of changes:

- renamed a section for clarity (WebExtensions Experiments -> Adding
  Experimental APIs in Privileged Extensions)
- fixed a few typos because I think we should consistently use the name
  WebExtensions (with a `s`) when it is followed by API(s) at least
- added a link to the xpi-manifest repo in a notice (main repo, not the
  `docs/` folder or a markdown file because that may change)
- Experimental APIs is referenced in the section that has been edited so
  made it clear what is an Experimental API vs Built-in (hopefully).
  Also kept the reference to "WebExtensions Experiment" (which seems to
  be an alias)

Differential Revision: https://phabricator.services.mozilla.com/D146537
2022-05-18 19:15:51 +00:00
Mark Banner
cc09541457 Bug 1769569 - Automatically replace Components.* with C* in sjs files. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D146451
2022-05-18 08:13:19 +00:00
Andrew McCreight
5cedd55c3f Bug 1514936, part 1 - Remove the outer argument to nsIFactory::createInstance. r=xpcom-reviewers,preferences-reviewers,nika,Gijs
This patch won't actually build, because a few bits of code are used
for both nsIFactory::createInstance and static components, and static
components are not fixed until the next patch.

The first place is nsLoadGroupConstructor, which uses an nsIFactory
macro to create a static component constructor. (This could be worked
around by expanding the macro to the state before this patch.)

The other issue is that nsAppShellConstructor is used in an nsIFactory
on OSX, but as a static component on all other platforms. This could
be worked around by wrapping nsAppShellConstructor in an adaptor that
passes in the extra null argument to nsAppShellConstructor.

Differential Revision: https://phabricator.services.mozilla.com/D146456
2022-05-17 20:24:19 +00:00
Sebastian Hengst
e8e4f38731 Backed out 5 changesets (bug 1769569) for causing devtools' browser/browser_page_redirection.js to fail. CLOSED TREE
Backed out changeset 66a42eb3a366 (bug 1769569)
Backed out changeset d3cc9629cd9a (bug 1769569)
Backed out changeset edcd3dade079 (bug 1769569)
Backed out changeset 29d8dd058b7a (bug 1769569)
Backed out changeset 1aed34fdf2d3 (bug 1769569)
2022-05-17 19:49:17 +02:00
Mark Banner
82aef582ff Bug 1769569 - Automatically replace Components.* with C* in sjs files. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D146451
2022-05-17 16:50:33 +00:00
Tooru Fujisawa
179ce888fb Bug 1765737 - Part 1: Pass an empty object instead of global this to Cu.cloneInto in toolkit/components/extensions/. r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D144783
2022-05-13 20:12:27 +00:00
Tooru Fujisawa
f1b0a10daf Bug 1765319 - Part 3: Use globalThis in deserialize. r=mixedpuppy
The deserialize parameter is used only for getting global object, and in the JSM
context, it's the shared global.  So directly passing globalThis works.

Differential Revision: https://phabricator.services.mozilla.com/D144133
2022-05-13 20:12:26 +00:00
Dana Keeler
85f142911f Bug 1768047 - stop using nsICryptoHMAC in services r=tjr
nsICryptoHMAC is redundant and does its computations on the main thread. JS
code using it should use WebCrypto instead.

Differential Revision: https://phabricator.services.mozilla.com/D145641
2022-05-12 22:24:29 +00:00
Luca Greco
fbb8929f7a Bug 1768482 - Fix TV intermittent failure on Glean.extensions.startupCacheLoadTime set to 0. r=mixedpuppy,chutten
The test failing intermittently on test-verify jobs seems to be only the one that covers the newly added
Glean timespan metric named "extensions.startupCacheLoadTime".

Given that it seems to be only failing in test-verify jobs, and with the Glean metric set to a numeric value as expected
just not always a non-zero value as the test expectes, I suspect it may be because the startupCache is technically
empty or only including a pretty small amount data and so it may be able to be loaded so fast that the resulting
value is 0 milliseconds.

I'm unable to reproduce the same locally even when running the test locally using --verify, and so this patch
is actually relaxing the failing assertion to only check that the Glean metric value is numeric and the
mirror scalar is set to the exact same value, and in addition to that the test is not reseting the FOG data
and assert that the Glean metric is initially undefined until we expect it to be collected and set to a numeric value.

Differential Revision: https://phabricator.services.mozilla.com/D145904
2022-05-12 16:07:29 +00:00
criss
a1f6426011 Backed out changeset 48ce51771f48 (bug 1768482) for causing failures on test_ext_startup_cache_telemetry.js. CLOSED TREE 2022-05-12 00:12:52 +03:00
Luca Greco
8d5ec9a343 Bug 1768482 - Fix TV intermittent failure on Glean.extensions.startupCacheLoadTime set to 0. r=mixedpuppy,chutten
The test failing intermittently on test-verify jobs seems to be only the one that covers the newly added
Glean timespan metric named "extensions.startupCacheLoadTime".

Given that it seems to be only failing in test-verify jobs, and with the Glean metric set to a numeric value as expected
just not always a non-zero value as the test expectes, I suspect it may be because the startupCache is technically
empty or only including a pretty small amount data and so it may be able to be loaded so fast that the resulting
value is 0 milliseconds.

I'm unable to reproduce the same locally even when running the test locally using --verify, and so this patch
is actually relaxing the failing assertion to only check that the Glean metric value is numeric and the
mirror scalar is set to the exact same value, and in addition to that the test is not reseting the FOG data
and assert that the Glean metric is initially undefined until we expect it to be collected and set to a numeric value.

Differential Revision: https://phabricator.services.mozilla.com/D145904
2022-05-11 19:32:57 +00:00
William Durand
3f3405e6cd Bug 1750765 - Add test cases to verify scripting.executeScript() with activeTab. r=robwu
Differential Revision: https://phabricator.services.mozilla.com/D145414
2022-05-11 17:48:44 +00:00
William Durand
07366b2302 Bug 1768839 - Use browser action API for MV3 action on Android. r=robwu,agi
I chose to write a minimal test case and defer more test coverage to Bug
1723763 since this bug already existed. The change in `ext-android.json`
is similar to what has been done in D113461.

Differential Revision: https://phabricator.services.mozilla.com/D146061
2022-05-11 17:48:43 +00:00
Mark Banner
dcdbe8e1be Bug 1766533 - Fix extension code for ESLint rule no-constant-binary-expression. r=webcompat-reviewers,twisniewski,robwu
Differential Revision: https://phabricator.services.mozilla.com/D145653
2022-05-10 20:04:03 +00:00
Luca Greco
672c351bf9 Bug 1768544 - Fix test_ext_webRequest_eventPage_StreamFilter.js permafailure due to pending test webRequest aborted after all tests have been completed. r=mixedpuppy
The failures are triggered by the pending request used by the initial four test cases, due to the pending request
being aborted (after all the tests in the test file have been executed and the test harness executes all the
registered cleanup functions) and its related promise rejection not being caught by the test itself.

Apparently the failures seems to be able to be triggered more often on windows builds, but I have been able to trigger it
on Linux using --verify even if way less often then on Windows (where I was able to trigger the failures consistently
by running the test file once and without --verify).

The attached patch prevents the failure by explicitly:
- handling the promise rejection (by catching the rejection, emit a log if the rejection is the expected one and
  trigger an explicit failure nearby where it is triggered otherwise, to make it easier to investigate other issues
  in the future if needed, by prevent the rejection to become silent and by triggering a failure easier to be
  correlated with what is actually triggering it)
- clearing the last pending request created right at the end of the test task that has created it (mainly to avoid
  keeping the request active if the related test is already exiting)

Differential Revision: https://phabricator.services.mozilla.com/D145958
2022-05-10 15:39:27 +00:00
William Durand
efd34b180a Bug 1760451 - Check permissions for content scripts registered with the scripting APIs. r=robwu
Depends on D145629

Differential Revision: https://phabricator.services.mozilla.com/D144811
2022-05-10 14:30:24 +00:00
William Durand
0b2f83c246 Bug 1766615 - Enable scripting APIs in MV2. r=rpl
Differential Revision: https://phabricator.services.mozilla.com/D145629
2022-05-10 14:30:24 +00:00
Yoshi Cheng-Hao Huang
47b1efb236 Bug 1768059 - Unload the extension first in test_ext_contentscript_importmap.js. r=robwu
[task 2022-05-09T17:23:01.721Z] 17:23:01     INFO -  "CONSOLE_MESSAGE: (error) [JavaScript Error: "[Exception... "Component returned failure code: 0x80520015 (NS_ERROR_FILE_ACCESS_DENIED) [nsIFile.remove]"  nsresult: "0x80520015 (NS_ERROR_FILE_ACCESS_DENIED)"  location: "JS frame :: resource://gre/modules/Extension.jsm :: cleanupGeneratedFile/< :: line 3066"  data: no]"]
[task 2022-05-09T17:23:01.722Z] 17:23:01     INFO -  cleanupGeneratedFile/<@resource://gre/modules/Extension.jsm:3066:14
[task 2022-05-09T17:23:01.722Z] 17:23:01     INFO -  _do_main@Z:\\task_1652115146\\build\\tests\\xpcshell\\head.js:240:6
[task 2022-05-09T17:23:01.722Z] 17:23:01     INFO -  _execute_test@Z:\\task_1652115146\\build\\tests\\xpcshell\\head.js:603:5

Exception is thrown from [1], which cleanupFile is the XPI from [2].
The XPI file is removed during Extension.shutdown [3]

So calling extension.unload() before calling contentPage.close().

m-c try pushes, with --rebuild 20: [4]
m-c with the patch, with --rebuild 20: [5]

[1]: https://searchfox.org/mozilla-central/rev/3175fbb2342bfcdd5dcffed21a4c5a29dae1c61c/toolkit/components/extensions/Extension.jsm#3066
[2]: https://searchfox.org/mozilla-central/rev/3175fbb2342bfcdd5dcffed21a4c5a29dae1c61c/toolkit/components/extensions/ExtensionTestCommon.jsm#682
[3]: https://searchfox.org/mozilla-central/rev/3175fbb2342bfcdd5dcffed21a4c5a29dae1c61c/toolkit/components/extensions/ExtensionTestCommon.jsm#222
[4]: https://treeherder.mozilla.org/jobs?repo=try&revision=fa3f89152368fd2a2d2031970b68fafa30ef0b6d
[5]: https://treeherder.mozilla.org/jobs?repo=try&revision=3549465995d026f11feb4eff4af0aaa7a103fa31

Differential Revision: https://phabricator.services.mozilla.com/D145912
2022-05-10 07:15:16 +00:00
Luca Greco
2fab75125b Bug 1759300 - Cancel suspend on idle if the extension EventPage has StreamFilter instances still active. r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D145257
2022-05-09 20:33:28 +00:00
Luca Greco
364b091e2d Bug 1767336 - Record extension startupCache time to load as a Glean metric mirrored into a telemetry scalar. r=chutten,mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D145419
2022-05-09 14:46:42 +00:00
Luca Greco
60ca8725ff Bug 1767336 - Record telemetry related to extension startupCache data size and read errors names. r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D145331
2022-05-09 14:46:41 +00:00
William Durand
ef0e2254e5 Bug 1754924 - Deprecate nonPersistentCookies option from the privacy.websites.cookieConfig API. r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D145249
2022-05-06 18:03:31 +00:00
Iulian Moraru
1978954b64 Backed out 2 changesets (bug 1766615, bug 1760451) for causing mochitest failures on test_ext_scripting_permissions.html. CLOSED TREE
Backed out changeset 4db3945f4fcb (bug 1760451)
Backed out changeset 74cf7a839ea5 (bug 1766615)
2022-05-06 17:43:46 +03:00
William Durand
cc96f71dfc Bug 1760451 - Check permissions for content scripts registered with the scripting APIs. r=robwu
Depends on D145629

Differential Revision: https://phabricator.services.mozilla.com/D144811
2022-05-06 11:31:46 +00:00
William Durand
404a3230c7 Bug 1766615 - Enable scripting APIs in MV2. r=rpl
Differential Revision: https://phabricator.services.mozilla.com/D145629
2022-05-06 11:31:46 +00:00
Edgar Chen
1add1596b3 Bug 1766860 - Revise the prefs for clipboard API; r=evilpie,nika
Differential Revision: https://phabricator.services.mozilla.com/D145005
2022-05-06 10:30:32 +00:00
Yoshi Cheng-Hao Huang
4598e7aefc Bug 1688879 - Part 9: mochitest, xpcshell-test and web-platform-test for import maps. r=jonco,yulia,robwu
mochitest and web-platform-test are verifying import maps are supported.

Moving the mochitest into its own folder
(dom/base/test/jsmodules/importmaps) as the prefs needs to be in [DEFAULT]
section in chrome.ini, see [1].

xpcshell-test is used to verify import maps are _NOT_ supported for web ext
content scripts.

[1]: https://searchfox.org/mozilla-central/rev/dd404f43c7198b1076fe5d7e05b1e6b1a03bdfeb/testing/mochitest/runtests.py#1725

Differential Revision: https://phabricator.services.mozilla.com/D142077
2022-05-05 21:19:04 +00:00
Butkovits Atila
b018b0e4da Backed out 11 changesets (bug 1688879) for causing build bustages. CLOSED TREE
Backed out changeset 350ddd17c7f5 (bug 1688879)
Backed out changeset 27984b95ed20 (bug 1688879)
Backed out changeset 6a5bb063965f (bug 1688879)
Backed out changeset d8edcfdb504b (bug 1688879)
Backed out changeset 77ab231310ec (bug 1688879)
Backed out changeset c2bce95a1aca (bug 1688879)
Backed out changeset f5862572ced8 (bug 1688879)
Backed out changeset 05e0a1bf32fc (bug 1688879)
Backed out changeset adeab05b7419 (bug 1688879)
Backed out changeset 0e60834e17e5 (bug 1688879)
Backed out changeset 877bb4c2ce66 (bug 1688879)
2022-05-05 19:52:05 +03:00
Yoshi Cheng-Hao Huang
ca6f976ef3 Bug 1688879 - Part 9: mochitest, xpcshell-test and web-platform-test for import maps. r=jonco,yulia,robwu
mochitest and web-platform-test are verifying import maps are supported.

xpcshell-test is used to verify import maps are _NOT_ supported for web ext
content scripts.

Differential Revision: https://phabricator.services.mozilla.com/D142077
2022-05-05 16:03:18 +00:00
Narcis Beleuzu
8fd1fceb75 Backed out 9 changesets (bug 1688879) for bustages on ImportMap.cpp
Backed out changeset 44e9abe72a5e (bug 1688879)
Backed out changeset 0503d2d2ae01 (bug 1688879)
Backed out changeset 2cf08a51b184 (bug 1688879)
Backed out changeset 6f0276c3ab0e (bug 1688879)
Backed out changeset f16b14d8f677 (bug 1688879)
Backed out changeset 03b772e02d07 (bug 1688879)
Backed out changeset 39ed48a5ecc2 (bug 1688879)
Backed out changeset d7b42d8312bb (bug 1688879)
Backed out changeset 5e695bf5dd0d (bug 1688879)
2022-05-05 03:41:31 +03:00
Yoshi Cheng-Hao Huang
6fabdb5d74 Bug 1688879 - Part 9: mochitest, xpcshell-test and web-platform-test for import maps. r=jonco,yulia,robwu
mochitest and web-platform-test are verifying import maps are supported.

xpcshell-test is used to verify import maps are _NOT_ supported for web ext
content scripts.

Differential Revision: https://phabricator.services.mozilla.com/D142077
2022-05-04 21:02:52 +00:00
Dão Gottwald
e4a09e1f3f Bug 1762903 - Implement Firefox View toolbar button. r=fluent-reviewers,Gijs
Differential Revision: https://phabricator.services.mozilla.com/D144735
2022-05-04 16:25:54 +00:00
Jan Varga
2eb1c71b23 Bug 1764696 - Adjust some tests for new pref; r=dom-storage-reviewers,jstutte
Differential Revision: https://phabricator.services.mozilla.com/D143689
2022-05-04 04:35:15 +00:00
Tooru Fujisawa
45ac4b3dfa Bug 1765167 - Part 10: Stop using Cu.import in toolkit/. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D144103
2022-05-03 06:32:32 +00:00
Tooru Fujisawa
ae327d0985 Bug 1765156 - Part 10: Use SpecialPowers.ChromeUtils.import in toolkit/components/extensions/. r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D144091
2022-05-03 06:32:28 +00:00
Cathy Lu
94c6c5c3e5 Bug 1601420 - Implement permissions.request/optional web extension permissions for geckoview r=geckoview-reviewers,agi,robwu
The general idea is that when extensions are installed at startup, they request permissions needed. Some examples of permissions might be access to downloads or bookmarks. This patch implements the ability to request permissions after install during runtime. A common optional permission is geolocation. The app won't request the user's location until needed.

GeckoView will provide a delegate to apps called onOptionalPrompt that provides the extension and the permissions the extension is requesting. They can then query the user to accept or reject the permission. The delegate works by listening to the browser API browser.permissions.request. Any browser API will be linked to a corresponding file and function such as ext-permissions.js::request() in this example. request() notifies observers of the topic webextension-optional-permission-prompt. ExtensionPromptObserver listens to that topic and dispatches an event GeckoView:WebExtension:OptionalPrompt. The geckoview web extension controller listens on that event and pass the extension and permissions to the skeleton delegate functions, that will get implemented by the app.

To verify this works, the test case WebExtensionTest.kt installs an extension through the package xpi. The package is created on build from moz.build to contain the extension's manifest.json and necessary scripts. Once the extension package is installed, we load the html script in the package that states when the page is clicked, trigger the browser API browser.permissions.request. The click is simulated with synthesizeTap. This request is then observed by listeners like mentioned in the previous paragraph. We verify in our skeleton delegate that the permissions provided match the ones requested.

Differential Revision: https://phabricator.services.mozilla.com/D143925
2022-05-02 19:45:39 +00:00
Peter Van der Beken
c1f8f93c43 Bug 1688585 - extensions::RequestWorkerRunnable::Init should propagate failure of dom::PromiseWorkerProxy::Create. r=rpl
Differential Revision: https://phabricator.services.mozilla.com/D145066
2022-05-02 07:36:53 +00:00
William Durand
32b231eadf Bug 1761550 - Remove tab after having unloaded the extensions. r=rpl
Initially, I thought the bug was related to a missing `extension.id` in
`ExtensionProcessScript.jsm` [1] but that isn't always reproducible.

There is possibly an issue there but I don't think it is the root cause
of the intermittent here (I would think that other OSes would be affected,
which isn't the case according to [2]).

@rpl and I investigated and we noticed that the mochitest error reported
didn't contain a meaningful error:

```
[object Object] - Should not throw any errors
```

Once we fixed the test framework output, we got:

```
FAIL {"operation":"remove","path":"C:\\Users\\William\\AppData\\Local\\Temp\\generated-extension-23.xpi","winLastError":5,"stack":"","fileName":"(unknown module)"} - Should not throw any errors
```

This is why this patch attempts to fix the intermittent by unloading the
extensions first and then removing the tab. As @rpl said:

> That may actually make sense, maybe removing the tab right before the
> unload prevented the extension to coordinate with the child process and
> make sure we flushed the cache, and that process may not have been yet
> fully destroyed.

[1]: https://searchfox.org/mozilla-central/rev/ecd91b104714a8b2584a4c03175be50ccb3a7c67/toolkit/components/extensions/ExtensionProcessScript.jsm#124
[2]: https://treeherder.mozilla.org/intermittent-failures/bugdetails?startday=2022-04-22&endday=2022-04-29&tree=trunk&bug=1761550

Differential Revision: https://phabricator.services.mozilla.com/D145104
2022-04-29 21:01:54 +00:00
Rob Wu
f0d0f855e8 Bug 1578405 - Use page's fetch/XHR/WebSocket in MV3 content scripts r=rpl
This patch ensures that fetch/XHR from MV3 content scripts have the
same capabilities as the web page, by relying on the fetch/XHR methods
inherit from the window prototype that use the page's principal, instead
of overwriting them with methods that use the expanded principal (MV2).

For completeness, although the WebSocket constructor does not require
origin permissions, I have also removed the similar special hack for
WebSocket, so that its behavior is also consistent with the page.

It is worth noting that currently, the page's CSP affects these methods,
instead of the content script's CSP (bug 1766813).

Besides the fix, this patch has test changes:

- test_ext_contentscript_csp.js was modified, to remove MV3 tests that
  rely on content.fetch and content.WebSocket, since the "content"
  global has been removed with the unification of these methods in
  content scripts. Two test expectations were changed to account for
  the CSP enforcement regression (bug 1766813).

- test_ext_contentscript_json_api.js was added because there is no
  specific coverage for the use of JSON APIs in content scripts, despite
  special handling in the code touched by this patch (from bug 1284020).
  I have also added a comment to the implementation to explain why the
  special handling was/is needed (this behavior remains unchanged).

- test_ext_secfetch.js was modified to test the fetch behavior of MV3.
  A previously-commented out test (fetch with CORS) was enabled since
  that behavior was resolved in MV3, and the (still failing) MV2 test
  results are annotated with the current failure (due to bug 1605197).

- test_ext_webSocket.js was modified to test the WebSocket behavior of
  MV3. Since this patch doesn't change the behavior for moz-extension:
  documents, the iframe tests are not affected by the fix. New
  content scripts-specific tests were introduced, along with test
  expectations for MV2 (unchanged) and MV3 (changed by this patch).

- test_ext_xhr_cors.js was introduced to test various scenarios with
  using XHR from MV3 content scripts. MV2 test coverage was not strictly
  required because it was mostly covered by test_ext_permission_xhr.js,
  but included for comparison. There is new test coverage for requests
  with CORS (which was/is still failing in MV2 - bug 1605197).

Differential Revision: https://phabricator.services.mozilla.com/D144931
2022-04-28 18:10:58 +00:00
Luca Greco
68251bded8 Bug 1759231 - Downloads panel should not open on extension created downloads created while not handling user input. r=mak,robwu
Differential Revision: https://phabricator.services.mozilla.com/D143268
2022-04-27 15:51:00 +00:00
Mark Banner
919c2481a2 Bug 1766238 - Stop using the target argument for ChromeUtils.import in ExtensionCommon.jsm. r=robwu
Differential Revision: https://phabricator.services.mozilla.com/D144557
2022-04-27 08:38:33 +00:00