Commit graph

244 commits

Author SHA1 Message Date
sakshaat
d781937a67 Bug 1517483 - Get rid of nsIScriptSecurityManager::IsSystemPrincipal r=bzbarsky
Replaced instances of callers in both C++ and JS files to query the state from the principal directly.

Differential Revision: https://phabricator.services.mozilla.com/D22532

--HG--
extra : moz-landing-system : lando
2019-03-24 20:36:25 +00:00
Kris Maglione
e930b89c34 Bug 1514594: Part 3 - Change ChromeUtils.import API.
***
Bug 1514594: Part 3a - Change ChromeUtils.import to return an exports object; not pollute global. r=mccr8

This changes the behavior of ChromeUtils.import() to return an exports object,
rather than a module global, in all cases except when `null` is passed as a
second argument, and changes the default behavior not to pollute the global
scope with the module's exports. Thus, the following code written for the old
model:

  ChromeUtils.import("resource://gre/modules/Services.jsm");

is approximately the same as the following, in the new model:

  var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");

Since the two behaviors are mutually incompatible, this patch will land with a
scripted rewrite to update all existing callers to use the new model rather
than the old.
***
Bug 1514594: Part 3b - Mass rewrite all JS code to use the new ChromeUtils.import API. rs=Gijs

This was done using the followng script:

https://bitbucket.org/kmaglione/m-c-rewrites/src/tip/processors/cu-import-exports.jsm
***
Bug 1514594: Part 3c - Update ESLint plugin for ChromeUtils.import API changes. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D16747
***
Bug 1514594: Part 3d - Remove/fix hundreds of duplicate imports from sync tests. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16748
***
Bug 1514594: Part 3e - Remove no-op ChromeUtils.import() calls. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16749
***
Bug 1514594: Part 3f.1 - Cleanup various test corner cases after mass rewrite. r=Gijs
***
Bug 1514594: Part 3f.2 - Cleanup various non-test corner cases after mass rewrite. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16750

--HG--
extra : rebase_source : 359574ee3064c90f33bf36c2ebe3159a24cc8895
extra : histedit_source : b93c8f42808b1599f9122d7842d2c0b3e656a594%2C64a3a4e3359dc889e2ab2b49461bab9e27fc10a7
2019-01-17 10:18:31 -08:00
Luca Greco
8bb370504e Bug 1464711 - Fix typo in ExtensionContent script.requiresCleanup getter. r=zombie
This patch fixes the typo in the requiresCleanup getter and adds an additional step
in the automated tests to verify that the scripts created by browser.tabs.removeCSS
are not being added to the content scripts that requires cleanup.

Differential Revision: https://phabricator.services.mozilla.com/D17345

--HG--
extra : moz-landing-system : lando
2019-01-24 17:18:22 +00:00
Kris Maglione
778252994f Bug 1513366: Part 5 - Migrate extension process script to a JSM. r=aswan
This simplifies things all around, and gets rid of one more unnecessary
component registration.

--HG--
rename : toolkit/components/extensions/extension-process-script.js => toolkit/components/extensions/ExtensionProcessScript.jsm
extra : rebase_source : 7ceb6ada0730f8241bbd5ddbd889a320da22b1b1
2018-12-12 17:58:19 -08:00
Luca Greco
2074f536c7 Bug 1509339 - Implement a UserScript API object and remove the userScripts.setScriptAPIs method. r=zombie,robwu
Depends on D12676

Differential Revision: https://phabricator.services.mozilla.com/D12678

--HG--
extra : moz-landing-system : lando
2018-11-30 16:10:58 +00:00
Luca Greco
3a91800a12 Bug 1509339 - Implement a userScript.onBeforeScript API event. r=zombie,robwu
Depends on D10061

Differential Revision: https://phabricator.services.mozilla.com/D12676

--HG--
extra : moz-landing-system : lando
2018-11-30 16:09:34 +00:00
Ehsan Akhgari
6f7b03e600 Bug 1504574 - Remove the XPCOM registration for nsDocumentEncoder; r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D10856
2018-11-05 23:16:04 -05:00
Rob Wu
92e0725cbb Bug 1491397 - Correctly forward falsey scriptMetadata in userScripts API r=rpl
This also adds new test coverage for the previously untested features:
- "file" in "js" param to userScripts.register works.
- "allFrames" set to true in userScripts.register works.
- scriptMetadata accepts primitive values, and in particular falsey
  values in particular (= bug 1491397 ).
 - scriptMetadata is the same object in all API script calls.

Differential Revision: https://phabricator.services.mozilla.com/D8582

--HG--
extra : moz-landing-system : lando
2018-10-15 18:05:08 +00:00
Andrew Swan
5abc00958c Bug 1498311 Handle content scripts properly on platforms without oop extensions r=zombie
--HG--
extra : rebase_source : 35e207d45979b5166833ad47c9e8b5892af15186
extra : source : 1cec1e9365524792ae0aeb11e53c33885f77f44e
2018-10-11 11:31:40 -07:00
shindli
620ed51b95 Backed out changeset 1cec1e936552 (bug 1498311) for ES linting failure 2018-10-12 00:10:59 +03:00
Andrew Swan
631def558c Bug 1498311 Handle content scripts properly on platforms without oop extensions r=zombie
--HG--
extra : rebase_source : 96f10978d9f19c2a8ec007a725643cd58395ccb6
2018-10-11 11:31:40 -07:00
Tomislav Jovanovic
7910836509 Bug 1496532 - Stop running content scripts on preallocated new tab page r=aswan
Differential Revision: https://phabricator.services.mozilla.com/D7976

--HG--
extra : moz-landing-system : lando
2018-10-08 19:40:20 +00:00
Luca Greco
202b39bc4b Bug 1491051 - Avoid awaiting a promise when all the content scripts are already precompiled and cached. r=robwu,mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D5794

--HG--
extra : moz-landing-system : lando
2018-09-15 18:42:23 +00:00
Luca Greco
87e37e32a0 Bug 1491024 - Rename userScripts manifest property to follow manifest property name conventions. r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D5777

--HG--
extra : source : f1cc448b5137c220962a35f1816f112f931de119
2018-09-13 15:33:12 +00:00
Cosmin Sabou
3061c72b4b Backed out changeset f1cc448b5137 (bug 1491024) for failures on test_ext_userScripts. CLOSED TREE 2018-09-13 22:11:41 +03:00
Luca Greco
44493dc39f Bug 1491024 - Rename userScripts manifest property to follow manifest property name conventions. r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D5777

--HG--
extra : moz-landing-system : lando
2018-09-13 15:33:12 +00:00
Luca Greco
0f496e199e Bug 1470466 - Use a different telemetry histogram key for the userScripts injection. r=janerik,mixedpuppy
This patch adds a new telemetry histogram for the userScripts injection time and adds an additional test case to verify that the expected telemetry histograms are being updated.

This phabricator revision depends on the following bugs and their related mozreview requests:

- [Bug 1437861](https://bugzilla.mozilla.org/1437861) Implement userScripts.register and execute userScripts js code in isolated sandboxes (https://reviewboard.mozilla.org/r/219856/)
- [Bug 1437864](https://bugzilla.mozilla.org/1437866) Implement userScripts API methods to allow an extension to inject custom APIs in the isolated userScripts sandboxes (https://reviewboard.mozilla.org/r/220630/)

Differential Revision: https://phabricator.services.mozilla.com/D3893

--HG--
extra : moz-landing-system : lando
2018-09-12 16:58:55 +00:00
Luca Greco
6056022481 Bug 1437864 - Implement userScripts API methods to allow an extension to inject custom APIs in the isolated userScripts sandboxes. r=zombie,mixedpuppy
MozReview-Commit-ID: 3GIFhnxMJVn

Depends on D4354

Differential Revision: https://phabricator.services.mozilla.com/D4355

--HG--
extra : moz-landing-system : lando
2018-09-12 16:46:24 +00:00
Luca Greco
8cba4aaaeb Bug 1437864 - Save a copy of the Error and Promise globals from extension context before they can be redefined. r=zombie,mixedpuppy
MozReview-Commit-ID: ALNJDiBwZL7

Differential Revision: https://phabricator.services.mozilla.com/D4354

--HG--
extra : moz-landing-system : lando
2018-09-12 16:46:06 +00:00
Luca Greco
c322d3c14f Bug 1437861 - Implement userScripts.register and execute userScripts js code in isolated sandboxes. r=zombie,mixedpuppy
This patch introduces the userScripts API namespace and the userScripts.register API method,
which allows an extension to register some javascript code to run on the matched webpages
into an isolated sandbox (whereas all the content scripts from the same extension run in
a per-window sandbox shared by all the extension content scripts).

Differential Revision: https://phabricator.services.mozilla.com/D4353

--HG--
extra : moz-landing-system : lando
2018-09-12 16:44:54 +00:00
Bogdan Tara
9c802a42f1 Backed out 4 changesets (bug 1437864, bug 1470466, bug 1437861) for Android xpcshell failures CLOSED TREE
Backed out changeset a6185abfc2f8 (bug 1470466)
Backed out changeset 82d60e34a977 (bug 1437864)
Backed out changeset 7634d9d14449 (bug 1437864)
Backed out changeset a92b6e069d7e (bug 1437861)
2018-09-12 00:57:00 +03:00
Luca Greco
0a4bdf7e7e Bug 1470466 - Use a different telemetry histogram key for the userScripts injection. r=janerik,mixedpuppy
This patch adds a new telemetry histogram for the userScripts injection time and adds an additional test case to verify that the expected telemetry histograms are being updated.

This phabricator revision depends on the following bugs and their related mozreview requests:

- [Bug 1437861](https://bugzilla.mozilla.org/1437861) Implement userScripts.register and execute userScripts js code in isolated sandboxes (https://reviewboard.mozilla.org/r/219856/)
- [Bug 1437864](https://bugzilla.mozilla.org/1437866) Implement userScripts API methods to allow an extension to inject custom APIs in the isolated userScripts sandboxes (https://reviewboard.mozilla.org/r/220630/)

Differential Revision: https://phabricator.services.mozilla.com/D3893

--HG--
extra : moz-landing-system : lando
2018-09-11 10:11:26 +00:00
Luca Greco
fd88da28d9 Bug 1437864 - Implement userScripts API methods to allow an extension to inject custom APIs in the isolated userScripts sandboxes. r=zombie,mixedpuppy
MozReview-Commit-ID: 3GIFhnxMJVn

Depends on D4354

Differential Revision: https://phabricator.services.mozilla.com/D4355

--HG--
extra : moz-landing-system : lando
2018-09-11 10:09:50 +00:00
Luca Greco
049cf75aa4 Bug 1437864 - Save a copy of the Error and Promise globals from extension context before they can be redefined. r=zombie,mixedpuppy
MozReview-Commit-ID: ALNJDiBwZL7

Differential Revision: https://phabricator.services.mozilla.com/D4354

--HG--
extra : moz-landing-system : lando
2018-09-11 10:08:03 +00:00
Luca Greco
aa17481856 Bug 1437861 - Implement userScripts.register and execute userScripts js code in isolated sandboxes. r=zombie,mixedpuppy
This patch introduces the userScripts API namespace and the userScripts.register API method,
which allows an extension to register some javascript code to run on the matched webpages
into an isolated sandbox (whereas all the content scripts from the same extension run in
a per-window sandbox shared by all the extension content scripts).

Differential Revision: https://phabricator.services.mozilla.com/D4353

--HG--
extra : moz-landing-system : lando
2018-09-11 10:06:30 +00:00
Luca Greco
bc6ccc75fd Bug 1489315 - Move ExtensionTelemetry into its own JSM module. r=mixedpuppy
This patch moves the ExtensionTelemetry helpers (added into ExtensionUtils.jsm by Bug 1483002)
into a new ExtensionTelemetry.jsm and makes the ExtensionTelemetry a lazy getter on every one
of the JSM and API modules that are going to use it, so that we don't have to load these helpers
until they are actually used and we can reduce their impact on the base content memory usage.

Differential Revision: https://phabricator.services.mozilla.com/D5266

--HG--
extra : moz-landing-system : lando
2018-09-07 16:27:44 +00:00
Luca Greco
88b7be38f8 Bug 1483002 - Added WEBEXT probes keyed by addon id. r=janerik,mixedpuppy
This patch contains a set of changes needed to add WEBEXT telemetry probes keyed by addon id.

The telemetry probes keyed by addon id has been added as separate telemetry histograms
named after the related generic WEBEXT probe with the additional "_BY_ADDONID" suffix.

A set of small helper methods have been defined in a new ExtensionTelemetry object, exported
by the ExtensionUtils.jsm.

Differential Revision: https://phabricator.services.mozilla.com/D4437

--HG--
extra : moz-landing-system : lando
2018-09-05 20:16:35 +00:00
Kris Maglione
b821d119a0 Bug 1486182: Part 2b - Update XPCOMUtils.enumerateCategoryEntries callers to use the category manager directly. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D4279

--HG--
extra : rebase_source : f57e09927871a23ed3c105325369e5c35ffd3d93
2018-08-24 17:05:41 -07:00
Kris Maglione
6adf9223ce Bug 1484496: Part 5b - Convert toolkit/ nsISimpleEnumerator users to use JS iteration. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D3730

--HG--
extra : rebase_source : 935f166ec2c6581ba6f3fffe912404e81c8dc3d6
extra : histedit_source : ba701801de5205dcce6cfdccabe7b26aa7c7859c
2018-08-18 19:27:50 -07:00
Kris Maglione
8a20a1620e Bug 1484373: Part 10 - Move some receiveMessage code to ExtensionContent.jsm. r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D3700

--HG--
extra : rebase_source : 5134540458628a004fa81e8978c2ba71aa5f6b6b
extra : histedit_source : 786919bc2ed8ebda1db004a13364a636a1f1f717
2018-08-17 22:20:45 -07:00
Kris Maglione
c6994239e3 Bug 1484373: Part 5 - Minimize the amount of content script options processing we do in child processes r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D3695

--HG--
extra : rebase_source : 5e99ca727b84d376744f6937bf96c60882038dec
extra : histedit_source : 2c3621e71dec052992a7d4f4ca33efd748f069ba
2018-08-17 20:02:52 -07:00
Kris Maglione
02ba563399 Bug 1463016: Part 5 - Add domWindow property to DocShellTreeItem and update callers to use it. r=nika
MozReview-Commit-ID: FRRAdxLHRtG

--HG--
extra : source : 0d69b4fb1ed43751cfcbc0b4f2fe3b6a49bc0494
extra : histedit_source : d0ce31513ffaae2fd7f01f6567a97b6d2d96b797%2Cfff837de7a00fa90809d2c3e755097180dfd56d8
2018-05-20 18:10:16 -07:00
Narcis Beleuzu
561ccb2ceb Backed out 2 changesets (bug 1463016, bug 1463291) for geckoview failures
Backed out changeset fcfb99baa0f0 (bug 1463291)
Backed out changeset 0d69b4fb1ed4 (bug 1463016)
2018-07-29 03:55:23 +03:00
Kris Maglione
636f1839e5 Bug 1463016: Part 5 - Add domWindow property to DocShellTreeItem and update callers to use it. r=nika
MozReview-Commit-ID: FRRAdxLHRtG

--HG--
extra : rebase_source : 36565ef5e74360aad14062005e5bdab2939e888b
2018-05-20 18:10:16 -07:00
Rob Wu
7713dfc025 Bug 1459750 - Remove unused principal variable r=rpl
Variable `principal` is only used when `this.isExtensionPage` is false.
So move this inside the branch where this condition is satisfied, and
remove the `else if (this.isExtensionPage) { ... }` block.

(This is a follow-up to bug 1214658, where the check was introduced that
 obsoleted the principal variable when `this.isExtensionPage` due to the
 use of `contentWindow` instead of `principal`).
(`principal = contentPrincipal` was already unused at its introduction
 in bug 1317697)

MozReview-Commit-ID: F7VX9vAH8MM

--HG--
extra : rebase_source : f2cbb1305d2ec98b471c0b43084e7b2c57ad05cd
2018-05-08 11:31:57 +02:00
Rob Wu
74c2f942c0 Bug 1459750 - Add JSDoc to ExtensionContent.Script constructor r=rpl
`contentScripts` in extension-process-script.js lazily instantiates
`ExtensionContent.Script` using the key as "matcher".

This "matcher" is usually a `WebExtensionContentScript`, except in
case of "Extension:Execute". Then the object is a
`WebExtensionContentScript`, extended with some expando properties.

MozReview-Commit-ID: 3hMAy9Ff1lr

--HG--
extra : rebase_source : fba3ee4672541ddbdb0bb6d51044f989c606e3cb
2018-05-08 01:59:48 +02:00
Kris Maglione
fcedebb912 Bug 1471102: Move more code out of ExtensionUtils.jsm. r=aswan
MozReview-Commit-ID: Fqlv5BRuuW8

--HG--
extra : rebase_source : 348f037abd9cecfa080183bc365e5f005eac1bd6
extra : amend_source : 05dbfd12f553fc3f2a93374402e34d271e26d767
2018-06-25 19:30:21 -07:00
Kris Maglione
7b7264f453 Bug 1464548: Part 3 - Update callers to use defineLazyGlobalGetters. r=mccr8
MozReview-Commit-ID: 9APGewiDDYB

--HG--
extra : rebase_source : 2931dd0eec0e4206414b698a9700fc20d922eb3a
2018-05-25 17:02:29 -07:00
Kris Maglione
5bbc8d23df Bug 1445026: Don't try to decode a binary hash blob as UTF-8. r=rpl
MozReview-Commit-ID: 91QNBYVQgQU

--HG--
extra : rebase_source : c7c1507e823bbbbeb9c6b9fe26139b20a9c1dda8
2018-03-12 14:18:43 -07:00
Kris Maglione
e427ba000e Bug 1420485: Follow-up: Remove unnecessary single-use stringToCryptoHash function. r=me
MozReview-Commit-ID: H1tPnsN0v2J

--HG--
extra : rebase_source : 616f0b88c1066ede9e45f6090115c4b45ca66db6
2018-03-11 22:25:56 -07:00
Bobby Holley
afa566952e Bug 1438974 - Fix WebExtensions to block layout for pending sheets. r=kmag
This fixes a failure in test_ext_contentScripts_register.js introduced
by async parsing.

MozReview-Commit-ID: JViFhpDX2k1
2018-02-28 10:43:13 -08:00
Florian Quèze
682b1ec3b2 Bug 1440284 - change this.EXPORTED_SYMBOLS back to var EXPORTED_SYMBOLS in JS modules, r=mccr8. 2018-02-23 20:50:01 +01:00
Ciure Andrei
855b730941 Merge mozilla-central to mozilla-inbound. a=merge CLOSED TREE 2018-02-23 00:03:06 +02:00
Boris Zbarsky
5e432144be Bug 1437921 part 2. Switch document_idle to use the documentReadyForIdle promise. r=kmag
MozReview-Commit-ID: 9cJ1cGuMzBJ
2018-02-22 16:55:40 -05:00
Luca Greco
181642ad79 Bug 1435100 - Ensure preloaded css and script caches are cleared when a WebExtension is shutting down. r=mixedpuppy
MozReview-Commit-ID: IHK7hBYVLMj

--HG--
extra : rebase_source : 9226ca3e5fcd13a7694ece3b44ede3f788c51070
2018-02-21 12:53:56 +01:00
Andrew McCreight
5dec0e0beb Bug 1432992, part 1 - Remove definitions of Ci, Cr, Cc, and Cu. r=florian
This patch was autogenerated by my decomponents.py

It covers almost every file with the extension js, jsm, html, py,
xhtml, or xul.

It removes blank lines after removed lines, when the removed lines are
preceded by either blank lines or the start of a new block. The "start
of a new block" is defined fairly hackily: either the line starts with
//, ends with */, ends with {, <![CDATA[, """ or '''. The first two
cover comments, the third one covers JS, the fourth covers JS embedded
in XUL, and the final two cover JS embedded in Python. This also
applies if the removed line was the first line of the file.

It covers the pattern matching cases like "var {classes: Cc,
interfaces: Ci, utils: Cu, results: Cr} = Components;". It'll remove
the entire thing if they are all either Ci, Cr, Cc or Cu, or it will
remove the appropriate ones and leave the residue behind. If there's
only one behind, then it will turn it into a normal, non-pattern
matching variable definition. (For instance, "const { classes: Cc,
Constructor: CC, interfaces: Ci, utils: Cu } = Components" becomes
"const CC = Components.Constructor".)

MozReview-Commit-ID: DeSHcClQ7cG

--HG--
extra : rebase_source : d9c41878036c1ef7766ef5e91a7005025bc1d72b
2018-02-06 09:36:57 -08:00
Luca Greco
84852d9e50 Bug 1420485 - Reduce memory usage related to the tabs.insertCSS cssCode urls. r=mixedpuppy
This patch introduces a cache of blob urls which are related to the cssCode
injected by the extensions using tabs.insertCSS, which aims to reduce the
amount of memory used by the extensions to store the cssCode injected
into the tabs and their subframes in the content child process.

The generated Blob URL are associated to the extension principal,
so that it is easier to identify in the about:memory reports
which is extension that is using the cached data.

MozReview-Commit-ID: ERhR5nmVMqY

--HG--
extra : rebase_source : af8e2c3312c84bec6715158bcc8af82b76c8a8a6
2017-11-24 19:17:33 +01:00
Kris Maglione
918ed6c474 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl

--HG--
extra : source : 12fc4dee861c812fd2bd032c63ef17af61800c70
extra : intermediate-source : 34c999fa006bffe8705cf50c54708aa21a962e62
extra : histedit_source : b2be2c5e5d226e6c347312456a6ae339c1e634b0
2018-01-29 15:20:18 -08:00
Cosmin Sabou
9a65a40178 Backed out 3 changesets (bug 1431533) for Android mochitest failures on testEventDispatcher on a CLOSED TREE
Backed out changeset a1eca62826a1 (bug 1431533)
Backed out changeset 34c999fa006b (bug 1431533)
Backed out changeset e2674287e57f (bug 1431533)
2018-01-30 07:17:48 +02:00
Kris Maglione
6476f95b13 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl

--HG--
extra : source : 12fc4dee861c812fd2bd032c63ef17af61800c70
2018-01-29 15:20:18 -08:00