Commit graph

173 commits

Author SHA1 Message Date
Luca Greco
c7c1214f36 Bug 1252215 - [webext] Add Embedded Extensions helper to LegacyExtensionsUtils. r=aswan,kmag
This patch introduces helper for the embedding of a webextension (and new related tests).

The new exported helpers are going to be integrated in the XPIProvider
to provide the Embedded WebExtension to the Legacy Extensions which
have enabled it in their install.rdf

MozReview-Commit-ID: 7M1DRkXjGat

--HG--
extra : rebase_source : 3226a83652b97601d9d4d34693761cfc720735a0
2016-08-29 15:56:02 +02:00
Luca Greco
9226a7b2f4 Bug 1252215 - [webext] LegacyExtensionsUtils JSM module and LegacyExtensionContext helper. r=aswan,kmag
- this new module contains helpers to be able to receive connections
  originated from a webextension context from a legacy extension context
  (implemented by the `LegacyExtensionContext` class exported from
  this new jsm module)

- two new test files (an xpcshell-test and a mochitest-browser) ensures that the LegacyExtensionContext can receive a Port
  object and exchange messages with a background page and a content script (the content script test
  is in a different test file because it doesn't currently work on android, because it needs
  the browser.tabs API and the TabManager internal helper)

MozReview-Commit-ID: DS1NTXk0fB6

--HG--
extra : rebase_source : 462d6a461167e317297d204e72c2f6773bc5c770
2016-08-24 18:31:36 +02:00
Kris Maglione
7fd9caf08b Bug 1298939: Don't initialize APIs that the extension does not have permissions for. r=rpl
MozReview-Commit-ID: Y0MTBL1z2O

--HG--
extra : rebase_source : f68463dca5dfffd19aa833402ac7599a15f92843
2016-09-01 13:04:54 -07:00
Kris Maglione
3e51cc7423 Bug 1299256: Fix performance issues when stripping comments from large locale files. r=rpl
MozReview-Commit-ID: H7IfBnQ4KnO

--HG--
extra : rebase_source : 1e3670e0817ab9764cdca5cecd203207c41f2987
2016-08-30 12:24:23 -07:00
Rob Wu
e080d5603d 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

--HG--
extra : rebase_source : 22cdc3ab3d14c6381f9f540739d6750281ae8c71
2016-08-24 01:03:49 -07:00
Rob Wu
2e1c4a437c 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

--HG--
extra : rebase_source : 440b25fcfb4a0438b1ff8680ad770930e7427de7
2016-08-20 15:37:43 -07:00
Rob Wu
72ac7d1f12 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

--HG--
extra : rebase_source : 7bab2249a7462a581e493f7aa937df45cb895107
2016-08-18 19:19:40 -07:00
Rob Wu
8053e5a9c0 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

--HG--
extra : rebase_source : bf2c7fb70a38fbf13cdfd4337cb3cb6fef7e67e8
2016-08-18 17:46:57 -07:00
Rob Wu
b21d936ca3 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

--HG--
extra : rebase_source : d2eee0298ad5038225ea56c2e752532af0bc6fb7
2016-08-17 17:51:21 -07:00
Rob Wu
be3652cd57 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

--HG--
extra : rebase_source : 946a3c0009a4e3223c2d10044b3099a94c845394
2016-08-16 15:51:50 -07:00
Rob Wu
1067b066d5 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

--HG--
extra : rebase_source : e2ab1e40de72fdea23acc9a68f3cf7d77e3da66f
2016-08-19 00:35:07 -07:00
Rob Wu
459ac122eb 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

--HG--
extra : rebase_source : 1376a1325fd9bf186e09e1dbe83467f3ad94516f
2016-08-17 20:28:19 -07:00
Andrew Swan
30f2e473c0 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

--HG--
extra : rebase_source : 855e44ebf7d595211de46a0ecbfedca107430662
2016-08-22 16:50:32 -07:00
Hector Zhao
ff7bc87130 Bug 1295894 - Show localized strings for browserAction/pageAction title. r=kmag
MozReview-Commit-ID: 1SMd3cnUOH4

--HG--
extra : rebase_source : 4c746fe866222e9d05177ba9b1d9210e15e1eac2
2016-08-17 14:39:33 +08:00
Rob Wu
36648bb360 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

--HG--
extra : rebase_source : d614424d50bbb2a5dea6c23e4dae1586b9efe4fb
2016-08-16 22:05:05 -07:00
Rob Wu
d8772c2374 Bug 1293132 - Document and enforce contract for Schemas.inject and Schemas.normalize r=kmag
MozReview-Commit-ID: KgSrgHttwrI

--HG--
extra : rebase_source : ab59db38073cb09ccfb8c38e76191bdc9d0cecc6
2016-08-07 18:36:36 -07:00
Rob Wu
2cc8f66f57 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

--HG--
extra : rebase_source : aede9c63e0f19d5b4c97022c0254b07603277aef
2016-08-18 13:58:30 -07:00
Rob Wu
bacc209644 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

--HG--
extra : rebase_source : 7aa9fb7a53e057e8d3d8c477bd6821f8344c571a
2016-08-15 01:04:58 -07:00
Sebastian Hengst
274c9cf54e 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
2164cd95c8 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
ba87856051 Backed out changeset 7c4c98ac6b3f (bug 1295082) 2016-08-18 16:46:26 +02:00
Rob Wu
e33e39b554 Bug 1293132 - Document contract for Schemas.inject and Schemas.normalize r=kmag
MozReview-Commit-ID: KgSrgHttwrI

--HG--
extra : rebase_source : 1cf288a7d0ce1c5d9dc7276b4f1710d0acb4187b
2016-08-07 18:36:36 -07:00
Rob Wu
a3c3c29726 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

--HG--
extra : rebase_source : 080d9b6de6fc2f256d953b5266a2c36ee9e56205
2016-08-16 14:31:28 -07:00
Rob Wu
dfc11d6f00 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

--HG--
extra : rebase_source : 9a85d95f0c147198938b86c57127f6e7403fd53c
2016-08-15 01:04:58 -07:00
Rob Wu
8a0b0a5460 Bug 1288901 - Create ExtensionContext at document-element-inserted r=billm
MozReview-Commit-ID: 9ZQWmNjoAXA

--HG--
extra : rebase_source : d62d5169df1549d576e71bbc9ad51ecf0b4add9b
2016-08-07 19:10:01 -07:00
Rob Wu
6cea2d2df8 Bug 1288901 - Destroy ExtensionContext at inner window destruction instead of unload r=billm
MozReview-Commit-ID: 4JI7PpAj9xd

--HG--
extra : rebase_source : 7b4a4f1e18dd52bf7c2f430d31ebe2b5f1928fab
2016-08-07 19:09:56 -07:00
Luca Greco
aa6d7d1c94 Bug 1290901 - [webext] Allow APIs implementation to return null when the API should not be injected in a context. r=aswan
needed to be able to return null when the registered schema API should not be available
based on the context type instead of WebExtensions permissions.

MozReview-Commit-ID: G8w8ZYzmA7S

--HG--
extra : rebase_source : 7cacd2d5b5c0e1ef354e2cef19c7d809cc632470
2016-08-02 04:00:06 +02:00
Luca Greco
d59eaef91b Bug 1290901 - [webext] Handle nested namespaced API schema. r=aswan
MozReview-Commit-ID: H26E8ZwLrqJ

--HG--
extra : rebase_source : d3eaba631b4f3aca55e0edb037776c13a319934d
2016-08-15 15:34:43 +02:00
Kris Maglione
026f92fc96 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

--HG--
extra : rebase_source : 88aa9e5eb14d22696126c26f960edbc40e923b89
extra : histedit_source : 01ff56be73b884fe73f4543b875acf37a1469b3d
2016-08-04 16:18:25 -07:00
Kris Maglione
d16036cec9 Bug 1293700: Make console object available to WebExtension internals. r=aswan
MozReview-Commit-ID: GyD4uo95gt6

--HG--
extra : rebase_source : a1bb70bbc186c76d5c0437530662b0754516ea7b
extra : histedit_source : d8bf619ce3d39987b2850223ccb3f28a82cbc532
2016-08-09 12:40:25 -07:00
Andrew Swan
b904b2d437 Bug 1286908 Remove id allocation from SpecialPowers loadExtension() r=kmag
Prior to this change, SpecialPowers used the extension id to identiy
extension instances in inter-process messaging.  This required that
an id be allocated from the content process side when loadExtension()
was called, but that made it impossible to test code that exercises the
code path in the AddonManager that allocates ids for extensions that do
not include an id in the manifest (it also made the loadExtension() api
clunky).

With this change, SpecialPowers allocates an internal identifier for
messaging, but this identifier is separate from extension ids.
Confusingly, we still store the actual extension id in an id property
on the object returned by loadExtension(), but there are enough tests
that reference this that it would be unnecessarily disruptive to get
rid of it so it stays for now...

MozReview-Commit-ID: G6xk1mBJJL8

--HG--
extra : rebase_source : a0891e5ba308972c35813f55274badf9edde62f7
extra : source : e8818ef3c28489e196d1db92cabf224861b693c9
2016-08-02 16:04:37 -07:00
Kris Maglione
947c1cf7ba Bug 1289527: Hide browserAction and pageAction namespaces when relevant manifest entries are missing. r=aswan
MozReview-Commit-ID: 2gx0pLkHaVJ

--HG--
extra : rebase_source : 94ab5fbc632aedee4dc8261145bc8832ae31f53d
2016-08-06 14:43:58 -07:00
Andrew Swan
fa3c0fac00 Bug 1213990 Clear storage when webextension is uninstalled r=kmag
MozReview-Commit-ID: BeMOxOCSeru

--HG--
extra : rebase_source : 3eb7fc4e61fe1ce698e22e25bd05fc779a6cf7a8
2016-08-01 16:30:18 -07:00
Andrew Swan
d7af10177b Bug 1213990 Convert getExtensionUUID to UUIDMap r=kmag
MozReview-Commit-ID: 9VVNa0pjx8g

--HG--
extra : rebase_source : d62e8289c127afe762a6af71fecb4e15c08272ca
2016-08-07 09:53:36 -07:00
Andrew Swan
956647e2c9 Bug 1213990 Do immediate uninstall for test webextensions r=kmag
MozReview-Commit-ID: 9vcAfPhRYFi

--HG--
extra : rebase_source : c10b7e927eb0d0e12f70d9e06f77d1b56fa405fc
2016-07-22 10:16:55 -07:00
Kris Maglione
73b1b5f221 Bug 1263011: Part 2 - Implement WebExtensions Experiments prototype. r=aswan
MozReview-Commit-ID: 4KO4cCLRsLf

--HG--
extra : rebase_source : 40e5ec808e557e845a771bb21e8863a8edcd4faf
2016-08-05 14:20:54 -07:00
Kris Maglione
b022382989 Bug 1263011: Part 1 - Refactor Extension and ExtensionData to use ES6 classes. r=aswan
MozReview-Commit-ID: f5NqRuPLU7

--HG--
extra : rebase_source : 209033bc3f6cf4b9aafb8530f7681584ca046601
2016-06-17 16:02:16 +01:00
Kris Maglione
0dba25a0da Bug 1288979: Always convert badge background color to a ColorTuple. r=aswan
MozReview-Commit-ID: CWmaa9wwQLD

--HG--
extra : rebase_source : aa8eaa19bad2b825c818abd29172f75fa84368dd
2016-08-04 14:50:52 -07:00
Jared Wein
871ed4e3ba Bug 1291855 - Enable the no-else-return rule for eslint. r=Felipe,kmag,mossop
MozReview-Commit-ID: DYOmE6xwMJh

--HG--
extra : rebase_source : bc81b68ea5599fd1815dc34dac7106eef7044483
2016-08-03 18:54:59 -04:00
Wes Kocher
6362b05a21 Backed out 3 changesets (bug 1213990) for problems in browser_ext_pageAction_context.js a=bustage CLOSED TREE
Backed out changeset c9b70a1998fc (bug 1213990)
Backed out changeset ffc2455a9135 (bug 1213990)
Backed out changeset 3223d0970b9a (bug 1213990)
2016-08-03 13:49:50 -07:00
Alexandre Lissy
0af5b943b6 Bug 1284674 - Remove NUWA r=cyu
MozReview-Commit-ID: GyMRNzOBKw6

--HG--
extra : rebase_source : 293af1cd55f2035ce6a99f4ebf144059c32a2b8f
2016-08-02 14:54:00 +02:00
Andrew Swan
0fbd21626b Bug 1213990 Clear storage when webextension is uninstalled r=kmag
MozReview-Commit-ID: BeMOxOCSeru

--HG--
extra : rebase_source : 24a4758a83b1792f8e52e426191abd0e229a4c0b
2016-08-01 16:30:18 -07:00
Andrew Swan
915d975a82 Bug 1213990 Convert getExtensionUUID to UUIDMap r=kmag
MozReview-Commit-ID: 9VVNa0pjx8g

--HG--
extra : rebase_source : 9959c866b77f5e6e8a4f5636aac6a1b906c6b013
2016-08-03 09:17:24 -07:00
Andrew Swan
b218e5f6ef Bug 1213990 Do immediate uninstall for test webextensions r=kmag
MozReview-Commit-ID: 9vcAfPhRYFi

--HG--
extra : rebase_source : 1834773542373362079d922785652f982f3facb6
2016-07-22 10:16:55 -07:00
Wes Kocher
f341d12e53 Backed out 3 changesets (bug 1213990) for webextension failures a=backout
Backed out changeset 2b1fdeff506d (bug 1213990)
Backed out changeset 157efae8dd8a (bug 1213990)
Backed out changeset ea870f4c5a61 (bug 1213990)
2016-08-02 10:51:06 -07:00
Andrew Swan
863d00a569 Bug 1213990 Clear storage when webextension is uninstalled r=kmag
MozReview-Commit-ID: BeMOxOCSeru

--HG--
extra : rebase_source : 552492edeccd340fcb03fcdd34f6229bb2ca7b48
2016-08-01 16:30:18 -07:00
Andrew Swan
d0a776b0e1 Bug 1213990 Convert getExtensionUUID to UUIDMap r=kmag
MozReview-Commit-ID: 9VVNa0pjx8g

--HG--
extra : rebase_source : befb02708aabf093320d4c6fcd5f70c0b117b087
2016-07-28 10:00:51 -07:00
Andrew Swan
b01dd213c2 Bug 1213990 Do immediate uninstall for test webextensions r=kmag
MozReview-Commit-ID: 9vcAfPhRYFi

--HG--
extra : rebase_source : 2b6313e7a1e572de160afbfcc5f2078f3ae6e716
2016-07-22 10:16:55 -07:00
Wes Kocher
507d36210b Backed out 3 changesets (bug 1213990) for failing a mochitest a=backout
Backed out changeset 846ac5ddba37 (bug 1213990)
Backed out changeset 26bab9c6a89c (bug 1213990)
Backed out changeset 12d7193f1310 (bug 1213990)
2016-08-01 16:56:18 -07:00
Andrew Swan
44326f4fae Bug 1213990 Clear storage when webextension is uninstalled r=kmag
MozReview-Commit-ID: BeMOxOCSeru

--HG--
extra : rebase_source : 389e8ab2f444b615e8b1f558b3f9a588b77f3512
2016-07-28 10:01:09 -07:00