Bug Description
The extension uses localStorage to pass screenshot data from the popup to the editor window. This is unreliable in Chrome extensions because:
- localStorage in popup context may not persist when popup closes
- localStorage is not shared between popup and window contexts
- Data can be lost if popup closes before editor reads it
Steps To Reproduce
- Take a screenshot (full page or visible area)
- Click "Edit" button to open privacy editor
- Editor opens in new window
- Editor attempts to read from
localStorage.getItem('screenshotForEdit')
- 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');
}
Bug Description
The extension uses
localStorageto pass screenshot data from the popup to the editor window. This is unreliable in Chrome extensions because:Steps To Reproduce
localStorage.getItem('screenshotForEdit')Expected Behavior
Actual Behavior
Affected Files
src/popup/popup.js(Line 266):localStorage.setItem('screenshotForEdit', captureData);src/editor/editor.js(Line 82):const screenshotData = localStorage.getItem('screenshotForEdit');Environment
Possible Solution
Use
chrome.storage.localAPI instead of localStorage: