mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
Issue #1691 - Part 9: Make import() work when the active script is in another document. https://bugzilla.mozilla.org/show_bug.cgi?id=1342012 Associate event handler with active script when they are compiled.
(cherry picked from commit 1a3cc5d6828a05a6309d959fad3c7e959ab9eb8d)
This commit is contained in:
parent
1109559a5d
commit
be916ef7ca
3 changed files with 17 additions and 4 deletions
|
|
@ -22,6 +22,8 @@
|
||||||
#include "mozilla/dom/Element.h"
|
#include "mozilla/dom/Element.h"
|
||||||
#include "mozilla/dom/Event.h"
|
#include "mozilla/dom/Event.h"
|
||||||
#include "mozilla/dom/EventTargetBinding.h"
|
#include "mozilla/dom/EventTargetBinding.h"
|
||||||
|
#include "mozilla/dom/ModuleScript.h"
|
||||||
|
#include "mozilla/dom/ScriptLoader.h"
|
||||||
#include "mozilla/dom/TouchEvent.h"
|
#include "mozilla/dom/TouchEvent.h"
|
||||||
#include "mozilla/TimelineConsumers.h"
|
#include "mozilla/TimelineConsumers.h"
|
||||||
#include "mozilla/EventTimelineMarker.h"
|
#include "mozilla/EventTimelineMarker.h"
|
||||||
|
|
@ -1018,6 +1020,15 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
|
||||||
NS_ENSURE_SUCCESS(result, result);
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
NS_ENSURE_TRUE(handler, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(handler, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
JS::Rooted<JSFunction*> func(cx, JS_GetObjectFunction(handler));
|
||||||
|
MOZ_ASSERT(func);
|
||||||
|
JS::Rooted<JSScript*> jsScript(cx, JS_GetFunctionScript(cx, func));
|
||||||
|
MOZ_ASSERT(jsScript);
|
||||||
|
RefPtr<LoadedScript> loaderScript = ScriptLoader::GetActiveScript(cx);
|
||||||
|
if (loaderScript) {
|
||||||
|
loaderScript->AssociateWithScript(jsScript);
|
||||||
|
}
|
||||||
|
|
||||||
if (jsEventHandler->EventName() == nsGkAtoms::onerror && win) {
|
if (jsEventHandler->EventName() == nsGkAtoms::onerror && win) {
|
||||||
RefPtr<OnErrorEventHandlerNonNull> handlerCallback =
|
RefPtr<OnErrorEventHandlerNonNull> handlerCallback =
|
||||||
new OnErrorEventHandlerNonNull(nullptr, handler, /* aIncumbentGlobal = */ nullptr);
|
new OnErrorEventHandlerNonNull(nullptr, handler, /* aIncumbentGlobal = */ nullptr);
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ void HostFinalizeTopLevelScript(JSFreeOp* aFop, const JS::Value& aPrivate) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (script->IsModuleScript()) {
|
if (script->IsModuleScript()) {
|
||||||
JSObject* module = script->AsModuleScript()->mModuleRecord.unbarrieredGet();
|
JSObject* module = script->AsModuleScript()->mModuleRecord.unbarrieredGet();
|
||||||
MOZ_ASSERT(JS::GetModulePrivate(module) == aPrivate);
|
MOZ_ASSERT_IF(module, JS::GetModulePrivate(module) == aPrivate);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2259,9 +2259,11 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> scriptContent(do_QueryInterface(aRequest->Element()));
|
bool isDynamicImport = aRequest->IsModuleRequest() &&
|
||||||
MOZ_ASSERT_IF(!scriptContent, aRequest->AsModuleRequest()->IsDynamicImport());
|
aRequest->AsModuleRequest()->IsDynamicImport();
|
||||||
if (scriptContent) {
|
if (!isDynamicImport) {
|
||||||
|
nsCOMPtr<nsIContent> scriptContent(do_QueryInterface(aRequest->Element()));
|
||||||
|
MOZ_ASSERT(scriptContent);
|
||||||
nsIDocument* ownerDoc = scriptContent->OwnerDoc();
|
nsIDocument* ownerDoc = scriptContent->OwnerDoc();
|
||||||
if (ownerDoc != mDocument) {
|
if (ownerDoc != mDocument) {
|
||||||
// Willful violation of HTML5 as of 2010-12-01
|
// Willful violation of HTML5 as of 2010-12-01
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue