Skip to content

[BUG] Screenshot Data Lost When Using Privacy Editor Due to localStorage Context Issue #121

Description

@Karelaking

Bug Description

The extension uses localStorage to pass screenshot data from the popup to the editor window. This is unreliable in Chrome extensions because:

  1. localStorage in popup context may not persist when popup closes
  2. localStorage is not shared between popup and window contexts
  3. Data can be lost if popup closes before editor reads it

Steps To Reproduce

  1. Take a screenshot (full page or visible area)
  2. Click "Edit" button to open privacy editor
  3. Editor opens in new window
  4. Editor attempts to read from localStorage.getItem('screenshotForEdit')
  5. Data may be undefined or null

Expected Behavior

  • Screenshot data should reliably transfer from popup to editor
  • Data should persist even if popup closes
  • Editor should always receive the screenshot data

Actual Behavior

  • Editor may show "No screenshot data found"
  • Data can be lost during transfer
  • Inconsistent behavior across browsers

Affected Files

  • src/popup/popup.js (Line 266): localStorage.setItem('screenshotForEdit', captureData);
  • src/editor/editor.js (Line 82): const screenshotData = localStorage.getItem('screenshotForEdit');

Environment

  • OS: All platforms
  • Browser: Chrome (most affected), Firefox, Edge
  • Version: 1.2.0

Possible Solution

Use chrome.storage.local API instead of localStorage:

// In popup.js:
document.getElementById('editBtn').addEventListener('click', async () => {
  if (captureData) {
    // Store in chrome.storage.local
    await chrome.storage.local.set({ screenshotForEdit: captureData });
    
    chrome.windows.create({
      url: chrome.runtime.getURL('/editor/editor.html'),
      type: 'popup',
      width: 1200,
      height: 800
    });
  }
});

// In editor.js:
async function loadScreenshot() {
  const result = await chrome.storage.local.get('screenshotForEdit');
  const screenshotData = result.screenshotForEdit;
  
  if (!screenshotData) {
    updateStatus('No screenshot data found', true);
    return;
  }
  
  // ... rest of loading logic
  
  // Clear after loading
  await chrome.storage.local.remove('screenshotForEdit');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions