Commit graph

53 commits

Author SHA1 Message Date
Tomislav Jovanovic
effef809a2 Bug 1386427 - Part 4: Implement basic storage.managed functionality r=kmag
MozReview-Commit-ID: Auy1ujS8wyz

--HG--
extra : rebase_source : abce9a406d36c68509a39569e4b8ce000a08e779
2017-09-16 19:42:40 +02:00
Kris Maglione
3d2f150743 Bug 1370752: Part 3 - Use structured clone rather than JSON to sanitize storage values. r=aswan
This gives us performance wins in sevaral areas:

- Creating a structured clone blob of storage data directly from the source
  compartment allows us to avoid X-ray and JSON serialization overhead when
  storing new values.

- Storing the intermediate StructuredCloneBlob, rather than JSON values,
  in-memory saves us additional JSON and structured clone overhead when
  passing the values to listeners and API callers, and saves us a fair amount
  of memory to boot.

- Serializing storage values before sending them over a message manager allows
  us to deserialize them directly into an extension scope on the other side,
  saving us a lot of additional structured clone overhead and intermediate
  garbage generation.

- Using JSONFile.jsm for storage lets us consolidate multiple storage file
  write operations, rather than performing a separate JSON serialization for
  each individual storage write.

- Additionally, this paves the way for us to transition to IndexedDB as a
  storage backend, with full support for arbitrary structured-clone-compatible
  data structures.

MozReview-Commit-ID: JiRE7EFMYxn

--HG--
extra : rebase_source : caed13b099e7cb05de8d516761e32298a7a81ee5
extra : source : 42d3c1599af53b047d7ccd6b1c92ab08975284d7
2017-07-10 18:24:11 -07:00
Wes Kocher
8185294d28 Backed out 2 changesets (bug 1370752) for failures in test_ext_storage.js a=backout
Backed out changeset 42d3c1599af5 (bug 1370752)
Backed out changeset 9c4bf59ab966 (bug 1370752)

MozReview-Commit-ID: 4M6DsJvJ6RI
2017-07-10 14:34:56 -07:00
Kris Maglione
a835678477 Bug 1370752: Part 3 - Use structured clone rather than JSON to sanitize storage values. r=aswan
This gives us performance wins in sevaral areas:

- Creating a structured clone blob of storage data directly from the source
  compartment allows us to avoid X-ray and JSON serialization overhead when
  storing new values.

- Storing the intermediate StructuredCloneBlob, rather than JSON values,
  in-memory saves us additional JSON and structured clone overhead when
  passing the values to listeners and API callers, and saves us a fair amount
  of memory to boot.

- Serializing storage values before sending them over a message manager allows
  us to deserialize them directly into an extension scope on the other side,
  saving us a lot of additional structured clone overhead and intermediate
  garbage generation.

- Using JSONFile.jsm for storage lets us consolidate multiple storage file
  write operations, rather than performing a separate JSON serialization for
  each individual storage write.

- Additionally, this paves the way for us to transition to IndexedDB as a
  storage backend, with full support for arbitrary structured-clone-compatible
  data structures.

MozReview-Commit-ID: JiRE7EFMYxn

--HG--
extra : rebase_source : 04a5681c604c5d2acd781b7ce4f66a757465071a
2017-06-29 14:11:05 -07:00
Andrew Swan
c29de224fb Bug 1369577 Part 1 Rename SingletonEventManager to EventManager r=kmag
MozReview-Commit-ID: 7nsYWdSTJCG

--HG--
extra : rebase_source : 7afd89a9a1853d51bd31196bb2faa7e0d786043c
2017-06-09 13:49:07 -07:00
Sebastian Hengst
6d1aee1b24 Backed out changeset 26fd6d0a1254 (bug 1369577) for failing xpcshell's test_ext_simple.js and test_ext_startup_cache.js on Android. r=backout 2017-06-30 01:01:13 +02:00
Andrew Swan
c60b71854e Bug 1369577 Part 1 Rename SingletonEventManager to EventManager r=kmag
MozReview-Commit-ID: 7nsYWdSTJCG

--HG--
extra : rebase_source : 22cf5ee36dfa27e121a5c577bce2fd0189ccb164
2017-06-09 13:49:07 -07:00
Bob Silverberg
29414a264f Bug 1374237 - Part 2: Declare all top-level functions in toolkit API files files via const., r=mixedpuppy
Also changed some function names to attempt to guarantee uniqueness across API files.

MozReview-Commit-ID: GnwWwTADF3a

--HG--
extra : rebase_source : 2d51f3de2958089de97ce98ed1f01c68ec0ed74a
2017-06-21 14:29:37 -04:00
Mark Banner
403075400a Bug 1371292 - Clean up more ESLint global definitions in configuration files in toolkit/ and browser/. r=mossop
MozReview-Commit-ID: 5KC23kzaCFN

--HG--
extra : rebase_source : 6a7541b5ffe85d275bc16194c155ad43f93d52ae
2017-06-08 10:59:12 +01:00
Kris Maglione
bae21228e0 Bug 1320186: Don't sanitize storage values more than once. r=aswan
MozReview-Commit-ID: y6S5LqS7fL

--HG--
extra : rebase_source : 45cadc8b865782f3633d01785e6084cd676ccc72
extra : amend_source : a9d9e68e5b66efd0b4859ba8bee9e72cb7f12ced
2017-06-06 18:59:06 -07:00
Kris Maglione
b13ea15e1c Bug 1317697: Remove things from ExtensionUtils that don't belong there. r=mixedpuppy
MozReview-Commit-ID: CTX0TckLqoV

--HG--
extra : rebase_source : ebea9b6f0f17a29d331851a08e025cbd04f4d02b
extra : absorb_source : 70b120f39e9307c4b2ef66d8e776e8b832b4aab8
2017-04-07 13:39:06 -07:00
Kris Maglione
bb351ebfca Bug 1350522: Part 2 - Convert toolkit APIs to lazy loading. r=aswan
MozReview-Commit-ID: 8TbTIM4WX2d

--HG--
extra : source : a3ed5ad1bc338e7fd8055c2efcf73695c25e09e5
2017-03-31 19:36:00 -07:00
Ethan Glasser-Camp
b228d5b47d 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

--HG--
extra : rebase_source : 305a98b8e1ece3ae7a5e8a2fdb5c58d8e7c496d9
2017-01-10 16:44:01 -05:00
Andrew Swan
322ee1283f Bug 1203330 Part 2 Convert EventManager uses to SingletonEventManager r=kmag
MozReview-Commit-ID: A12TPwAYzTS

--HG--
extra : rebase_source : 10526ee923dc1eed24bac3c9b9c80c54b8e174e9
2017-01-26 11:27:03 -08:00
Phil Ringnalda
9447dfdbd4 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
2dde6b8e9b Bug 1203330 Part 2 Convert EventManager uses to SingletonEventManager r=kmag
MozReview-Commit-ID: A12TPwAYzTS

--HG--
extra : rebase_source : 3e034fba247132c3b7a92ce8f4656136c2313a20
2017-01-26 11:27:03 -08:00
Ethan Glasser-Camp
e863aa6c2a 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

--HG--
extra : rebase_source : fa749703bb9aeea214ea9c19fd42d9fdf9ed6efa
2016-12-19 18:06:05 -05:00
Luca Greco
4808be0c5c Bug 1309906 - part2: provide existent APIs to the devtools contexts. r=kmag
MozReview-Commit-ID: L6YOpnMPVFf

--HG--
extra : rebase_source : 8bfafb95e04884d8dafba7cf1569ba342135de41
2016-11-04 12:41:12 +01:00
Ethan Glasser-Camp
57b31da4a0 Bug 1253740 - Add code that syncs and tests, r=bsilverberg,kmag,markh
MozReview-Commit-ID: 8pm2jG92hCs

--HG--
extra : rebase_source : 5ed7b120cb3b1b76498fbdf03f278b24afeb7e89
extra : intermediate-source : cc6b17b87de9162eba88ac5e86d23d63e80b31cd
extra : source : ea91038a3a747fb8d3c122bf6d5757287396189c
2016-09-08 14:16:09 -04:00
Michiel de Jong
002dba0f07 Bug 1253740 - Implement storage.sync, r=bsilverberg,kmag
MozReview-Commit-ID: 5v9nYBTgekj

--HG--
extra : rebase_source : fc267740bbd3f91838c77f071e6e3c039a88fa32
2016-08-11 18:16:37 -04:00
Wes Kocher
57c08b3b40 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
314ce99cee Bug 1253740 - Add code that syncs and tests, r=bsilverberg,kmag,markh
MozReview-Commit-ID: 8pm2jG92hCs

--HG--
extra : rebase_source : 44ff9b5fda993063b907a39192449ca2f910f1f3
extra : intermediate-source : cc6b17b87de9162eba88ac5e86d23d63e80b31cd
extra : source : ea91038a3a747fb8d3c122bf6d5757287396189c
2016-09-08 14:16:09 -04:00
Michiel de Jong
e4f0b4fda1 Bug 1253740 - Implement storage.sync, r=bsilverberg,kmag
MozReview-Commit-ID: 5v9nYBTgekj

--HG--
extra : rebase_source : 17da39c6ab98eaa043b1f00847921e26f91add5a
2016-08-11 18:16:37 -04:00
Sebastian Hengst
4fdd9389f6 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
2535dfda38 Backed out changeset d7e4e2a7c0a6 (bug 1253740) 2016-11-02 16:39:59 +01:00
Ethan Glasser-Camp
8b4a02d6b2 Bug 1253740 - Add code that syncs and tests, r=bsilverberg,kmag,markh
MozReview-Commit-ID: 8pm2jG92hCs

--HG--
extra : rebase_source : 9c7a7141d7d76269f2a8e37b2de9b679a5456943
extra : intermediate-source : abb3063bc341fa10328e0f4dfeb54201d6a472d3
extra : source : ea91038a3a747fb8d3c122bf6d5757287396189c
2016-09-08 14:16:09 -04:00
Michiel de Jong
eb2588e288 Bug 1253740 - Implement storage.sync, r=bsilverberg,kmag
MozReview-Commit-ID: 5v9nYBTgekj

--HG--
extra : rebase_source : 26cf64cf3f4fd07ae2d4dc842b299755a35217b7
2016-08-11 18:16:37 -04: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
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
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
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
Andrew Swan
de7347ec1a Bug 1274708 Use Context.jsonStringify() in ExtensionStorage r=kmag
MozReview-Commit-ID: Ba1w33Jl42n

--HG--
extra : rebase_source : dba7eeea129e5b5e594cea894afe0939abd6e309
2016-06-14 08:56:31 -07:00
Kris Maglione
a1dac7caad Bug 1279392: [webext] Move API permission definitions to the schemas. r=aswan
MozReview-Commit-ID: 8m7wJrAbFwS

--HG--
extra : source : a00cf073f5c00380d4e42b13bc0cd3146b708845
extra : amend_source : d74ef90e88acbe62e33af3b5b9cf870d5c0a9d3e
2016-06-09 17:44:47 -07:00
Sebastian Hengst
f8035f62a8 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
b465305345 Bug 1279392: [webext] Move API permission definitions to the schemas. r=aswan
MozReview-Commit-ID: 8m7wJrAbFwS

--HG--
extra : rebase_source : cba877c0ef400917b0b7e5913895e64ebefb34b9
extra : amend_source : 6e943015e3e00854c431cbd653994a6734e66ce4
2016-06-09 17:44:47 -07:00
Kris Maglione
87247e9d25 Bug 1258139: Part 2 - [webext] Fix dead wrapper issues in storage API. r=gabor
MozReview-Commit-ID: 7F0oBpjl7Qt

--HG--
extra : rebase_source : e4eee969b527078fefd999282371365e8fa39556
2016-03-25 01:14:39 +01:00
Kris Maglione
e6cd1c5fce Bug 1258139: Part 1 - [webext] Refactor storage API code. r=rpl
MozReview-Commit-ID: L6cO7mVnN5E

--HG--
extra : rebase_source : f6fe51fd9b90b2a1bc4928775a07d2c7bd522663
2016-03-25 01:03:30 +01:00
Kris Maglione
ba2e5f60f4 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
cc7eba7dde Bug 1246787 - [webext] Add schema storage.json (r=kmag) 2016-02-11 13:04:31 -08:00
Kris Maglione
8597becbc0 Bug 1234020: Part 2e - [webext] Return promises from the storage API. r=rpl
--HG--
extra : commitid : 5FRGdLfPV8r
extra : rebase_source : 9ab4549e5876e9de236d5adb3e26637d99293a02
2016-01-29 18:59:37 -08:00
Kris Maglione
b729a30707 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.

--HG--
rename : devtools/.eslintrc => toolkit/components/extensions/.eslintrc
extra : commitid : 4aDZOi5MNPc
extra : rebase_source : f34ba43aeb8046a0c971cb76b76410497bd12b42
extra : source : 2a7eb4ef7b375e5fd52d843ca206a071367a6475
2015-12-02 16:58:53 -08:00
Bill McCloskey
fd0aea8d56 Bug 1223585 - [webext] Annotate ignoreEvent (r=kmag) 2015-11-12 08:19:45 -08:00
Johann Hofmann
898c7be7cd Bug 1217886 - Implement chrome.storage.local.clear. r=wmccloskey 2015-11-04 22:29:31 +01:00
Carsten "Tomcat" Book
08997000eb 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
e7ef778c9d Backed out 1 changesets (bug 1202902) for causing merge conflicts to mozilla-central
Backed out changeset cfc1820361f5 (bug 1202902)

--HG--
extra : rebase_source : 5d3db72337754bc7ab0ed0c30b2896100411ff92
2015-10-07 12:13:45 +02:00
Shu-yu Guo
d06b6030f6 Bug 1202902 - Scripted fix the world. 2015-10-06 14:00:31 -07:00
Shu-yu Guo
64db2267cf 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é
d0a42c5e92 Bug 1190995 - Support the new extension model in b2g r=billm 2015-08-14 16:55:09 -07:00
Fabrice Desré
4bccca4c8b Bug 1190995 - backout 0450f02a2b3b for M1 failures 2015-08-14 17:57:34 -07:00
Fabrice Desré
dc4738feca Bug 1190995 - Support the new extension model in b2g r=billm 2015-08-14 16:55:09 -07:00