Commit Graph

43 Commits

Author SHA1 Message Date
Kris Maglione
da08b6926c Bug 1317697: Remove things from ExtensionUtils that don't belong there. r=mixedpuppy
MozReview-Commit-ID: CTX0TckLqoV
2017-04-07 13:39:06 -07:00
Kris Maglione
884009911d Bug 1350522: Part 2 - Convert toolkit APIs to lazy loading. r=aswan
MozReview-Commit-ID: 8TbTIM4WX2d
2017-03-31 19:36:00 -07:00
Ethan Glasser-Camp
8e51fef619 Bug 1321570 - use dependency injection for fxAccounts, r=kmag
Get rid of the ugly hack where test code monkeypatches a singleton to
convince the rest of the ExtensionStorageSync code that a fake user is
logged in. Instead, take a handle to the fxAccounts service at
construction time. Test code can provide any kind of fxAccounts it
wants, including one that has a hard-coded user.

This provokes a bunch of changes:

- ExtensionStorageSync is now no longer a singleton, but a class. You
  have to instantiate it in order to do anything with it. A global
  instance extensionStorageSync is provided for use by Sync code as
  well as WebExtension code.

- CryptoCollection is now also a class, and each ExtensionStorageSync
  instance has its own CryptoCollection. This dependency should maybe
  also be injected, but for the time being it doesn't provide us any
  value to do so.

- Converting singletons with asynchronous methods to classes is a pain
  in the neck. We convert async method foo from `foo:
  Task.async(....)` to `async foo() { .... }`. While we're here,
  convert KeyRingEncryptionRemoteTransformer#decode to async/await to
  eliminate a need for `let self = this`.

- Update Sync code and WebExtension code to use extensionStorageSync.

- There's a cyclic dependency where CryptoCollection#sync depends on
  ExtensionStorageSync#_syncCollection which depends on
  CryptoCollection#getKeyRing. As a short-term hack, we now require an
  ExtensionStorageSync argument to CryptoCollection#sync.

- KeyRingEncryptionRemoteTransformer now takes a handle to fxAccounts
  on construction time as well. Because this is the only
  EncryptionRemoteTransformer subclass that accesses fxAccounts, we
  can get rid of the hack where the tests monkeypatch something in the
  EncryptionRemoteTransformer prototype.

- CollectionKeyEncryptionRemoteTransformer now takes a handle to a
  CryptoCollection, rather than relying on a global one.

- A bunch of methods that previously assumed access to fxAccounts now
  check if fxAccounts is present (i.e. if we're on Android). Strictly
  speaking, this isn't required by this change, but it helps make
  certain kinds of failure a little easier to diagnose.

- Update tests, including extracting a domain-specific helper method
  to hide the use of CollectionKeyEncryptionRemoteTransformer. We now
  no longer monkeypatch in our mock fxaService, but pass it to the
  test so that it can do whatever it wants with it. We also provide an
  ExtensionStorageSync instance for convenience. Access to the global
  cryptoCollection is now done through an ExtensionStorageSync
  instance.

To summarize, we've gone from a situation where a bunch of singletons
had implicit dependencies on other singletons in a shared global
namespace, to a situation where dependencies are provided explicitly
using method/constructor arguments. This highlights some of the
dependencies present:

- ExtensionStorageSync depends on CryptoCollection and fxAccounts if
  it needs to sync

- Every collection created via openCollection needs a handle to
  CryptoCollection so it can correctly create its remote transformers

- CryptoCollection needs a handle to fxAccounts so it can create its
  own remote transformer for its special collection

Most of this is only possible, or at least much easier, because we no
longer try to juggle Sqlite connections but just keep one around
forever.

However, please note:

- CryptoCollection needs a handle to ExtensionStorageSync to actually
  perform syncing logic because that's where we foolishly put the
  logic to make requests

- There's still a backing Sqlite store which is shared by everything

- There's still a singleton tracking contexts that opened extensions
  which we manage to try to clean contexts up correctly

MozReview-Commit-ID: DGIzyRTdYZ1
2017-01-10 16:44:01 -05:00
Andrew Swan
d23b45b581 Bug 1203330 Part 2 Convert EventManager uses to SingletonEventManager r=kmag
MozReview-Commit-ID: A12TPwAYzTS
2017-01-26 11:27:03 -08:00
Phil Ringnalda
5781d2a09e Backed out 3 changesets (bug 1203330) for failures in test_delay_update_webextension.js
CLOSED TREE

Backed out changeset 2d42350d209a (bug 1203330)
Backed out changeset 3a12c51c3eca (bug 1203330)
Backed out changeset 31fac390e15d (bug 1203330)
2017-01-26 19:13:11 -08:00
Andrew Swan
99c8d3a692 Bug 1203330 Part 2 Convert EventManager uses to SingletonEventManager r=kmag
MozReview-Commit-ID: A12TPwAYzTS
2017-01-26 11:27:03 -08:00
Ethan Glasser-Camp
d9bfc68da1 Bug 1323228 - throw an exception if using the storage API without an ID, r=kmag
This protection is in ext-storage.js rather than
ExtensionStorageSync.jsm because storage.local may one day be migrated
to work using the same code as ExtensionStorageSync, but without any
syncing event loop. When this happens, we still want to raise but only
in the storage.sync case.

MozReview-Commit-ID: Jwu9FA5DZA6
2016-12-19 18:06:05 -05:00
Luca Greco
89a4aa4c82 Bug 1309906 - part2: provide existent APIs to the devtools contexts. r=kmag
MozReview-Commit-ID: L6YOpnMPVFf
2016-11-04 12:41:12 +01:00
Ethan Glasser-Camp
1c16eba2cc Bug 1253740 - Add code that syncs and tests, r=bsilverberg,kmag,markh
MozReview-Commit-ID: 8pm2jG92hCs
2016-09-08 14:16:09 -04:00
Michiel de Jong
f4b60082d3 Bug 1253740 - Implement storage.sync, r=bsilverberg,kmag
MozReview-Commit-ID: 5v9nYBTgekj
2016-08-11 18:16:37 -04:00
Wes Kocher
f17d46cc2b Backed out 9 changesets (bug 1253740) for xpcshell failures a=backout
Backed out changeset 903890f218dd (bug 1253740)
Backed out changeset 1b13fe394b66 (bug 1253740)
Backed out changeset e1312ab53299 (bug 1253740)
Backed out changeset 5b5338a2baeb (bug 1253740)
Backed out changeset d3d89d4e2d87 (bug 1253740)
Backed out changeset 96da5e6944b8 (bug 1253740)
Backed out changeset 4fbff333994f (bug 1253740)
Backed out changeset 653788e146f2 (bug 1253740)
Backed out changeset b98fa03d8c15 (bug 1253740)
2016-11-11 18:59:24 -08:00
Ethan Glasser-Camp
492b52f8a9 Bug 1253740 - Add code that syncs and tests, r=bsilverberg,kmag,markh
MozReview-Commit-ID: 8pm2jG92hCs
2016-09-08 14:16:09 -04:00
Michiel de Jong
a1fdb6f3ff Bug 1253740 - Implement storage.sync, r=bsilverberg,kmag
MozReview-Commit-ID: 5v9nYBTgekj
2016-08-11 18:16:37 -04:00
Sebastian Hengst
35ad3e7e0a Backed out changeset 396333163897 (bug 1253740) for failing xpcshell /test_ext_storage.js on Android and Linux. r=backout on a CLOSED TREE 2016-11-02 16:42:22 +01:00
Sebastian Hengst
5c978afde0 Backed out changeset d7e4e2a7c0a6 (bug 1253740) 2016-11-02 16:39:59 +01:00
Ethan Glasser-Camp
26a598a5d7 Bug 1253740 - Add code that syncs and tests, r=bsilverberg,kmag,markh
MozReview-Commit-ID: 8pm2jG92hCs
2016-09-08 14:16:09 -04:00
Michiel de Jong
e5151fda43 Bug 1253740 - Implement storage.sync, r=bsilverberg,kmag
MozReview-Commit-ID: 5v9nYBTgekj
2016-08-11 18:16:37 -04: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
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
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
Andrew Swan
8be33a5e99 Bug 1274708 Use Context.jsonStringify() in ExtensionStorage r=kmag
MozReview-Commit-ID: Ba1w33Jl42n
2016-06-14 08:56:31 -07:00
Kris Maglione
843973aa31 Bug 1279392: [webext] Move API permission definitions to the schemas. r=aswan
MozReview-Commit-ID: 8m7wJrAbFwS
2016-06-09 17:44:47 -07:00
Sebastian Hengst
d97f588f03 Backed out changeset a00cf073f5c0 (bug 1279392) for failing mochitest test_ext_contentscript_create_iframe.html at least on Linux x64 opt. r=backout 2016-06-14 13:37:52 +02:00
Kris Maglione
b2a33e3bf1 Bug 1279392: [webext] Move API permission definitions to the schemas. r=aswan
MozReview-Commit-ID: 8m7wJrAbFwS
2016-06-09 17:44:47 -07:00
Kris Maglione
2a00e3a878 Bug 1258139: Part 2 - [webext] Fix dead wrapper issues in storage API. r=gabor
MozReview-Commit-ID: 7F0oBpjl7Qt
2016-03-25 01:14:39 +01:00
Kris Maglione
683987e77f Bug 1258139: Part 1 - [webext] Refactor storage API code. r=rpl
MozReview-Commit-ID: L6cO7mVnN5E
2016-03-25 01:03:30 +01:00
Kris Maglione
666cee3637 Bug 1248855 - [webext] Add "object-curly-spacing" ESLint rule and auto-fix errors. r=billm
MozReview-Commit-ID: BAZ2rRl7eSM
2016-02-16 20:10:00 -08:00
Bill McCloskey
e0f8de3c70 Bug 1246787 - [webext] Add schema storage.json (r=kmag) 2016-02-11 13:04:31 -08:00
Kris Maglione
ff06160124 Bug 1234020: Part 2e - [webext] Return promises from the storage API. r=rpl 2016-01-29 18:59:37 -08:00
Kris Maglione
956fe582d0 Bug 1229874: Part 3 - Enable ESLint in WebExtension code. r=billm
The base .eslintrc is essentially a merge of the root Toolkit .eslintrc and
the devtools .eslintrc, with some minor changes to match our prevalent style.

For the most enforces the coding styles that we've been using most
consistently. There are a couple of significant differences, though:

 * The rule for opening brace alignment can only be applied globally, and
   doesn't make exceptions for top-level functions. I chose to turn it on, and
   change the brace style of existing top-level functions that violated it,
   since the rule seemed worth using, and that's the direction most Toolkit JS
   code has been headed anyway.

 * The rule for switch/case statements requires an added indentation level for
   case statements. Most of our switch statements did not use an extra level
   of indentation, and I initially wrote the rule to enforce that style, until
   I came across case statements that used blocks, and required the extra
   indentation level for sanity.
2015-12-02 16:58:53 -08:00
Bill McCloskey
948f074381 Bug 1223585 - [webext] Annotate ignoreEvent (r=kmag) 2015-11-12 08:19:45 -08:00
Johann Hofmann
3b798c478f Bug 1217886 - Implement chrome.storage.local.clear. r=wmccloskey 2015-11-04 22:29:31 +01:00
Carsten "Tomcat" Book
036e6d2fa3 Backed out 2 changesets (bug 1202902) to recking bug 1202902 to be able to reopen inbound on a CLOSED TREE
Backed out changeset 647025383676 (bug 1202902)
Backed out changeset d70c7fe532c6 (bug 1202902)
2015-10-07 14:03:21 +02:00
Carsten "Tomcat" Book
12369728f5 Backed out 1 changesets (bug 1202902) for causing merge conflicts to mozilla-central
Backed out changeset cfc1820361f5 (bug 1202902)
2015-10-07 12:13:45 +02:00
Shu-yu Guo
474f49adb7 Bug 1202902 - Scripted fix the world. 2015-10-06 14:00:31 -07:00
Shu-yu Guo
37989840cd Bug 1202902 - Mass replace toplevel 'let' with 'var' in preparation for global lexical scope. (rs=jorendorff) 2015-09-15 11:19:45 -07:00
Fabrice Desré
bc561611cc Bug 1190995 - Support the new extension model in b2g r=billm 2015-08-14 16:55:09 -07:00
Fabrice Desré
c50552b3e4 Bug 1190995 - backout 0450f02a2b3b for M1 failures 2015-08-14 17:57:34 -07:00
Fabrice Desré
edcc328e33 Bug 1190995 - Support the new extension model in b2g r=billm 2015-08-14 16:55:09 -07:00
Bill McCloskey
1ba4b05dd9 Bug 1175770 - New extension API (r=Mossop) 2015-08-03 10:41:24 -07:00
Carsten "Tomcat" Book
5b881a75d9 Backed out changeset 4e3821b236f9 (bug 1175770) 2015-08-03 09:37:54 +02:00
Bill McCloskey
d7318b2bd9 Bug 1175770 - New extension API (r=Mossop) 2015-08-02 17:29:55 -07:00