Commit Graph

206 Commits

Author SHA1 Message Date
Kris Maglione
7553f01ab3 Bug 1348442: Part 2c - Refactor Script class into ES6 class. r=aswan
MozReview-Commit-ID: Dtci1mfQts0
2017-03-18 15:19:29 -07:00
Kris Maglione
d06b5048db Bug 1348442: Part 2b - Add getWinUtils helper. r=aswan
MozReview-Commit-ID: 9vvCbYovyoN
2017-03-18 15:16:16 -07:00
Kris Maglione
c97f45a8ff Bug 1348442: Part 2a - Asynchronously load and cache content script CSS. r=aswan
MozReview-Commit-ID: 1BzLNbdXMfU
2017-03-23 18:51:38 -07:00
Tomislav Jovanovic
d4b3c25736 Bug 1339559 - Identify script that resulted in non-structured-clonable data r=kmag
MozReview-Commit-ID: AURB4Qpwimh
2017-03-13 09:04:45 +01:00
Kris Maglione
c94ce68add Bug 1333990: Part 3e - Add tests for content script cache eviction. r=aswan,billm
MozReview-Commit-ID: 6SRI8xTuZk5
2017-03-11 20:17:36 -08:00
Kris Maglione
4c52b3f8db Bug 1333990: Part 3d - Split observe() method to fix complexity warnings. r=aswan
MozReview-Commit-ID: 5ACOf2X5Z7I
2017-03-10 23:33:06 -08:00
Kris Maglione
f13f0b4436 Bug 1333990: Part 3c - Evict cached content scripts after a timeout and on memory-pressure. r=aswan,billm
This change automatically evicts content scripts 5 minutes after their last
use, and flushes the entire cache whenever a memory-pressure event is
received.

In the case of memory-pressure events other than heap-minimize, we only evict
scripts that have been in the cache for longer than 3 seconds (which is a
fairly arbitrary number) in order to prevent pre-loads from being evicted and
then immediately re-loaded.

MozReview-Commit-ID: LCXkI9qVMxS
2017-03-10 20:11:18 -08:00
Kris Maglione
572c355699 Bug 1333990: Part 3b - Preload matching content scripts when opening document channels. r=aswan,billm
This uses the http-on-opening-request observer that's dispatched in the child
process to begin preloading matching content scripts as early in the load
cycle as possible. Ideally we would use the network predictor for this, but
most of its prediction work happens in the parent process, and there are no
simple ways for us to hook into it.

This currently does not do any pre-loading in the parent process, mainly
because there isn't a good way to distinguish top-level document loads that
are happening directly in the parent versus those that are being proxied from
the child.

MozReview-Commit-ID: dIQW68HtxZ
2017-03-10 21:01:52 -08:00
Kris Maglione
7f9c816bc2 Bug 1333990: Part 3a - Use async loading and in-memory caching for WebExtension content scripts. r=aswan
MozReview-Commit-ID: GcdKDbWcUtu
2017-03-16 18:45:22 -07:00
Kris Maglione
418e10ee90 Bug 1314361 - Part 4: Stop setting addonId origin attribute. r=billm 2016-11-04 18:22:45 -07:00
Kris Maglione
be885c3aa9 Bug 1314361 - Part 2: Stop using addonId origin attribute for permission checks. r=billm 2016-11-04 15:16:50 -07:00
Kris Maglione
4c12719b3a Bug 1258360: Implement onMessageExternal and onConnectExternal. r=mixedpuppy
MozReview-Commit-ID: 7NTrgyWpXbv
2017-02-11 13:28:18 -08:00
Florian Quèze
13cfe1d3f3 Bug 1329182 - remove trailing newURI null parameters in toolkit/, r=jaws. 2017-01-09 20:27:25 +01:00
Tom Schuster
dc5a9c790a Bug 1310026 - webext: Add cssOrigin option to insertCSS/removeCSS. r=kmag 2017-01-06 16:07:59 +01:00
Tomislav Jovanovic
b90358a078 Bug 1319070 - Match against the principal. r=kmag
MozReview-Commit-ID: BB6UfZ6qjKr
2016-11-23 18:46:10 +01:00
Kris Maglione
8758dd16e8 Bug 1318371: Flush jar caches by path rather than creating a nsIFile in the content process. r=billm
MozReview-Commit-ID: 4J88w5lxEsP
2016-11-17 20:00:30 -08:00
Phil Ringnalda
a174c917cb Merge m-c to m-i
MozReview-Commit-ID: GwBaSZdoAZK
2016-11-17 20:33:59 -08:00
Kris Maglione
c6d33fa5d9 Bug 1317101 - Part 6: Remove or refactor code that prevents extensions from running in the child process. r=aswan
MozReview-Commit-ID: 7v5eIBOKA2v
2016-11-12 17:09:19 -08:00
Wes Kocher
2876e6bba5 Backed out 15 changesets (bug 1317101) for e10s jsreftest failures a=backout CLOSED TREE
Backed out changeset 17757ba4c0e8 (bug 1317101)
Backed out changeset 61f8a4084bbd (bug 1317101)
Backed out changeset a8cdc81cdcce (bug 1317101)
Backed out changeset e06d269a5d4f (bug 1317101)
Backed out changeset 1e1bfb578dcd (bug 1317101)
Backed out changeset 0f8144296a9d (bug 1317101)
Backed out changeset b7892d3fb0ca (bug 1317101)
Backed out changeset 039d63d5fef7 (bug 1317101)
Backed out changeset ef7e061b37bf (bug 1317101)
Backed out changeset af7b81d7a5cc (bug 1317101)
Backed out changeset 225ad2535585 (bug 1317101)
Backed out changeset b0521588011d (bug 1317101)
Backed out changeset 07321664430a (bug 1317101)
Backed out changeset 47d283897283 (bug 1317101)
Backed out changeset ffc63be3557c (bug 1317101)
2016-11-16 16:44:30 -08:00
Kris Maglione
c6eb354cd3 Bug 1317101 - Part 6: Remove or refactor code that prevents extensions from running in the child process. r=aswan
MozReview-Commit-ID: 7v5eIBOKA2v
2016-11-12 17:09:19 -08:00
Luca Greco
6a52aa7f33 Bug 1309906 - part1: adapt webext-oop internals for devtools contexts and APIs. r=kmag
MozReview-Commit-ID: E0gxV271N31
2016-11-14 21:38:20 +01:00
Tomislav Jovanovic
e7e303ee0e bug 1310331 - implement matchAboutBlank for tabs.executeScript r=kmag
MozReview-Commit-ID: ApuakyrctzD
2016-11-03 11:41:21 +01:00
Kris Maglione
92059c8fa9 Bug 1316780: Part 1 - Proxy extension events between the parent and child process. r=aswan
MozReview-Commit-ID: 6820Fzoks8n
2016-11-10 18:39:49 -08:00
Kris Maglione
e80af36c5a Bug 1316396: Part 2 - Rename contexts to make it clearer how and where they're used. r=aswan
MozReview-Commit-ID: 25oSbulhCmX
2016-11-09 12:08:42 -08:00
Kris Maglione
d25b4ecf0f Bug 1316396: Part 1 - Reorganize parent, child, common, and test code into more appropriate modules. r=aswan
MozReview-Commit-ID: 5WMt69GoN3K
2016-11-10 12:35:22 -08:00
Kris Maglione
8efd30c89e Bug 1312690: Add some stupid microoptimizations. r=aswan
MozReview-Commit-ID: 4qoNuG2k0KS
2016-11-01 16:56:21 -07:00
Kris Maglione
feb1c37e6d Bug 1312690: Remove now-useless .matches() call from tryInject. r=aswan
MozReview-Commit-ID: 9EVWJFSe1tU
2016-11-01 16:53:55 -07:00
Kris Maglione
4125c57411 Bug 1312690: Create content script sandboxes in same zone as content window. r=aswan
MozReview-Commit-ID: K44jMuVfhz4
2016-10-31 12:46:39 -07:00
Kris Maglione
07d3973769 Bug 1312690: Load content scripts asynchronously when possible. r=aswan
MozReview-Commit-ID: BzpZA4stbCI
2016-11-02 13:57:19 -07:00
Kris Maglione
bec1b361f5 Bug 1312690: Lazily initialize extension APIs. r=aswan
MozReview-Commit-ID: 2ofzT6wPvus
2016-11-02 19:21:04 -07:00
Tomislav Jovanovic
aa0c1e2ea1 bug 1272890 - implement match_about_blank for content scripts r=kmag
MozReview-Commit-ID: 3iZLpUw5LF4
2016-10-12 05:48:04 +02:00
Sebastian Hengst
27a124a864 Backed out changeset 6a904e8a06a7 (bug 1272890) for timing out in test_ext_tab_teardown.html. r=backout 2016-10-26 19:01:38 +02:00
Tomislav Jovanovic
7d95c6bb3e bug 1272890 - implement match_about_blank for content scripts r=kmag
MozReview-Commit-ID: 3iZLpUw5LF4
2016-10-12 05:48:04 +02:00
Rob Wu
cc38019772 Bug 1287007 - Move part of browserAction and pageAction to child r=billm
And remove redundant `Promise.resolve()` because it is the default
for async functions.

setIcon is not supported on Android, so there was no need to change
mobile/android/components/extensions/ext-pageAction.js.

MozReview-Commit-ID: 94ebaJFxLAi
2016-09-11 04:18:35 -07:00
Rob Wu
549209e57b Bug 1287007 - Use child's Extension instead of the process' r=billm
MozReview-Commit-ID: 9o8tOuUbchn
2016-09-06 15:31:33 -07:00
Rob Wu
0b6a21b18a Bug 1287007 - Use IPC to share viewType, tabId and windowId r=billm
Accessing <browser> in ContentChild does not work when extensions run in
a separate process.

MozReview-Commit-ID: EK0aOYeGaZ5
2016-09-06 15:25:10 -07:00
Rob Wu
19ac7136a0 Bug 1287007 - Move extension context initialization to ExtensionContent r=billm
This is a simple move of ExtensionContext creation logic to
ExtensionChild.

Before the change, ExtensionContext was initialized as follows:

1. (ext-backgroundPage.js) Create background page
2. (Extension.jsm) document-element-inserted observed.
3. (Extension.jsm) new ExtensionContext + unload observer.

After this commit:

1. (ext-backgroundPage.js) Create background page
2. (ext-backgroundPage.js) emit extension-browser-inserted event
3. (Extension.jsm) Pass global to ExtensionContent + unload listener.
4. (ExtensionContent.jsm) document-element-inserted observed.
5. (ExtensionChild.jsm) new ExtensionContext

The next step is to use frame scripts and synchronize state.

MozReview-Commit-ID: K6mPdq7KQ2T
2016-09-05 23:50:11 -07:00
Rob Wu
0e978724ec Bug 1287007 - Introduce ChildAPIManager to addon code r=billm
This is the bare minimum to separate the generation of addon_parent and
addon_child APIs. Now it is possible to have methods with the same name
but different implementations in the parent and child.

Many APIs are not compatible with the proxied API implementation, so
they temporarily fall back to directly invoking the parent API, just as
before this commit.

MozReview-Commit-ID: fwuZUvD8tY
2016-09-05 18:57:38 -07:00
Rob Wu
24545e9765 Bug 1287007 - Derive context.principal from sandbox r=billm,kmag
`context.principal` should be equal to the principal of the sandbox, so
that if a new sandbox is created using `Cu.Sandbox(principal)`, that
objects can be shared between the new sandbox and `context.cloneScope`
(= `context.sandbox`) without issues.

Without this change, using `context.jsonStringify` on an object from a
content script would trigger the following error:

> Error: Permission denied to access property "toJSON"

This scenario is covered by the test
toolkit/components/extensions/test/mochitest/test_ext_storage_content.html
in the next commit.

MozReview-Commit-ID: E4Jt8TDwNAZ
2016-09-30 19:16:34 +02:00
Sebastian Hengst
72f51c6f0b Backed out changeset cc266f8bc70a (bug 1272890) for frequent failures in test_ext_contentscript_about_blank.html and a cascade of non-webextension tests. r=backout a=backout
MozReview-Commit-ID: 74wvhzI6fky
2016-10-22 22:56:18 +02:00
Tomislav Jovanovic
2d6c9a67a7 bug 1272890 - implement match_about_blank for content scripts r=kmag
MozReview-Commit-ID: 3iZLpUw5LF4
2016-10-12 05:48:04 +02:00
Andrew Swan
6593774129 Bug 1295324 r=kmag a=al
MozReview-Commit-ID: GN4Bc8RZQBn
2016-10-07 11:20:12 -07:00
Kris Maglione
b60b9cd3ac Bug 1306447: Remove b2g support code from WebExtensions. r=aswan
MozReview-Commit-ID: L3g01tpDSwH
2016-09-29 21:10:30 +01:00
Rob Wu
b60b96622e Bug 1302020 - Add filter to Messenger + fix code documentation r=billm
- Make all keys in `filter` mandatory.
- Add `optionalFilter` to Messenger to take over the role of the former
  `filter` parameter.
- Add documentation to Messenger to explain what it really does.
- Fix type comments. Many message message managers were declared as a
  sender, while they are at most a receiver (e.g. `Services.pppm`).

MozReview-Commit-ID: ILDnP2qDIK9
2016-09-11 22:38:40 -07:00
Ehsan Akhgari
513846c904 Bug 1297687 - Part 3: Ensure that the expanded principal of a sandbox has a sensible OriginAttributes; r=bholley
This patch allows specifying an OriginAttributes when creating a sandbox
using Components.utils.Sandbox() by specifying an originAttributes
member on the options dictionary.

If an OA is specified in this way, it is used for creating codebase
principals from the string arguments passed to the function.  Otherwise,
if one or more principals are passed in the array argument to Sandbox(),
the OA of the principal(s) is used to construct codebase principals from
the strings inside the array.  In this case, we check to make sure that
all of the passed principals have the same OA, otherwise we'll throw an
exception.

In case no explicit OA is specified and no principals are passed in the
array argument, we create the codebase principals using a default OA.
2016-09-22 13:27:51 -04:00
Philipp Kewisch
dc8e3f9b36 Bug 1298879 - Upgrade to ESLint 3.5.0 for faster linting. r=miker 2016-09-20 10:27:03 +01:00
Tomislav Jovanovic
1a9e69a168 bug 1288263 - tabs.detectLanguage() returns "und" for undetermined, r=kmag
MozReview-Commit-ID: 72ltWdufHiu
2016-09-10 23:05:02 +02:00
Rob Wu
91820391f9 Bug 1298979 - Add ProxyMessenger, change message managers and getSender r=billm
- Introduce a proxy for IPC messages to allow the following APIs
  to be run out-of-process (ProxyMessenger):

    * runtime.connect
    * runtime.sendMessage
    * tabs.connect
    * tabs.sendMessage
    * runtime.onConnect
    * runtime.onMessage

- Update getSender in ext-tabs, make it independent of the context
  (in particular do not throw an error when a message is received while
  the tab is gone), and move it from MessageChannel to ProxyMessenger to
  make sure that it works in webext-oop. MessageChannel lives in a child
  process, whereas the TabManager (used by getSender) requires data from
  the main process.

- Set the third parameter of `addMessageListener` to true in some places
  to make sure that messages get delivered even after unloading the
  context. This is needed for the next two points.

- Put the `messageManager` property in BaseContext, and let it be set by
  `setContentWindow` - runtime.sendMessage/connect and tabs.sendMessage/
  connect depends on this property, and using the frame message manager
  makes sense.

- Unconditionally use the frame message manager in
  runtime.sendMessage/connect instead of sometimes the cpmm.

MozReview-Commit-ID: 4QkPnlMOkjS
2016-08-25 17:08:08 -07:00
Rob Wu
f600b2cf99 Bug 1287010 - Use schema-generated extension, split ext-extension.js r=billm
- This was the last non-schema-generated API in content scripts.

MozReview-Commit-ID: FaIOCHoircf
2016-08-18 19:19:40 -07:00
Rob Wu
0167c8c6a2 Bug 1287010, 1286712 - Use schema-generated runtime API, split ext-runtime.js r=billm
- Use schema-generated runtime API for content scripts instead of
  untyped API.
- Move logic that cannot be run in the main process to a new file.

Together with the previous patch that migrated the i18n API, this
concludes the fix for bug 1286712.

MozReview-Commit-ID: A3yG0x1kjwx
2016-08-18 18:15:37 -07:00