Commit Graph

277 Commits

Author SHA1 Message Date
Andrew Swan
58fbc451c8 Bug 1317590 AddonManager support for permissions r=rhelmer
MozReview-Commit-ID: 6I6BTb0TJR2
2016-11-16 08:53:56 -08:00
Kris Maglione
bab75b7f08 Add getUniqueId helper function to ExtensionUtils. (no bug) r=me
MozReview-Commit-ID: BXi3Yse5jFt
2016-11-10 21:44:05 -08:00
Sebastian Hengst
4247074d30 Backed out changeset 6790d8962ad9 to make ESlint happy. r=backout 2016-11-12 17:07:10 +01:00
Kris Maglione
1596e24307 Add getUniqueId helper function to ExtensionUtils. (no bug) r=me
MozReview-Commit-ID: BXi3Yse5jFt
2016-11-10 21:44:05 -08: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
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
4bd88237a3 Bug 1315575: Part 2 - Stop generating multiple sets of schema bindings for proxy contexts. r=aswan
MozReview-Commit-ID: 2VqYscQAAF6
2016-11-07 22:21:01 -08:00
Kris Maglione
89425f013c Bug 1315575: Part 1 - More cleanup. r=aswan
MozReview-Commit-ID: KdAplJGH9Hy
2016-11-06 17:28:16 -08:00
Matthew Wein
bb3fd3b5a2 Bug 1247435 - Fix context.incognito (this completes part of bug 1309610) r=kmag
MozReview-Commit-ID: IFW8SfNymbE
2016-11-04 14:37:09 +00:00
Kris Maglione
bec1b361f5 Bug 1312690: Lazily initialize extension APIs. r=aswan
MozReview-Commit-ID: 2ofzT6wPvus
2016-11-02 19:21:04 -07:00
Kris Maglione
6fd3e7cc09 Bug 1312690: Cleanup. r=aswan
MozReview-Commit-ID: IorfzVPKyIE
2016-10-30 19:54:23 -07:00
Matthew Wein
65938122a3 Bug 1252871 - Add support for runtime.onInstalled r=aswan
MozReview-Commit-ID: 3wDtv0g0BpO
2016-10-19 10:38:29 +01:00
Wes Kocher
d88274da9b Backed out 3 changesets (bug 1252871) for test_ext_all_apis.html bustage a=backout CLOSED TREE
Backed out changeset b3a08a040c8a (bug 1252871)
Backed out changeset c2a511511a72 (bug 1252871)
Backed out changeset 9c2c3780aa4c (bug 1252871)
2016-10-28 14:24:13 -07:00
Rob Wu
21eaf53406 Bug 1299411 - Move native messaging to child process r=kmag
Move `runtime.connectNative` and `runtime.sendNativeMessage` to
`addon_child`. Note: This does not change the behavior for launching the
native app, it is still launched from the main process.

Now ExtensionUtils's Port is also used for native messaging ports. Now
the behavior of `runtime.connect` and `runtime.connectNative` are
identical from the extension's perspective.
In particular:
- `disconnect()` does not throw when called again (bug 1287229).
- `onDisconnect` is called with error messages (tests will be added in
  the next commit).

MozReview-Commit-ID: AyU9amiLeoL
2016-09-24 13:25:56 +02:00
Rob Wu
cbf6c0d553 Bug 1299411 - Deduplicate context getter logic in ParentAPIManager r=aswan
MozReview-Commit-ID: E9MpHhal7WF
2016-09-24 13:10:39 +02:00
Matthew Wein
6a04843fa4 Bug 1252871 - Add support for runtime.onInstalled r=aswan
MozReview-Commit-ID: 3wDtv0g0BpO
2016-10-19 10:38:29 +01:00
Rob Wu
9ebbb4a33c Bug 1287007 - Fix "onclick" in contextMenus, to child. r=billm
Main thing: Making contextMenus implementation webext-oop compatible.

Preparation:

- Add getParentEvent to ChildAPIManager to allow use of remote events.
- Introduce `addon_parent_only` to "allowedContexts" to only generate a
  schema API in the main process.
- Do not fill in `null` for missing keys if the schema declares a key as
  `"optional": "omit-key-if-missing"`. This is needed for the second
  point in the next list.

Drive-by fixes:

- Ensure that the "onclick" handler is erased when a context closes.
- Do not clear the "onclick" handler in `contextMenus.update` if the
  onclick key has been omitted (parity with Chrome).
- Remove some unnecessary `Promise.resolve()`
- Add extensive set of tests that check the behavior of the contextMenus
  APIs with regards to the onclick attribute in various scenarios.

MozReview-Commit-ID: A5f3AUQzU8T
2016-09-12 18:26:03 -07: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
ee6c294ec5 Bug 1287007 - Set parent cloneScope to child cloneScope r=billm
This is only to help with migration. This change allows all APIs to
behave identical regardless of whether the API is proxied.

Change cloneScope to be a getter because cloneScope is
`this.contentWindow`, which may be nulled when the context navigates away
(but stays in the bfcache).

Any API that is not proxied must have an identical clone scope to make
sure that properties such as toJSON (in the native messaging
stringifier) and ArrayBuffer (in webRequest as requestBody) are visible
to the caller.

MozReview-Commit-ID: 9aT3SUBieHK
2016-09-11 03:10:21 -07:00
Rob Wu
c9845ed1a0 Bug 1287007 - Track message manager / browser swaps r=billm
Neither the message manager nor the XUL browser is guaranteed to be
constant during a ProxyContext's lifetime.

Add a new class to follow the `<browser>` belonging to the current
docshell and update the ProxyContext properties as needed.
NOTE: The `BrowserDocshellFollower` class assumes that docshells are
swapped using `newBrowser.swapDocShells(oldBrowser)`. If this
assumption turns out to be false, then the tracker will lose track of
the `<browser>`. See bugzil.la/1301837 for more details.

Also, renamed `messageManager` to `currentMessageManager` because the
`messageManager` property is overwritten by the `setContentWindow` hack
in WannabeChildAPIManager in ExtensionChild.jsm.

browser/components/extensions/test/browser/browser_ext_currentWindow.js
provides test coverage for this feature once the `test` API goes through
a ChildAPIManager instead of directly through a WannabeChildAPIManager.
Why? Because that test calls `test.onMessage.addListener` in the script
that is loaded in a popup page. Popups are loaded in two stages: First
the content is preloaded in a `<browser>`, and then when the popup is
shown a new `<browser>` is created and the docshells are swapped.
When the script runs while the popup script is being preloaded, the
`ParentAPIManager` receives the IPC message with the target set to the
`<browser>` used for preloading. When the API response is ready,
`target.messageManager.sendAsyncMessage` is called. Meanwhile the
docshells have been swapped, the message manager is gone and this fails.
With this patch, the message manager is correctly tracked and this test
passes.

MozReview-Commit-ID: C5Z0ZJRXKyw
2016-09-09 23:04:04 -07:00
Rob Wu
ea854c568f Bug 1287007 - Use frame script to initialize background/popup page r=billm
MozReview-Commit-ID: 8Di1nTnwpbU
2016-09-08 20:41:43 -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
b1b009afcb Bug 1287007 - Move background page API logic to child r=billm
MozReview-Commit-ID: iGROahhkhn
2016-09-05 22:34:44 -07:00
Rob Wu
85f4c6b8ea Bug 1287007 - Rename "context.type" to "context.viewType" r=billm
"viewType" is more easily searchable and not as ambiguous as "type".

MozReview-Commit-ID: 8sG4qagFCBu
2016-09-05 22:26:56 -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
cea9d2eac3 Bug 1287007 - Move ExtensionContext to separate file r=billm
This is just a mechanical change, literally nothing more than cutting
ExtensionContext from Extension.jsm, pasting it in ExtensionChild.jsm
and adding the minimal imoort boilerplate.

MozReview-Commit-ID: 5uVt1IOdEFU
2016-09-05 00:15:18 -07:00
Rob Wu
840f06c381 Bug 1287007 - Improve errors for non-existing remote APIs r=billm
Currently, if the remote implementation is missing, the next unhelpful
error message is logged to the console:
"TypeError: findPathInObject(...) is not a function" or
"TypeError: findPathInObject(...) is undefined", etc.

This commit makes the message more useful:
"WebExtension API tabs.create not found (it may be unimplemented by Firefox)"

MozReview-Commit-ID: FhPEYKSjnLm
2016-09-01 21:14:31 -07:00
Kris Maglione
d4f9daf879 Bug 1287209: Handle popup and options browser resizing using a frame script. r=aswan
MozReview-Commit-ID: DIfynklqrus
2016-10-20 15:27:51 -07:00
Phil Ringnalda
12b5bd3b6d Backed out 2 changesets (bug 1287209) for failures in browser_ext_pageAction_popup_resize.js
Backed out changeset 50dcca551b63 (bug 1287209)
Backed out changeset cc7503f09572 (bug 1287209)

MozReview-Commit-ID: A5q4SnWzgOa
2016-10-20 19:23:33 -07:00
Kris Maglione
967a70173c Bug 1287209: Handle popup and options browser resizing using a frame script. r=aswan
MozReview-Commit-ID: DIfynklqrus
2016-10-20 15:27:51 -07:00
Wes Kocher
8bf7d8ac8b Backed out 2 changesets (bug 1287209) for browser_ext_commands_execute_browser_action.js leaks a=backout
Backed out changeset a6787db4d131 (bug 1287209)
Backed out changeset 7ea8213113d7 (bug 1287209)
2016-10-20 14:37:12 -07:00
Kris Maglione
ddb12899fc Bug 1287209: Handle popup and options browser resizing using a frame script. r=aswan
MozReview-Commit-ID: DIfynklqrus
2016-10-20 09:57:13 -07:00
Sebastian Hengst
b8a5819c2d Backed out changeset 68806639c031 (bug 1287209) for failing browser-chrome test browser_ext_popup_corners.js. r=backout 2016-10-20 09:17:03 +02:00
Kris Maglione
c0448e9939 Bug 1287209: Handle popup and options browser resizing using a frame script. r=aswan
MozReview-Commit-ID: DIfynklqrus
2016-10-19 20:19:43 -07:00
Sebastian Hengst
faa4e03c25 Bug 1304829 - rename RELEASE_BUILD to RELEASE_OR_BETA: main part. r=ted,Mossop
MozReview-Commit-ID: 1lCt0xTMV5O
2016-10-08 11:14:49 +02:00
Kris Maglione
843c84b50c Bug 1289273: Resolve URLs passed to windows.create relative to the caller. r=aswan a=al
MozReview-Commit-ID: 3TUIK6EvO3q
2016-10-05 20:27:06 +01:00
Yoshi Huang
85db56b906 Bug 1237152 - rename clear-origin-data to clear-origin-attributes-data, r=smaug
find \( -name '*.cpp' -o -name '*.h' -o -name '*.js' -o -name '*.jsm' -o -name '*.idl' -o -name '*.html' \) \
-a -type f -exec sed -i 's/clear-origin-data/clear-origin-attributes-data/g' {} \;
2016-10-07 17:45:10 +08:00
Alexandre Poirot
27c0d33718 Bug 1290581 - Improve error message from Extension.jsm and Schemas.jsm's readJSON functions. r=rpl
MozReview-Commit-ID: 8O5OIk4IdYM
2016-10-03 09:38:52 -07:00
Kris Maglione
85bdbb6626 Bug 1306858: Fix locale discovery in packed, embedded WebExtensions. r=aswan
MozReview-Commit-ID: KKcaj9i2PwK
2016-10-01 19:09:24 +01: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
Kris Maglione
0e8fb15468 Bug 1306037: Support options_ui in embedded WebExtensions. r=aswan
MozReview-Commit-ID: KZVPz52qrTS
2016-09-28 23:11:35 +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
Carsten "Tomcat" Book
2dfe81885a merge mozilla-inbound to mozilla-central a=merge 2016-09-22 11:55:12 +02:00
Matthew Wein
c26b978847 Bug 1302898 - Rename 'restrictions' to 'allowedContexts' r=kmag
All tests pass locally.

MozReview-Commit-ID: 5dPPthlPT6i
2016-09-19 17:36:46 -07:00
Matthew Wein
fec69037f1 Bug 1302898 - Make the schema restrictions array non-nullable. r=kmag
MozReview-Commit-ID: Lk8TGsqC4WC
2016-09-14 17:02:06 -07:00
Kris Maglione
bad292d78c Bug 1304331: Support setting the Content-Type header from WebRequest observers. r=mao
MozReview-Commit-ID: 93joPUweJ2x
2016-09-21 14:17:24 +01: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
Rob Wu
9cfd0fcca8 Bug 1298979 - move tabs.sendMessage/connect to child process r=billm
- Use the frame's message manager to direct messages via the
  ProxyMessenger to the right tab instead of directly to the tab.
- Put the implementation in a separate file that is only loaded in
  child processes (in the future).
- Explicitly list all addon-process specific files in a new category
  instead of reusing the content one.

MozReview-Commit-ID: 8oIMx9ol7Tl
2016-08-28 20:07:46 -07:00