Commit Graph

715 Commits

Author SHA1 Message Date
Thomas Wisniewski
c030c85638 Bug 289714 - Do not write <parsererror> nodes for invalid XML documents in XMLHttpRequests made by web content. r=billm, r=bz 2016-08-29 16:30:36 -04:00
Rob Wu
4d5d4452a8 Bug 1286124 - Part 2/2 - Do not deliver messages to the sender's frame r=kmag
MozReview-Commit-ID: 8xZPDIJyMEo
2016-07-13 21:33:56 -07:00
Rob Wu
719db77cf5 Bug 1286124 - Part 1/2 - Modify existing tests to not use same-frame messaging r=kmag
MozReview-Commit-ID: CtCcajKYAoR
2016-07-13 16:25:58 -07:00
Shubheksha Jalan
b8f5ca14cd Bug 1282978 - Accept and ignore the minimum_chrome_version manifest property. r=kmag
MozReview-Commit-ID: C9AlxpQDCnC
***
Bug 1282978 - Fixed tabs and spacing issues

MozReview-Commit-ID: 3SSpQpvZY2B
2016-08-30 00:40:33 +05:30
Rob Wu
4014c9af7b Bug 1287010 - s/Extension:RemoveListener/API:RemoveListener/ r=billm
This fix is not related to the referenced bug but came up during review.

MozReview-Commit-ID: IjrxWzkLIq1
2016-08-24 16:09:43 -07:00
Rob Wu
8eb396a770 Bug 1287010 - Add test for SchemaAPIManager's loadScript r=billm
And change `this.global.Object.create(null)` to
`Cu.createObjectIn(this.global)`. The tests pass either way, but
`Cu.createObjectIn` is more explicit.

MozReview-Commit-ID: LmL6rTru5zZ
2016-08-24 15:40:35 -07:00
Rob Wu
becfb68e93 Bug 1287010 - Refactor shouldInject / pathObj r=billm
Split the `shouldInject` method into separate methods:
- `shouldInject` to determine whether the API (or namespace)
  should be injected.
- `getImplementation` to return the actual implementation.

Introduced `SchemaAPIInterface` for documentation purposes, and
two concrete implementations `LocalAPIImplementation` and
`ProxyAPIImplementation` which provide the functionality to run a local
and remote implementation of the API for which the schema API is
generated, respectively. These classes store the necessary details for
the invocation, so the methods that were formerly in the `Context` in
Schemas.jsm no longer get the `pathObj`, `path` or `name` parameters.

And merge the `path` and `name` in the implementation of remote APIs
because there is no need for having them separate, as the callers and
callees often did redundant pre/post-processing on `data.path` because
of the way it was implemented.

MozReview-Commit-ID: isbG9i9pNP
2016-08-24 01:03:49 -07:00
Rob Wu
a430263825 Bug 1287010 - Use sandbox instead of JSM for global separation r=billm
MozReview-Commit-ID: GSqmh0xC2hW
2016-08-23 16:19:33 -07:00
Rob Wu
11db14b054 Bug 1287010 - Extension.jsm optimization: Use pathObj r=billm
The API implementation is already available upfront when the schema API
is generated, so `pathObj` has the implementation and can be used
instead of looking up the implementation over and over again with
`findPathInObject`.

MozReview-Commit-ID: FnCIyoaxgA4
2016-08-20 15:37:43 -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
42e49c6137 Bug 1287010 - Add pathObj parameter to Schemas r=billm
Local wrappers currently look up the API object over and over again
whenever a schema API is invoked. This can be optimized by re-using
the lookup result from a `shouldInject` invocation, which is passed
as the `pathObj` parameter to the wrapper methods.

This commit adds the necessary changes and tests to allow this to
happen, but does not modify the wrapper in Extension.jsm yet.

Also, this construction allows the `ChildAPIManager` to use a local
implementation if available and fall back to a remote implementation
otherwise.

MozReview-Commit-ID: C9gm7A9Zppb
2016-08-19 00:35:07 -07:00
Rob Wu
a68fdede92 Bug 1287010 - Use minimal global scope for ext-*.js scripts r=billm
Currently there is a tight coupling between registered APIs because they
share the same global scope, and the dependencies between the modules
that use these globals are not explicit. Consequently, it would be
possible for APIs to break when the registered APIs run in separate
processes, because then there are separate global scopes.
To mitigate this issue, this patch isolates the global namespaces of
API registrations in different environments, starting with the "chrome"
process. Content and addon processes will follow later.

A new JSM is introduced to avoid hidden dependencies between ext-*.js
and the script loader. ExtensionUtils.jsm would be a natural choice for
this shared utility method, but cannot be used because its local
`EventEmitter` implementation conflicts with the `EventEmitter` import
in ext-tabs.js.

So, this patch provides isolation of global variables declared through
`globals.XXX = ...`, but does not provide isolation for `Cu.import`-ed
logic. Ideally `Cu.import` should always use its second argument to
prevent inadvertent namespace pollution.

MozReview-Commit-ID: 1DTZaKOaeSE
2016-08-17 20:28:19 -07:00
Ryan VanderMeulen
65e0550627 Merge m-c to inbound. a=merge 2016-08-24 09:09:05 -04:00
Andrew Swan
ffbad6824f Bug 1297229 Run experiments APIs through schemas r=kmag
It is not directly related to the current bug but I added a test
for browser.extentionTypes while I was here.

MozReview-Commit-ID: 2XifKm3ZhrY
2016-08-22 16:50:32 -07:00
Rob Wu
52997a1c5a Bug 1297202 - Support cross-namespace submodule references in schemas r=aswan
MozReview-Commit-ID: 5JfOI3i3xbW
2016-08-22 15:11:47 -07:00
Hector Zhao
538abb2038 Bug 1295894 - Show localized strings for browserAction/pageAction title. r=kmag
MozReview-Commit-ID: 1SMd3cnUOH4
2016-08-17 14:39:33 +08:00
Kris Maglione
1e9bb5a560 Bug 1296934: Prevent background pages from showing up in global history. r=gabor
MozReview-Commit-ID: GRIJwCsfqVB
2016-08-21 12:43:50 -07:00
Ryan VanderMeulen
0c6be0762e Merge inbound to m-c. a=merge 2016-08-22 09:40:41 -04:00
Rob Wu
b36ca744fc Bug 1286712 - Remove unused ExtensionContext and GlobalManager globals r=billm
The presence of these globals interfere with the attempt to get ext-*.js
scripts to load in a content process because these globals are only
available in the main process.

MozReview-Commit-ID: 7syjAGcuUnu
2016-08-16 22:05:05 -07:00
Rob Wu
47e975c1fb Bug 1286712 - Validate runtime.sendMessage parameters r=billm
The main motive for this patch is to remove the use of the GlobalManager
global (which was used to see if an extension ID is valid, which was
specifically added in order to create thebrowser_ext_lastError.js test).
To preserve test coverage I implemented a full validation of the
runtime.sendMessage method.

Now the error for a non-existent extension is identical in both the
content script and background pages. Note that this also fixes a
minor privacy leak: Previously extensions could see whether another
extension is installed by sending a message to the specified extension
and using the different responses to see whether another extension is
installed.

MozReview-Commit-ID: 82R97Ei25Xr
2016-08-16 21:36:42 -07:00
Rob Wu
b37ee71c9a Bug 1293132 - Document and enforce contract for Schemas.inject and Schemas.normalize r=kmag
MozReview-Commit-ID: KgSrgHttwrI
2016-08-07 18:36:36 -07:00
Ryan VanderMeulen
2b652f9a60 Bug 1295082 - Fix merge bustage. a=bustage 2016-08-19 10:13:02 -04:00
Ryan VanderMeulen
576edfd1fd Merge inbound to m-c. a=merge 2016-08-19 09:52:53 -04:00
Rob Wu
8cbae07e24 Bug 1295082 - Minor fixups for experimental WebExtensions APIs r=kmag
- Remove unused registerAPI and registerPrivilegedAPI
- Generate the APIs just once.
- Fix typo in addon ID.

MozReview-Commit-ID: rdiiIxHMsm
2016-08-18 13:58:30 -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
Bob Silverberg
5ca0acc7d4 Bug 1283116 - Implement chrome.management.getSelf. r=kmag
MozReview-Commit-ID: Bj9ZyF1meED
2016-08-18 11:52:31 -04:00
Rob Wu
5d41ba7ac3 Bug 1295473 - Fix return type of {tabs,runtime}.sendMessage r=billm
The tabs.sendMessage and runtime.sendMessage implementations behave like
an async function: They take a callback parameter and return a promise.
So they should be handled by |callAsyncFunction|, not
|callFunctionNoReturn|.

This fixes the issue for background pages, but not for content scripts
because sendMessage is not implemented as a schema at the moment. This
will also be fixed once content script APIs are generated via Schemas.

MozReview-Commit-ID: 9p1hvOP0KSm
2016-08-15 23:53:24 -07:00
Wes Kocher
cc1de99fa7 Backed out changeset d0ba9997681a (bug 1283116) for android xpcshell failures a=backout 2016-08-17 16:00:47 -07:00
Bob Silverberg
d886594163 Bug 1283116 - Implement chrome.management.getSelf, r=kmag
MozReview-Commit-ID: Bj9ZyF1meED
2016-08-17 17:03:39 -04:00
Kris Maglione
6470e45452 Bug 1296888: Add "webextensions" tag to WebExtension tests. r=aswan
MozReview-Commit-ID: 3QYXtpdznrP
2016-08-20 15:41:31 -07:00
Kris Maglione
007774bc99 Bug 1259093: Follow-up: Fix another test race. r=me
MozReview-Commit-ID: 3DsTcQli8Ga
2016-08-20 14:00:37 -07:00
Wes Kocher
be3c2198cc Merge m-c to inbound a=merge 2016-08-19 18:39:52 -07:00
Kris Maglione
bfd63ddac8 Bug 1259093: Part 3 - Preload browserAction popups to prevent flicker during opening. r=Gijs r=jaws r=bwinton f=mattw
MozReview-Commit-ID: EpAKLV8VPTn
2016-08-19 12:29:11 -07:00
Sebastian Hengst
4efcf6be95 Backed out changeset d71c400313a2 (bug 1293132) for failing test_ext_schemas_api_injection.js on Android's Sets test. r=backout 2016-08-18 18:27:34 +02: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
Sebastian Hengst
0653534c29 Backed out changeset 7c4c98ac6b3f (bug 1295082) 2016-08-18 16:46:26 +02:00
Rob Wu
cfcfbf0fa2 Bug 1293132 - Document contract for Schemas.inject and Schemas.normalize r=kmag
MozReview-Commit-ID: KgSrgHttwrI
2016-08-07 18:36:36 -07:00
Rob Wu
d32dcb8f44 Bug 1295082 - Minor fixups for experimental WebExtensions APIs r=kmag
- Remove unused registerAPI and registerPrivilegedAPI
- Generate the APIs just once.
- Fix typo in addon ID.

MozReview-Commit-ID: rdiiIxHMsm
2016-08-16 14:31:28 -07: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
c37b6fdf35 Bug 1288901 - Create ExtensionContext at document-element-inserted r=billm
MozReview-Commit-ID: 9ZQWmNjoAXA
2016-08-07 19:10:01 -07:00
Rob Wu
d5bc9c78b6 Bug 1288901 - Destroy ExtensionContext at inner window destruction instead of unload r=billm
MozReview-Commit-ID: 4JI7PpAj9xd
2016-08-07 19:09:56 -07:00
Rob Wu
5dc40a2716 Bug 1288901 - Hide inactive extension views from getViews r=billm
When we close the ExtensionContext at inner-window-destroyed instead of
unload, the browser_ext_getViews.js test fails due to the extension view
appearing again in getViews() immediately after "closing" the extension
button popup. With this change that test passes again.

MozReview-Commit-ID: A4gn66sFZa9
2016-08-08 18:34:24 -07:00