Commit Graph

185 Commits

Author SHA1 Message Date
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
Rob Wu
4aa1ab5d36 Bug 1287010 - Use schema-generated i18n for all contexts r=billm
Use schema-generated i18n API for both content script and
addon contexts, instead of just the addon context.

MozReview-Commit-ID: AKDAFxNv6Zs
2016-08-20 15:49:20 -07:00
Rob Wu
fc61c013eb Bug 1287010 - Prepare for moving content script APIs to schemas r=billm
- By default, schema APIs are not injected in content scripts unless
  the JSON schema sets the "restrictions" attribute to `["content"]`.
- Added the "restrictions" attribute to the storage and test schemas.
  Other APIs will follow in subsequent commits and make use of the
  primitives introduced in this commit.

MozReview-Commit-ID: 1rNjQap0BiM
2016-08-18 17:46:57 -07:00
Rob Wu
488a453294 Bug 1287010 - Move Management logic to SchemaAPIManager r=billm
- Moved Management logic to ExtensionUtils (as SchemaAPIManager) so that
  the logic can be used by addon and content processes.
- Remove the `context.extension.hasPermission(api.permission)` check in
  `generateAPIs` because the only user (`registeredPrivilegedAPI`) was
  removed before in bug 1295082.
- Add new category "webextension-scripts-content", intended for
  registering the few scripts that must be loaded in a content process.

MozReview-Commit-ID: 81nhblV8YE6
2016-08-17 17:51:21 -07:00
Rob Wu
812e170fe8 Bug 1287010 - Make environment of Context explicit. r=billm
- Add `envType` to BaseContext.
 - Pass an explicit envType to all `registerSchemaAPI` invocations.
 - The factories passed to `registerSchemaAPI` will be split up later, so
   that content scripts (`content_child`) and addon pages can share
   common implementations.
 - The factories that implement the addon API will also be split up,
   to separate code running in the main process (`addon_parent`) from
   code running in a child process (`addon_child`).
 - Remove the use of a hardcoded list of `namespaces` from ProxyContext.
   Now `envType` is used to specify whether an API should be activated.

MozReview-Commit-ID: Jiff8HIwG92
2016-08-16 15:51:50 -07:00
Rob Wu
98a49ff299 Bug 1295082 - BaseContext.extensionId -> BaseContext.extension.id r=kmag
MozReview-Commit-ID: 2tFVUwjyJQu
2016-08-16 14:29:52 -07:00
Rob Wu
6efdd88867 Bug 1295082 - Put Extension in BaseContext r=kmag
ExtensionContext in Extension.jsm has |extension| as an instance member,
so use it instead of passing |extension| to registerSchemaAPI's
callback.

And to make sure that this pattern also works in content processes, move
the |extension| member to BaseContext.

MozReview-Commit-ID: BgsGGCPQxJR
2016-08-15 01:04:58 -07:00
Sebastian Hengst
c7a498ffbd Backed out changeset 0ce1cc39aa3d (bug 1295082) for timing out in test_ext_schemas_api_injection.js. r=backout 2016-08-18 16:47:09 +02:00
Sebastian Hengst
ff21875b1a Backed out changeset dc7b09331202 (bug 1295082) 2016-08-18 16:46:30 +02:00
Rob Wu
7c6379abff Bug 1295082 - BaseContext.extensionId -> BaseContext.extension.id r=kmag
MozReview-Commit-ID: 2tFVUwjyJQu
2016-08-16 14:29:52 -07:00
Rob Wu
6189daa99f Bug 1295082 - Put Extension in BaseContext r=kmag
ExtensionContext in Extension.jsm has |extension| as an instance member,
so use it instead of passing |extension| to registerSchemaAPI's
callback.

And to make sure that this pattern also works in content processes, move
the |extension| member to BaseContext.

MozReview-Commit-ID: BgsGGCPQxJR
2016-08-15 01:04:58 -07:00
Rob Wu
8472b153c7 Bug 1290157 - Always pass an array to tabs.executeScript on success r=kmag
MozReview-Commit-ID: Ctw8RUtfEZC
2016-08-09 00:28:47 -07:00
Wes Kocher
b9d5a32ad5 Merge inbound to central, a=merge 2016-08-12 13:44:29 -07:00
Kris Maglione
874e487954 Bug 1292369: Null out contentWindow properties when they point to a different inner window than the context belongs to. r=billm
MozReview-Commit-ID: LYQRxpU9vI8
2016-08-04 16:18:25 -07:00
Kris Maglione
d970e4c3c7 Bug 1293700: Make console object available to WebExtension internals. r=aswan
MozReview-Commit-ID: GyD4uo95gt6
2016-08-09 12:40:25 -07:00
Rob Wu
922403c487 Bug 1293126 - Remove Schemas.load from content's ExtensionContext r=kmag
MozReview-Commit-ID: JOToEC2Aokp
2016-08-07 17:59:58 -07:00
Rob Wu
c576617ccb Bug 1197451 - Add clipboardWrite permission r=billm
MozReview-Commit-ID: 6d1mQSVWRPe
2016-07-08 17:19:17 -07:00
Jared Wein
ebf1ccbe46 Bug 1291855 - Enable the no-else-return rule for eslint. r=Felipe,kmag,mossop
MozReview-Commit-ID: DYOmE6xwMJh
2016-08-03 18:54:59 -04:00
Kris Maglione
8c3da6958e Bug 1274871: Return a more useful error message for executeScript without matching window. r=aswan
MozReview-Commit-ID: 3AhuxY6gQPL
2016-07-26 17:55:58 -07:00
Rob Wu
3cbb2da8a5 Bug 1280482 - Add export helpers to content scripts. r=kmag
MozReview-Commit-ID: I4o3NXVphJX
2016-07-15 23:33:47 -07:00
Kris Maglione
4b566c58e2 Bug 1284020: Treat window.fetch/window.XMLHttpRequest the same as the global variants in content scripts. r=aswan
MozReview-Commit-ID: Cuz6CiNZdrd
2016-07-12 15:45:07 -07:00
Sebastian Hengst
b341fe6cc0 Backed out changeset 56d636b5d961 (bug 1284020) for failures in browser_dbg_sources-webext-contentscript.js. r=backout 2016-07-13 10:02:09 +02:00