Commit Graph

45 Commits

Author SHA1 Message Date
Kris Maglione
856fa07b17 Bug 1514594: Part 3 - Change ChromeUtils.import API.
***
Bug 1514594: Part 3a - Change ChromeUtils.import to return an exports object; not pollute global. r=mccr8

This changes the behavior of ChromeUtils.import() to return an exports object,
rather than a module global, in all cases except when `null` is passed as a
second argument, and changes the default behavior not to pollute the global
scope with the module's exports. Thus, the following code written for the old
model:

  ChromeUtils.import("resource://gre/modules/Services.jsm");

is approximately the same as the following, in the new model:

  var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");

Since the two behaviors are mutually incompatible, this patch will land with a
scripted rewrite to update all existing callers to use the new model rather
than the old.
***
Bug 1514594: Part 3b - Mass rewrite all JS code to use the new ChromeUtils.import API. rs=Gijs

This was done using the followng script:

https://bitbucket.org/kmaglione/m-c-rewrites/src/tip/processors/cu-import-exports.jsm
***
Bug 1514594: Part 3c - Update ESLint plugin for ChromeUtils.import API changes. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D16747
***
Bug 1514594: Part 3d - Remove/fix hundreds of duplicate imports from sync tests. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16748
***
Bug 1514594: Part 3e - Remove no-op ChromeUtils.import() calls. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16749
***
Bug 1514594: Part 3f.1 - Cleanup various test corner cases after mass rewrite. r=Gijs
***
Bug 1514594: Part 3f.2 - Cleanup various non-test corner cases after mass rewrite. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16750
2019-01-17 10:18:31 -08:00
Kris Maglione
541a602618 Bug 1476032: Neuter StructuredCloneHolder objects after deserializing. r=aswan
Differential Revision: https://phabricator.services.mozilla.com/D17287
2019-01-22 13:01:22 -08:00
Luca Greco
541560466e Bug 1475306 - Changes to the detection of extensions already migrated to ExtensionStorageIDB and rename successfully migrated JSONFile. r=mixedpuppy
This patch applies the following changes to the storage.local data migration behaviors:

- An about:config preference is set when an extension has been migrated successfully to the
  storage.local IndexedDB backend (cleared automatically if the addon is uninstalled).
- If the above about:config preference is set, the storage.local IndexedDB backend is enabled
  without attempting to open an IndexedDB connection for the new backend.
- While migrating an extension, if we fail to open the IndexedDB connection, the data migration
  is cancelled and the storage.local API is going to fallback to the storage.local JSONFile backend
  (until the next extension startup, when a new data migration is going to be tried).
- When a migration is completed successfully, the old JSONFile is renamed (by appending ".migrated"
  to its original file name) instead of being removed.

MozReview-Commit-ID: LPM0fQUagTd
2018-07-06 19:07:28 +02:00
Luca Greco
fb1814a3e1 Bug 1406181 - Add ExtensionStorageIDB JSM module. r=aswan
This patch defined a new ExtensionStorageIDB module, which provides the
same "internal" API currently provided by ExtensionStorage and uses
IndexedDB as its backend (instead of the JSONFile used as the backend
provided by ExtensionStorage).

MozReview-Commit-ID: DsvPudExcyr
2017-10-17 04:12:15 +02:00
Luca Greco
2014f60047 Bug 1406181 - Move serialize/deserialize helpers from ext-c-storage.js to ExtensionStorage.jsm. r=kmag
MozReview-Commit-ID: 4iundHpQ8d2
2017-10-18 19:31:27 +02:00
Cosmin Sabou
0f5163a609 Backed out 10 changesets (bug 1406181) as per developers request.
Backed out changeset 06461ddb2699 (bug 1406181)
Backed out changeset fd61d9faedf0 (bug 1406181)
Backed out changeset b52c2fb70ae1 (bug 1406181)
Backed out changeset 4f387b4a76a9 (bug 1406181)
Backed out changeset db783c96c076 (bug 1406181)
Backed out changeset 62e9126ecd0d (bug 1406181)
Backed out changeset d34810cab822 (bug 1406181)
Backed out changeset 3241c2dfb296 (bug 1406181)
Backed out changeset 912a2eaf4d26 (bug 1406181)
Backed out changeset fdac47b8ef20 (bug 1406181)
2018-06-03 16:10:23 +03:00
Luca Greco
c751280589 Bug 1406181 - Add ExtensionStorageIDB JSM module. r=aswan
This patch defined a new ExtensionStorageIDB module, which provides the
same "internal" API currently provided by ExtensionStorage and uses
IndexedDB as its backend (instead of the JSONFile used as the backend
provided by ExtensionStorage).

MozReview-Commit-ID: DsvPudExcyr
2017-10-17 04:12:15 +02:00
Luca Greco
bbe53783be Bug 1406181 - Move serialize/deserialize helpers from ext-c-storage.js to ExtensionStorage.jsm. r=kmag
MozReview-Commit-ID: 4iundHpQ8d2
2017-10-18 19:31:27 +02:00
Florian Quèze
f1a55f73f8 Bug 1440284 - change this.EXPORTED_SYMBOLS back to var EXPORTED_SYMBOLS in JS modules, r=mccr8. 2018-02-23 20:50:01 +01:00
Kris Maglione
b6b0e424db Fix typo JSON.serialize -> JSON.stringify. (no bug) r=trivial
MozReview-Commit-ID: J94OgyyiDQ5
2018-02-17 19:52:06 -08:00
Andrew McCreight
272cee1e65 Bug 1432992, part 1 - Remove definitions of Ci, Cr, Cc, and Cu. r=florian
This patch was autogenerated by my decomponents.py

It covers almost every file with the extension js, jsm, html, py,
xhtml, or xul.

It removes blank lines after removed lines, when the removed lines are
preceded by either blank lines or the start of a new block. The "start
of a new block" is defined fairly hackily: either the line starts with
//, ends with */, ends with {, <![CDATA[, """ or '''. The first two
cover comments, the third one covers JS, the fourth covers JS embedded
in XUL, and the final two cover JS embedded in Python. This also
applies if the removed line was the first line of the file.

It covers the pattern matching cases like "var {classes: Cc,
interfaces: Ci, utils: Cu, results: Cr} = Components;". It'll remove
the entire thing if they are all either Ci, Cr, Cc or Cu, or it will
remove the appropriate ones and leave the residue behind. If there's
only one behind, then it will turn it into a normal, non-pattern
matching variable definition. (For instance, "const { classes: Cc,
Constructor: CC, interfaces: Ci, utils: Cu } = Components" becomes
"const CC = Components.Constructor".)

MozReview-Commit-ID: DeSHcClQ7cG
2018-02-06 09:36:57 -08:00
Kris Maglione
0bb74efdf1 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl
2018-01-29 15:20:18 -08:00
Cosmin Sabou
f09d6d985d Backed out 3 changesets (bug 1431533) for Android mochitest failures on testEventDispatcher on a CLOSED TREE
Backed out changeset a1eca62826a1 (bug 1431533)
Backed out changeset 34c999fa006b (bug 1431533)
Backed out changeset e2674287e57f (bug 1431533)
2018-01-30 07:17:48 +02:00
Kris Maglione
fd67f090b2 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl
2018-01-29 15:20:18 -08:00
Brindusan Cristian
483ba301cb Backed out 2 changesets (bug 1431533) for ESlint failures on a CLOSED TREE
Backed out changeset 6e56f4c8843e (bug 1431533)
Backed out changeset 12fc4dee861c (bug 1431533)
2018-01-30 02:32:43 +02:00
Kris Maglione
683a97d172 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl
2018-01-29 15:20:18 -08:00
Kris Maglione
c8ea1d4273 Bug 1421459: Update to ESLint 4 "indent" rule. r=aswan
MozReview-Commit-ID: LxLDWlsIlSk
2017-11-28 14:13:59 -08:00
Tomislav Jovanovic
1566f5e353 Bug 1386427 - Part 4: Implement basic storage.managed functionality r=kmag
MozReview-Commit-ID: Auy1ujS8wyz
2017-09-16 19:42:40 +02:00
Kris Maglione
ee30da7682 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
2017-07-10 18:24:11 -07:00
Wes Kocher
a0b015fa22 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
5c0bb13dcc 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
2017-06-29 14:11:05 -07:00
Kris Maglione
e8bafb1a92 Bug 1320186: Don't sanitize storage values more than once. r=aswan
MozReview-Commit-ID: y6S5LqS7fL
2017-06-06 18:59:06 -07:00
Florian Queze
d3c36892fa Bug 1356569 - Remove addObserver's last parameter when it is false, r=jaws. 2017-04-14 21:51:38 +02:00
Sebastian Hengst
42670ceca0 Backed out changeset 322fde2d53bf (bug 1356569) so bug 1355161 can be backed out. r=backout 2017-04-14 23:39:22 +02:00
Florian Queze
9b4f73599f Bug 1356569 - Remove addObserver's last parameter when it is false, r=jaws. 2017-04-14 21:51:38 +02:00
Luca Greco
2fe83e6087 Bug 1320181 - Storage sanitizer should return an empty object belonging to the correct scope. r=kmag
MozReview-Commit-ID: Bx95Cgx0EuH
2016-11-28 20:11:06 +01:00
Rob Wu
ab47bf4a5d Bug 1287007 - Fix cross-process browser.storage.local serialization r=billm
- Lazily initialize file IO-specific stuff in ExtensionStorage.jsm,
  and limit this work to the main process.

- Add local versions of the `storage.local.get` and `storage.local.set`
  implementations that perform sanitization (without the change, values
  are improperly serialized over IPC).

- Copied the `backgroundScript` test from xpcshell/test_ext_storage.js
  to mochitest/test_ext_storage_content.html because they should behave
  identical. Before this patch the test failed due to IPC serialization
  issues, now the test passes.
  Note that the old test also passes with the changes.

MozReview-Commit-ID: 8J8CCdwMACN
2016-09-04 19:19:17 -07:00
Martin Giger
a4d444323f Bug 1265317 - Handle missing storage error as success. r=kmag 2016-06-15 07:13:00 -04: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
4a1342c9e6 Bug 1278733: Turn on JSDoc validation, and fix basic errors in existing comments. r=aswan
MozReview-Commit-ID: EZpOyvoi2h0
2016-06-07 18:36:19 -07:00
Bill McCloskey
f43508ae12 Bug 1197346 - Allow browser.storage to be used from content scripts (r=kmag) 2016-04-23 20:04:30 -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
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
Johann Hofmann
3b798c478f Bug 1217886 - Implement chrome.storage.local.clear. r=wmccloskey 2015-11-04 22:29:31 +01:00
Bill McCloskey
ff77125470 Bug 1197475 - [webext] Add test for browser.storage.local, fix a few bugs in it (r=gabor) 2015-09-23 17:18:30 -07:00
Phil Ringnalda
aaf72d29b9 Backed out 12 changesets (bug 1202482, bug 1202483, bug 1202481, bug 1202486, bug 1202479, bug 1202478, bug 1197475, bug 1203331, bug 1139860, bug 1202501, bug 1199473, bug 1190662) for Mulet mochitest-5 timeouts
CLOSED TREE

Backed out changeset 6503123e95dd (bug 1139860)
Backed out changeset b83bc163064d (bug 1203331)
Backed out changeset 2f501bd57cd2 (bug 1202481)
Backed out changeset 37e6ac7beb42 (bug 1202486)
Backed out changeset f9b6e99e620e (bug 1202483)
Backed out changeset 466af9f9baee (bug 1202482)
Backed out changeset 6be690e265a2 (bug 1202479)
Backed out changeset 57ff88bfccf4 (bug 1197475)
Backed out changeset 7e8c04ff6049 (bug 1202478)
Backed out changeset 525227997274 (bug 1202501)
Backed out changeset da317cdb79d3 (bug 1199473)
Backed out changeset 73b8ddd6dac9 (bug 1190662)
2015-09-22 19:29:51 -07:00
Bill McCloskey
28e66b14dc Bug 1197475 - [webext] Add test for browser.storage.local, fix a few bugs in it (r=gabor) 2015-09-22 16:09:21 -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