X-ray expandos for inner window are lost when recomputing wrappers
Webcompat Score Accessibility Severity Size Estimate a11y-review Performance Impact Webcompat Priority Tracking Status relnote-firefox thunderbird_esr115 thunderbird_esr128 thunderbird_esr140 firefox-esr115 firefox-esr128 firefox-esr140 firefox140 firefox141 firefox142Reset Assignee to default
Bug Flags:
behind-pref firefox-backlog sec-bounty sec-bounty-hof in-qa-testsuite in-testsuite qe-verifyThis bug is publicly visible.
This page for example (also happens on other pages), wait for the Phabricator Revisions to load and then click one of the Phabricator Revision. Wait for the Phabricator page to load. Now click the back-button.
Actual:
It seems that the content script is not loaded into the (cached)? page.
Expected:
The content script should be loaded into the page (in chrome it works as expected).
This is the expected behavior. Content scripts get loaded into a document once. When you go back to a page in bfcache, the content scripts are already loaded, so they don't get loaded again. If you want to do something special in those cases, you need to add a "pageshow" listener.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
(In reply to Kris Maglione [:kmag] from comment #1)
so they don't get loaded again.
I need to load the jquery.min.js script into the cached page again?
Because, it doesn't seem to stay loaded in the cached page!
Sorry, it should be:
so they don't get loaded again.
I need to load the jquery.min.js script into the cached page again?
Because, it doesn't seem to stay loaded in the cached page!
the content scripts are already loaded
The jquery.min.js script does not stay loaded in the cached page.
If you have a testcase that shows the problem, I can look at it, but the testcase you posted works as expected.
The jquery.min.js script is still cached, but the jQuery property on the window is not available anymore.
Is this a bug or is this the expected behavior?
Flags: needinfo?(kmaglione+bmo)
STR:
window.prop1
, this.prop1
(this = content script global) and document.prop3
)Expected:
window.prop1
, this.prop1
and window.prop2
should be printed.Actual:
window.prop1
has become undefined
(after pageshow
).Full log demonstrating the issue, captured in Firefox Nightly 67.0a1 buildID 20190211092917
[https://example.com/ Mon Feb 11 2019 18:28:41 GMT+0100 (Central European Standard Time)] contentscript executed for the first time
window.prop1 = window.prop
global.prop2 = global.prop
global.prop1 = window.prop (inherit from window)
document.prop3 = document.prop
contentscript.js:17:5
[https://example.com/ Mon Feb 11 2019 18:28:41 GMT+0100 (Central European Standard Time)] pagehide
window.prop1 = window.prop
global.prop2 = global.prop
global.prop1 = window.prop (inherit from window)
document.prop3 = document.prop
contentscript.js:17:5
[https://example.com/ Mon Feb 11 2019 18:28:41 GMT+0100 (Central European Standard Time)] pageshow
window.prop1 = undefined
global.prop2 = global.prop
global.prop1 = undefined (inherit from window)
document.prop3 = document.prop
This is a valid bug and needs more investigation.
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: INVALID → ---
Summary: content script not loaded into (cached)? page when using back button → Expandos on window object of content script are cleared upon navigating back to the bfcache
Component: General → XPConnect
Flags: needinfo?(kmaglione+bmo)
Product: WebExtensions → Core
Summary: Expandos on window object of content script are cleared upon navigating back to the bfcache → X-ray expandos for inner window are lost when recomputing wrappers
Boris, your thoughts on this one?
Flags: needinfo?(bzbarsky)
Priority: -- → P2
Found related bug 1404107. Jason, can you look into this?
Flags: needinfo?(bzbarsky) → needinfo?(jorendorff)
So the basic structure here is like so. We start with a Window W1 which has a WindowProxy P1. There is an Xray X1 to it, which points at the WindowProxy.
Now we navigate. This creates a new Window W2 and a new WindowProxy P2. P1 mutates into a cross-compartment wrapper to P2. All CCWs are recomputed and X1 becomes an Xray pointing to P2. The old contents of the X1 object (including expandos) are thrown away; they can't stay on the object, because it now represents a new window and that should not have the same expandos.
Then we navigate back. The current window becomes W1 again. P1 becomes its WindowProxy again. P2 becomes a CCW to P1. We recompute CCWs again, and X1 becomes an Xray pointing to P1. But the expando state is gone.
In terms of fixing this, probably the sanest thing is for WindowStateHolder to store all the Xray expando objects for the window. Then we can restore them after we do the xpc::TransplantObject in nsGlobalWindowOuter::SetNewDocument (which is what does the wrapper remapping).
Flags: needinfo?(jorendorff)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4