mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1805492 - Avoid firing WebExtension content script error on the content window. r=evilpie
I'm also removing AssociatedWindowOrNull as this was the only usage of it. Differential Revision: https://phabricator.services.mozilla.com/D164608
This commit is contained in:
parent
68e935a7d0
commit
7dc932df03
@ -515,14 +515,19 @@ void AutoJSAPI::ReportException() {
|
||||
if (mIsMainThread) {
|
||||
RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
|
||||
|
||||
// We aren't using WindowOrNull as we also want to match web extension
|
||||
// content scripts against the related window their sandbox executes
|
||||
// against.
|
||||
RefPtr<nsGlobalWindowInner> inner =
|
||||
xpc::AssociatedWindowOrNull(errorGlobal, cx());
|
||||
RefPtr<nsGlobalWindowInner> inner = xpc::WindowOrNull(errorGlobal);
|
||||
|
||||
// For WebExtension content script, `WindowOrNull` method will return
|
||||
// null, whereas we would still like to flag the exception with the
|
||||
// related WindowGlobal the content script executed against. So we only
|
||||
// update the `innerWindowID` and not `inner` as we don't want to dispatch
|
||||
// exceptions caused by the content script to the webpage.
|
||||
uint64_t innerWindowID = 0;
|
||||
if (inner) {
|
||||
innerWindowID = inner->WindowID();
|
||||
} else if (nsGlobalWindowInner* win = xpc::SandboxWindowOrNull(
|
||||
JS::GetNonCCWObjectGlobal(errorGlobal), cx())) {
|
||||
innerWindowID = win->WindowID();
|
||||
}
|
||||
|
||||
bool isChrome =
|
||||
|
@ -627,14 +627,6 @@ nsGlobalWindowInner* WindowGlobalOrNull(JSObject* aObj) {
|
||||
return WindowOrNull(glob);
|
||||
}
|
||||
|
||||
nsGlobalWindowInner* AssociatedWindowOrNull(JSObject* aObj, JSContext* aCx) {
|
||||
nsGlobalWindowInner* win = WindowOrNull(aObj);
|
||||
if (win) {
|
||||
return win;
|
||||
}
|
||||
return SandboxWindowOrNull(JS::GetNonCCWObjectGlobal(aObj), aCx);
|
||||
}
|
||||
|
||||
nsGlobalWindowInner* SandboxWindowOrNull(JSObject* aObj, JSContext* aCx) {
|
||||
MOZ_ASSERT(aObj);
|
||||
|
||||
|
@ -553,15 +553,6 @@ nsGlobalWindowInner* WindowOrNull(JSObject* aObj);
|
||||
*/
|
||||
nsGlobalWindowInner* WindowGlobalOrNull(JSObject* aObj);
|
||||
|
||||
/**
|
||||
* If |aObj| is a window, returns the associated nsGlobalWindow,
|
||||
* or, if |aObj| is a Sandbox associated with a DOMWindow via a
|
||||
* sandboxPrototype, then return that DOMWindow. Otherwise, returns null.
|
||||
*
|
||||
* |aCx| is used for checked unwrapping of the Window.
|
||||
*/
|
||||
nsGlobalWindowInner* AssociatedWindowOrNull(JSObject* aObj, JSContext* aCx);
|
||||
|
||||
/**
|
||||
* If |aObj| is a Sandbox object associated with a DOMWindow via a
|
||||
* sandboxPrototype, then return that DOMWindow.
|
||||
|
Loading…
Reference in New Issue
Block a user