Bug 1342012 - Associate event handler with active script when they are compiled r=smaug

This commit is contained in:
Jon Coppeard 2019-01-03 10:06:01 +00:00
Родитель 4f6ab86fcf
Коммит ca2a67e9ff
6 изменённых файлов: 12 добавлений и 28 удалений

Просмотреть файл

@ -22,7 +22,9 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/EventTargetBinding.h"
#include "mozilla/dom/LoadedScript.h"
#include "mozilla/dom/PopupBlocker.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/TimelineConsumers.h"
@ -990,6 +992,15 @@ nsresult EventListenerManager::CompileEventHandlerInternal(
NS_ENSURE_SUCCESS(result, result);
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);
}
MOZ_ASSERT(js::IsObjectInContextCompartment(handler, cx));
JS::Rooted<JSObject*> handlerGlobal(cx, JS::CurrentGlobalOrNull(cx));

Просмотреть файл

@ -69,7 +69,7 @@ void HostFinalizeTopLevelScript(JSFreeOp* aFop, const JS::Value& aPrivate) {
#ifdef DEBUG
if (script->IsModuleScript()) {
JSObject* module = script->AsModuleScript()->mModuleRecord.unbarrieredGet();
MOZ_ASSERT(JS::GetModulePrivate(module) == aPrivate);
MOZ_ASSERT_IF(module, JS::GetModulePrivate(module) == aPrivate);
}
#endif

Просмотреть файл

@ -1,7 +0,0 @@
[string-compilation-base-url-external-classic.html]
[reflected-inline-event-handlers should successfully import]
expected: FAIL
[inline-event-handlers-UA-code should successfully import]
expected: FAIL

Просмотреть файл

@ -1,7 +0,0 @@
[string-compilation-base-url-external-module.html]
[reflected-inline-event-handlers should successfully import]
expected: FAIL
[inline-event-handlers-UA-code should successfully import]
expected: FAIL

Просмотреть файл

@ -2,9 +2,3 @@
[setTimeout must inherit the nonce from the triggering script, thus execute]
expected: FAIL
[reflected inline event handlers must inherit the nonce from the triggering script, thus execute]
expected: FAIL
[inline event handlers triggered via UA code must inherit the nonce from the triggering script, thus execute]
expected: FAIL

Просмотреть файл

@ -1,10 +1,3 @@
[string-compilation-nonce-module.html]
[setTimeout must inherit the nonce from the triggering script, thus execute]
expected: FAIL
[reflected inline event handlers must inherit the nonce from the triggering script, thus execute]
expected: FAIL
[inline event handlers triggered via UA code must inherit the nonce from the triggering script, thus execute]
expected: FAIL