Closed Bug 1542035 Opened 10 months ago Closed 5 months ago

Support inspection of WebExtension storage.local API data from the Storage panel of the WebExtension Addon Debugger toolbox

Categories

(WebExtensions :: Storage, enhancement, P3)

enhancement

Tracking

(firefox70 verified, firefox71 verified)

VERIFIED FIXED
mozilla70
Tracking Status
firefox70 --- verified
firefox71 --- verified

People

(Reporter: bdanforth, Assigned: bdanforth)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Attachments

(3 files, 3 obsolete files)

This is part of the larger meta Bug 1292234, but it limits the scope of the work to only the browser.storage.local API.

Please refer to rpl's excellent high level description of the work involved.

The scope here will also be further limited to supporting only the IndexedDB extension storage local back-end, which we are migrating to in Firefox 66+ for performance reasons.

Assignee: nobody → bdanforth
Blocks: 1292234
Priority: -- → P3
Type: defect → enhancement
  • Add a new extensionStorage actor to enable inspection of data stored by an extension using the WebExtension storage.local API in the Storage panel client.
  • The actor is only listed when the developer toolbox is targeting an extension process. For multi-process Firefox (e10s), this applies to only the toolbox accessed in about:debugging.
  • The actor is gated behind a preference: devtools.storage.extensionStorage.enabled. This preference is set to false by default.
  • The Storage panel displays storage item values as strings. If a storage item value is not JSON-stringifiable, it will be displayed in the table as "Object".
  • It should be noted that extension storage.local’s storage backend is in the process of migrating from a JSON file to IndexedDB as of Firefox 66 for performance reasons. This actor only works for extensions that have migrated to the IndexedDB storage backend.
  • In-line comments referencing Bugs 1542038 and 1542039 indicate places where the implementation may differ for local storage versus the other storage areas in the actor.
  • Update the extensionStorage actor to enable some writing to extension storage.local through the Storage panel client.
  • All values in the client are displayed as strings, so the actor must stringify them before sending them to the client and parse them when receiving changes from the client. For this reason, there is currently limited write support.
    • Storage item values that are JSONifiable (numbers, strings, booleans, object literals, arrays and null) can be modified in the Storage panel.
    • Non-JSONifiable values cannot be modified, and will be represented by "[value *]" or "[object *]" in the panel, where * depends on the value type.
    • Storage item names can be modified in the storage panel.
  • In-line comments referencing Bugs 1542038 and 1542039 indicate places where the implementation may differ for local storage versus the other storage areas in the actor.
  • The parseItemValue method used in the client was moved to a shared directory, so that the actor could parse string values from the client in its editItem method.

Depends on D34415

Duplicate of this bug: 1557109
Blocks: 1573201

Comment on attachment 9071087 [details]
Bug 1542035 - Add limited write support for extension storage.local in addon debugger

Revision D34416 was moved to bug 1573201. Setting attachment 9071087 [details] to obsolete.

Attachment #9071087 - Attachment is obsolete: true

Moved the limited write support patch to a follow-up bug, Bug 1573201.

Keywords: checkin-needed

Pushed by csabou@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d7bfcc967c3e
Add read-only support for extension storage.local in addon debugger r=miker,rpl

Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70

Bug 1542035 QA Test Plan

Setup

  1. Open Firefox Beta 70 in a new profile
  2. Download the following test extensions attached to this bug:
  • Test Extension 1: 1542035-test-extension-1-1.1.zip
    • Extension with Background script, a content script that loads into any http(s):// webpage, and a browserAction toolbar button. Clicking the browserAction toolbar button opens a popup with a menu.
  • Test Extension 2: 1542035-test-extension-2-1.1.zip
    • Extension with no Background script and a browserAction toolbar button. Clicking the browserAction toolbar button opens a popup with a menu.

Notes about the test extensions:

  • For any non-add operations (i.e. edit, remove, remove all), storage items must first be added.
  • Any non-add bulk operations will affect all storage items if there are less than 10 in total.
  • Both test extensions use a counter for adding new storage items via the browserAction popup menu. This counter starts at 1 (so the first storage item to be added is {"1": 1} and so on). It is stored in storage.sync; therefore it can only be reset back to 1 by clearing the profile's sync data (or using a new profile). There shouldn't be a need to reset the counter.

Verify Extension Storage is not listed in the Storage panel sidebar when ...

The Storage panel is in the addon toolbox and the feature is disabled

  1. In about:config, set devtools.storage.extensionStorage.enabled to false.
  2. Load Test Extension 1 in about:debugging.
  3. Open the addon toolbox for Test Extension 1 in about:debugging, and select the Storage panel.
  4. Verify "Extension Storage" is not listed in the left sidebar.

The Storage panel is in a non-addon toolbox and the feature is enabled

  1. Restart Firefox using the same profile.
  2. In about:config, set devtools.storage.extensionStorage.enabled to true.
  3. Load Test Extension 1 in about:debugging.
  4. Open a page in a new tab (e.g. https://www.mozilla.org/).
  5. Open the in-page toolbox and select the Storage panel.
  6. Verify "Extension Storage" is not listed in the left sidebar.

Verify Storage panel data matches expected data when...

Storage data is modified by various different scripts in the same session

Important: Complete these checks for both Test Extension 1 and Test Extension 2 (referred to as Test Extension below):

  1. In about:config, set devtools.storage.extensionStorage.enabled to true.
  2. Load Test Extension in about:debugging.
  3. If Test Extension 1, open any http(s) page in a new tab (e.g. https://www.mozilla.org/). If such a page was already open, reloading it is sufficient.
  4. If Test Extension 2, open the addon toolbox for the extension in about:debugging and click "Disable Popup Auto-Hide" in the toolbox's overflow menu. Move the toolbox to a second, separate window.
  5. Click the browserAction toolbar icon in the (first) window.
  6. For each option in the browserAction popup:
  • Click an option, e.g. "Background script adds a new storage item" or "browserAction script adds a new storage item".
  • Open (or switch back to) the addon toolbox for Test Extension in about:debugging.
  • Select the Console panel and note the storage item(s) that is/are modified.
  • Open the Storage panel and select the extension under "Extension Storage" in the left sidebar.
  • Verify the storage data displayed in the panel reflects the modification(s).
    • The Storage panel should display the correct data whether the addon toolbox is left open or closed and re-opened each time.
    • Note that if the Storage panel is left open, some modifications require clicking the 'Refresh Items' button in the top right corner of the panel.

Storage data is modified by various different scripts, and then the extension is restarted

Important: Complete these checks for both Test Extension 1 and Test Extension 2 (referred to as Test Extension below):

  1. Remove any previous installation of Test Extension 1 and/or Test Extension 2 and close any open toolboxes.
  2. In about:config, set devtools.storage.extensionStorage.enabled to true.
  3. Load Test Extension in about:debugging.
  4. If Test Extension 2, open the addon toolbox for the extension in about:debugging and click "Disable Popup Auto-Hide" in the toolbox's overflow menu. Move the toolbox to a second, separate window.
  5. Click the browserAction toolbar icon in the (first) window.
  6. In the popup, click 'Background script bulk adds several storage items' or 'browserAction script bulk adds several storage items'.
  7. Open (or switch back to) the addon toolbox for Test Extension in about:debugging.
  8. Select the Storage panel, and select the extension under "Extension Storage" in the left sidebar and note the storage items added.
  9. Close the addon toolbox.
  10. Disable the extension in about:addons.
  11. Enable the extension in about:addons.
  12. Open the addon toolbox for Test Extension in about:debugging.
  13. Select the Storage panel, and select the extension under "Extension Storage" in the left sidebar.
  14. Verify the storage data in the panel matches the data added prior to disabling the addon.

Verify JSONifiable values display as-is while non-JSONifiable values display as "Object"

  1. Remove any previous installation of Test Extension 1 and/or Test Extension 2 and close any open toolboxes.
  2. In about:config, set devtools.storage.extensionStorage.enabled to true.
  3. Load Test Extension 1 in about:debugging.
  4. Open the addon toolbox for Test Extension 1 in about:debugging.
  5. Select the Console panel, and for each of the following stringifiable items, verify they are set as a string equivalent in the Storage panel:
  • Note: Quotes around object literal keys such as f below are expected.
  • Note: the Console panel does not always provide helpful error messages for incorrect syntax, so it is recommended to copy these lines over exactly and limit modifications.
await browser.storage.local.set({a: 123});
await browser.storage.local.set({b: true});
await browser.storage.local.set({c: "test"});
await browser.storage.local.set({d: [1, 2]});
await browser.storage.local.set({e: {f: false}});
await browser.storage.local.set({g: null});```

Select the Console panel, and for each of the following non-stringifiable items, verify they are set as “Object” in the Storage panel:

await browser.storage.local.set({map: new Map()});
await browser.storage.local.set({set: new Set()});
await browser.storage.local.set({arrayBuffer: new ArrayBuffer(8)});
await browser.storage.local.set({regexp: /regexp/});

Try out a real world extension and modify some of its settings kept in storage local

  1. In the same profile as before, download Tree Style Tab from https://addons.mozilla.org/en-US/firefox/addon/tree-style-tab/.
  2. Leaving any new tabs that are created from the install open, open the addon toolbox for Tree Style Tab in about:debugging.
  3. Select the Storage panel, and select the extension under "Extension Storage" in the sidebar and note the storage items present.
  • For version 3.1.7, you should see something like:
    • closeParentBehaviorMode: 1
    • configsVersion: 7
    • notifiedFeaturesVersion: 3
  1. In the extension page that opens up, check both checkbox options. Click through the prompts to accept the increased permissions.
  • For version 3.1.7, the Storage panel should now have data such as:
    • closeParentBehaviorMode: 1
    • configsVersion: 7
    • notifiedFeaturesVersion: 3
    • requestingPermissionsNatively: null
    • skipCollapsedTabsForTabSwitchingShortcuts: true

Appendix

Helpful tips

  • How to clear the test extension’s storage local:
    • Since the test extensions are just temporarily installed, simply restart Firefox.
    • Note that you will need to re-install the test extension via about:debugging.
  • What the error, TypeError: CONTENT_SCRIPT_PORT is null means:
    • Make sure you have an http(s):// page loaded in a tab (e.g. https://www.mozilla.org/).
    • If the extension has restarted (e.g. disabled/re-enabled, reloaded…) since the page was loaded, you may need to reload the page.
  • For Test Extension 2, the addon toolbox's Console panel clears every time the popup is opened, closed, or the browserAction button is hovered over. This makes it hard to reference the Console for how the storage data was modified without doing the following:
    • Each time the toolbox is opened, before opening the browserAction popup, click "Disable Popup Auto-Hide" in the overflow menu settings in the toolbox. This keeps the popup open and therefore keeps the Console from clearing.

Known or possible bugs I found while creating this test plan

Should be fixed as part of this patch

  • Bug 1578447: Adding storage items while the addon toolbox's Storage panel is open live updates, but all other modifications requires a manual refresh by clicking the 'Refresh Items' button. It'd be nice if all modifications automatically refreshed. This may require changes to the larger storage actor framework and/or the Storage panel's client side code, which we've tried hard not to touch.

May be a follow-up bug or unrelated

  • Bug 1578452: The behavior of the addon toolbox's Storage panel is different if left open between disabling and re-enabling it for Test Extension 1 (has background page) versus Test Extension 2 (does not have a background page). For the former, the panel updates to reflect that the extension is disabled. For the later, there is no change. This is outside of the scope of this patch, but it may be worth filing a follow-up bug.
Attached file 1542035-test-extension-1-1.0.zip (obsolete) —

Test Extension 1 for the QA Test Plan

Attached file 1542035-test-extension-2-1.0.zip (obsolete) —

Test Extension 2 for the QA Test Plan

Depends on: 1578447
Depends on: 1578452

Part of the solution for Bug 1578447. See this commit for how version 1.1 differs from 1.0.

Attachment #9089690 - Attachment is obsolete: true

Part of the solution for Bug 1578447. See this commit for how version 1.1 differs from 1.0.

Attachment #9089691 - Attachment is obsolete: true

While testing using the new test extensions I noticed that the Content script add functionality of test extension 1 is not working as expected and added the following bug : https://bugzilla.mozilla.org/show_bug.cgi?id=1580224.
However, I will be setting is as invalid since realizing that the situation was caused by not having an http(s):// page loaded in a tab (e.g. https://www.mozilla.org/).

Blocks: 1585499

Verfied the enhancement implementation on Windows 10 Pro 64-bit Ubuntu 18.04.3 LTS and MACos High Sierra 10.13.6 on Firefox Nightly 71.0a1 (20191007215350) and Beta 70.0b12 (20191002212950).
The 1542035-test-extension-1-1.1.zip and 1542035-test-extension-2-1.1.zip extension were used for testing in order to workaround bug 1578447.
Making use of the QA test plan from comment 8, a test rail test suite was developed to validate the most important flows and testing results were overall passed.
Pre-release QA Sign off was marked as Green.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.