Attachment #9032897: bug1342012-15-associate-event-handlers v2 for bug #1342012

View | Details | Raw Unified | Return to bug 1342012
Collapse All | Expand All

(-)a/dom/events/EventListenerManager.cpp (+11 lines)
Line     Link Here 
 Lines 17-33    Link Here 
17
#include "mozilla/JSEventHandler.h"
17
#include "mozilla/JSEventHandler.h"
18
#include "mozilla/Maybe.h"
18
#include "mozilla/Maybe.h"
19
#include "mozilla/MemoryReporting.h"
19
#include "mozilla/MemoryReporting.h"
20
#include "mozilla/Preferences.h"
20
#include "mozilla/Preferences.h"
21
#include "mozilla/dom/BindingUtils.h"
21
#include "mozilla/dom/BindingUtils.h"
22
#include "mozilla/dom/Element.h"
22
#include "mozilla/dom/Element.h"
23
#include "mozilla/dom/Event.h"
23
#include "mozilla/dom/Event.h"
24
#include "mozilla/dom/EventTargetBinding.h"
24
#include "mozilla/dom/EventTargetBinding.h"
25
#include "mozilla/dom/LoadedScript.h"
25
#include "mozilla/dom/PopupBlocker.h"
26
#include "mozilla/dom/PopupBlocker.h"
27
#include "mozilla/dom/ScriptLoader.h"
26
#include "mozilla/dom/ScriptSettings.h"
28
#include "mozilla/dom/ScriptSettings.h"
27
#include "mozilla/dom/TouchEvent.h"
29
#include "mozilla/dom/TouchEvent.h"
28
#include "mozilla/TimelineConsumers.h"
30
#include "mozilla/TimelineConsumers.h"
29
#include "mozilla/EventTimelineMarker.h"
31
#include "mozilla/EventTimelineMarker.h"
30
#include "mozilla/TimeStamp.h"
32
#include "mozilla/TimeStamp.h"
31
33
32
#include "EventListenerService.h"
34
#include "EventListenerService.h"
33
#include "nsCOMArray.h"
35
#include "nsCOMArray.h"
 Lines 985-1000   nsresult EventListenerManager::CompileEv Link Here 
985
987
986
  JS::Rooted<JSObject*> handler(cx);
988
  JS::Rooted<JSObject*> handler(cx);
987
  result = nsJSUtils::CompileFunction(jsapi, scopeChain, options,
989
  result = nsJSUtils::CompileFunction(jsapi, scopeChain, options,
988
                                      nsAtomCString(typeAtom), argCount,
990
                                      nsAtomCString(typeAtom), argCount,
989
                                      argNames, *body, handler.address());
991
                                      argNames, *body, handler.address());
990
  NS_ENSURE_SUCCESS(result, result);
992
  NS_ENSURE_SUCCESS(result, result);
991
  NS_ENSURE_TRUE(handler, NS_ERROR_FAILURE);
993
  NS_ENSURE_TRUE(handler, NS_ERROR_FAILURE);
992
994
995
  JS::Rooted<JSFunction*> func(cx, JS_GetObjectFunction(handler));
996
  MOZ_ASSERT(func);
997
  JS::Rooted<JSScript*> jsScript(cx, JS_GetFunctionScript(cx, func));
998
  MOZ_ASSERT(jsScript);
999
  RefPtr<LoadedScript> loaderScript = ScriptLoader::GetActiveScript(cx);
1000
  if (loaderScript) {
1001
    loaderScript->AssociateWithScript(jsScript);
1002
  }
1003
993
  MOZ_ASSERT(js::IsObjectInContextCompartment(handler, cx));
1004
  MOZ_ASSERT(js::IsObjectInContextCompartment(handler, cx));
994
  JS::Rooted<JSObject*> handlerGlobal(cx, JS::CurrentGlobalOrNull(cx));
1005
  JS::Rooted<JSObject*> handlerGlobal(cx, JS::CurrentGlobalOrNull(cx));
995
1006
996
  if (jsEventHandler->EventName() == nsGkAtoms::onerror && win) {
1007
  if (jsEventHandler->EventName() == nsGkAtoms::onerror && win) {
997
    RefPtr<OnErrorEventHandlerNonNull> handlerCallback =
1008
    RefPtr<OnErrorEventHandlerNonNull> handlerCallback =
998
        new OnErrorEventHandlerNonNull(static_cast<JSContext*>(nullptr),
1009
        new OnErrorEventHandlerNonNull(static_cast<JSContext*>(nullptr),
999
                                       handler, handlerGlobal,
1010
                                       handler, handlerGlobal,
1000
                                       /* aIncumbentGlobal = */ nullptr);
1011
                                       /* aIncumbentGlobal = */ nullptr);
(-)a/dom/script/LoadedScript.cpp (-1 / +1 lines)
Line     Link Here 
 Lines 64-80   void HostFinalizeTopLevelScript(JSFreeOp Link Here 
64
  // pointed to by a dying JSScript. The reference count was
64
  // pointed to by a dying JSScript. The reference count was
65
  // originally incremented by AssociateWithScript() above.
65
  // originally incremented by AssociateWithScript() above.
66
66
67
  auto script = static_cast<LoadedScript*>(aPrivate.toPrivate());
67
  auto script = static_cast<LoadedScript*>(aPrivate.toPrivate());
68
68
69
#ifdef DEBUG
69
#ifdef DEBUG
70
  if (script->IsModuleScript()) {
70
  if (script->IsModuleScript()) {
71
    JSObject* module = script->AsModuleScript()->mModuleRecord.unbarrieredGet();
71
    JSObject* module = script->AsModuleScript()->mModuleRecord.unbarrieredGet();
72
    MOZ_ASSERT(JS::GetModulePrivate(module) == aPrivate);
72
    MOZ_ASSERT_IF(module, JS::GetModulePrivate(module) == aPrivate);
73
  }
73
  }
74
#endif
74
#endif
75
75
76
  script->Release();
76
  script->Release();
77
}
77
}
78
78
79
//////////////////////////////////////////////////////////////
79
//////////////////////////////////////////////////////////////
80
// ClassicScript
80
// ClassicScript
(-)a/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-base-url-external-classic.html.ini (-7 lines)
Line     Link Here 
 Lines 1-7    Link Here 
1
[string-compilation-base-url-external-classic.html]
2
  [reflected-inline-event-handlers should successfully import]
3
    expected: FAIL
4
5
  [inline-event-handlers-UA-code should successfully import]
6
    expected: FAIL
7
(-)a/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-base-url-external-module.html.ini (-7 lines)
Line     Link Here 
 Lines 1-7    Link Here 
1
[string-compilation-base-url-external-module.html]
2
  [reflected-inline-event-handlers should successfully import]
3
    expected: FAIL
4
5
  [inline-event-handlers-UA-code should successfully import]
6
    expected: FAIL
7
(-)a/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-nonce-classic.html.ini (-6 lines)
Line     Link Here 
 Lines 1-10    Link Here 
1
[string-compilation-nonce-classic.html]
1
[string-compilation-nonce-classic.html]
2
  [setTimeout must inherit the nonce from the triggering script, thus execute]
2
  [setTimeout must inherit the nonce from the triggering script, thus execute]
3
    expected: FAIL
3
    expected: FAIL
4
4
5
  [reflected inline event handlers must inherit the nonce from the triggering script, thus execute]
6
    expected: FAIL
7
8
  [inline event handlers triggered via UA code must inherit the nonce from the triggering script, thus execute]
9
    expected: FAIL
10
(-)a/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-nonce-module.html.ini (-7 lines)
Line     Link Here 
 Lines 1-10    Link Here 
1
[string-compilation-nonce-module.html]
1
[string-compilation-nonce-module.html]
2
  [setTimeout must inherit the nonce from the triggering script, thus execute]
2
  [setTimeout must inherit the nonce from the triggering script, thus execute]
3
    expected: FAIL
3
    expected: FAIL
4
5
  [reflected inline event handlers must inherit the nonce from the triggering script, thus execute]
6
    expected: FAIL
7
8
  [inline event handlers triggered via UA code must inherit the nonce from the triggering script, thus execute]
9
    expected: FAIL
10

Return to bug 1342012