Closed
Bug 1601175
Opened 6 years ago
Closed 6 years ago
SetScriptGlobalObject happens before we have properly set up the document (and hence principal!) of the inner window
Categories
(Core :: DOM: Core & HTML, defect, P3)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla74
| Tracking | Status | |
|---|---|---|
| firefox74 | --- | fixed |
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
Details
Attachments
(1 file)
I just discovered today that we can end up in error-reporting code, examining an inner window's principal, when that principal is null. The sequence of events is as follows:
- We are doing a pageload and land in
nsGlobalWindowOuter::SetNewDocument. - We create a new inner window but have not set its
mDocyet. - We call
SetScriptGlobalObjecton the document. - This grabs CSP violation stuff and tries to report it via
nsCSPContext::flushConsoleMessages. - This lands in
nsScriptErrorBase::InitializeOnMainThreadwhich tries to examine the principal of the window... but that's still nullptr at this point. It happens to not crash only becausensContentUtils::IsSystemPrincipalis null-safe. But, importantly, it's getting the wrong answers if we reach this code for an actual system-principal window via this path!
I am going to try to see what happens if I change the order around in SetNewDocument so we set up mDoc before calling SetScriptGlobalObject... That seems much saner to me, in terms of not passing partially-initialized inner windows around.
| Assignee | ||
Comment 1•6 years ago
|
||
In particular, nsScriptErrorBase::ComputeIsFromPrivateWindow and nsScriptErrorBase::ComputeIsFromChromeContext are the things that will get determined incorrectly.
Updated•6 years ago
|
Priority: -- → P3
| Assignee | ||
Updated•6 years ago
|
Assignee: nobody → bzbarsky
| Assignee | ||
Comment 2•6 years ago
|
||
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3c1f509939f1
Make sure the mDoc of an inner window is set before we call SetScriptGlobalObject on the document. r=peterv
Comment 4•6 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 6 years ago
status-firefox74:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in
before you can comment on or make changes to this bug.
Description
•