Closed Bug 1340865 Opened 8 years ago Closed 7 years ago

ASSERTION: "Non-XSLT Defer script on a document without an active parser; bug 592366" when loading module script with async=false from event handler

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla54
Tracking Status
firefox54 --- fixed

People

(Reporter: anba, Assigned: jonco)

References

Details

Attachments

(1 file, 1 obsolete file)

Test case:
---
<html>
  <body>
    <script>
function loadModule() {
    var module = document.createElement("script");
    module.type = "module";
    module.src = "./empty.js";
    module.async = false;

    document.documentElement.appendChild(module);
}
    </script>
    <button onclick="loadModule()">Click me!</button>
  </body>
</html>
---

The file "empty.js" is an empty file.


Steps to reproduce:
- Enable "dom.moduleScripts.enabled" preference in about:config
- Click the button in the test case html page


The following assertion is triggered:

[3547] ###!!! ASSERTION: Non-XSLT Defer script on a document without an active parser; bug 592366.: 'mDocument->GetCurrentContentSink() || aElement->GetParserCreated() == FROM_PARSER_XSLT', file /home/andre/hg/mozilla-inbound/dom/base/nsScriptLoader.cpp, line 1629


Stacktrace:
---
#0  0x00007fffe801d764 in RealBreak () at /home/andre/hg/mozilla-inbound/xpcom/base/nsDebugImpl.cpp:457
#1  Break (
    aMsg=0x7fffffff8fc0 "[3547] ###!!! ASSERTION: Non-XSLT Defer script on a document without an active parser; bug 592366.: 'mDocument->GetCurrentContentSink() || aElement->GetParserCreated() == FROM_PARSER_XSLT', file /home"...) at /home/andre/hg/mozilla-inbound/xpcom/base/nsDebugImpl.cpp:546
#2  NS_DebugBreak (aSeverity=aSeverity@entry=1, aStr=aStr@entry=0x7fffebaeda25 "Non-XSLT Defer script on a document without an active parser; bug 592366.", 
    aExpr=aExpr@entry=0x7fffebaed9ce "mDocument->GetCurrentContentSink() || aElement->GetParserCreated() == FROM_PARSER_XSLT", 
    aFile=aFile@entry=0x7fffebaea8ce "/home/andre/hg/mozilla-inbound/dom/base/nsScriptLoader.cpp", aLine=aLine@entry=1629) at /home/andre/hg/mozilla-inbound/xpcom/base/nsDebugImpl.cpp:438
#3  0x00007fffe8e5f34a in nsScriptLoader::ProcessScriptElement (this=0x7fffc1d6fe00, aElement=aElement@entry=0x7fffc7bc9c50) at /home/andre/hg/mozilla-inbound/dom/base/nsScriptLoader.cpp:1627
#4  0x00007fffe8e5f803 in nsScriptElement::MaybeProcessScript (this=this@entry=0x7fffc7bc9c50) at /home/andre/hg/mozilla-inbound/dom/base/nsScriptElement.cpp:149
#5  0x00007fffe975486d in mozilla::dom::HTMLScriptElement::BindToTree (this=0x7fffc7bc9bc0, aDocument=<optimised out>, aParent=<optimised out>, aBindingParent=<optimised out>, 
    aCompileEventHandlers=<optimised out>) at /home/andre/hg/mozilla-inbound/dom/html/HTMLScriptElement.cpp:66
#6  0x00007fffe8e3daf4 in nsINode::doInsertChildAt (this=0x7fffce478be0, aKid=0x7fffc7bc9bc0, aIndex=2, aNotify=<optimised out>, aChildArray=...)
    at /home/andre/hg/mozilla-inbound/dom/base/nsINode.cpp:1624
#7  0x00007fffe8e3cfce in nsINode::ReplaceOrInsertBefore (this=this@entry=0x7fffce478be0, aReplace=aReplace@entry=false, aNewChild=0x7fffc7bc9bc0, aRefChild=aRefChild@entry=0x0, aError=...)
    at /home/andre/hg/mozilla-inbound/dom/base/nsINode.cpp:2527
#8  0x00007fffe8fc7422 in nsINode::InsertBefore (aError=..., aChild=0x0, aNode=..., this=0x7fffce478be0) at /home/andre/hg/mozilla-inbound/dom/base/nsINode.h:1836
#9  nsINode::AppendChild (aError=..., aNode=..., this=0x7fffce478be0) at /home/andre/hg/mozilla-inbound/dom/base/nsINode.h:1840
#10 mozilla::dom::NodeBinding::appendChild (cx=0x7fffe38a2000, obj=..., self=0x7fffce478be0, args=...) at /home/andre/hg/mozilla-inbound/obj-x86_64-pc-linux-gnu/dom/bindings/NodeBinding.cpp:856
#11 0x00007fffe9543d5b in mozilla::dom::GenericBindingMethod (cx=0x7fffe38a2000, argc=<optimised out>, vp=<optimised out>) at /home/andre/hg/mozilla-inbound/dom/bindings/BindingUtils.cpp:2951
#12 0x00007fffeaf1ccca in js::CallJSNative (cx=cx@entry=0x7fffe38a2000, native=0x7fffe9543bec <mozilla::dom::GenericBindingMethod(JSContext*, unsigned int, JS::Value*)>, args=...)
    at /home/andre/hg/mozilla-inbound/js/src/jscntxtinlines.h:281
#13 0x00007fffeaf178ca in js::InternalCallOrConstruct (cx=0x7fffe38a2000, args=..., construct=js::NO_CONSTRUCT) at /home/andre/hg/mozilla-inbound/js/src/vm/Interpreter.cpp:463
#14 0x00007fffeaf0a1ce in js::CallFromStack (args=..., cx=<optimised out>) at /home/andre/hg/mozilla-inbound/js/src/vm/Interpreter.cpp:514
#15 Interpret (cx=0x7fffe38a2000, state=...) at /home/andre/hg/mozilla-inbound/js/src/vm/Interpreter.cpp:2960
#16 0x00007fffeaf174a2 in js::RunScript (cx=cx@entry=0x7fffe38a2000, state=...) at /home/andre/hg/mozilla-inbound/js/src/vm/Interpreter.cpp:409
#17 0x00007fffeaf179e5 in js::InternalCallOrConstruct (cx=cx@entry=0x7fffe38a2000, args=..., construct=construct@entry=js::NO_CONSTRUCT) at /home/andre/hg/mozilla-inbound/js/src/vm/Interpreter.cpp:481
#18 0x00007fffeaf17c56 in InternalCall (cx=cx@entry=0x7fffe38a2000, args=...) at /home/andre/hg/mozilla-inbound/js/src/vm/Interpreter.cpp:508
#19 0x00007fffeaf17dae in js::Call (cx=cx@entry=0x7fffe38a2000, fval=..., fval@entry=..., thisv=..., thisv@entry=..., args=..., rval=..., rval@entry=...)
    at /home/andre/hg/mozilla-inbound/js/src/vm/Interpreter.cpp:527
#20 0x00007fffeb2f05a0 in JS::Call (cx=0x7fffe38a2000, thisv=..., thisv@entry=..., fval=..., fval@entry=..., args=..., rval=..., rval@entry=...) at /home/andre/hg/mozilla-inbound/js/src/jsapi.cpp:2883
#21 0x00007fffe942b61f in mozilla::dom::EventHandlerNonNull::Call (this=this@entry=0x7fffbf4fa140, cx=0x7fffe38a2000, aThisVal=..., aThisVal@entry=..., event=..., aRetVal=..., aRetVal@entry=..., aRv=...)
    at /home/andre/hg/mozilla-inbound/obj-x86_64-pc-linux-gnu/dom/bindings/EventHandlerBinding.cpp:260
#22 0x00007fffe9674e74 in mozilla::dom::EventHandlerNonNull::Call<nsISupports*> (aCompartment=0x0, aExceptionHandling=mozilla::dom::CallbackObject::eReportExceptions, 
    aExecutionReason=0x7fffebb8303b "EventHandlerNonNull", aRv=..., aRetVal=..., event=..., thisVal=@0x7fffc5a71ec8: 0x7fffce384a80, this=<optimised out>)
    at /home/andre/hg/mozilla-inbound/obj-x86_64-pc-linux-gnu/dist/include/mozilla/dom/EventHandlerBinding.h:362
#23 mozilla::JSEventHandler::HandleEvent (this=0x7fffc5a71eb0, aEvent=<optimised out>) at /home/andre/hg/mozilla-inbound/dom/events/JSEventHandler.cpp:214
#24 0x00007fffe967adbb in mozilla::EventListenerManager::HandleEventSubType (this=this@entry=0x7fffd8128430, aListener=<optimised out>, aListener@entry=0x7fffd8128460, aDOMEvent=0x7fffc6fd8920, 
    aCurrentTarget=aCurrentTarget@entry=0x7fffce384a80) at /home/andre/hg/mozilla-inbound/dom/events/EventListenerManager.cpp:1123
#25 0x00007fffe967b55a in mozilla::EventListenerManager::HandleEventInternal (this=0x7fffd8128430, aPresContext=<optimised out>, aEvent=0x7fffffffb0e8, aDOMEvent=aDOMEvent@entry=0x7fffffffae98, 
    aCurrentTarget=<optimised out>, aEventStatus=aEventStatus@entry=0x7fffffffaea0) at /home/andre/hg/mozilla-inbound/dom/events/EventListenerManager.cpp:1297
...
---
Jon, can you take a look here?
Flags: needinfo?(jcoppeard)
Attached patch bug1340865-insert-module-script (obsolete) (deleted) — Splinter Review
I think we just want to do the same thing for non-parser-created non-async classic scripts here.

(I originally excluded module requests from this block because of the comment about spec violations, but now I look at this again it's talking about the order in which these are executed, and looking at that I'm not sure it is even different to what the spec says any more.)
Assignee: nobody → jcoppeard
Flags: needinfo?(jcoppeard)
Attachment #8840012 - Flags: review?(bugs)
Comment on attachment 8840012 [details] [diff] [review]
bug1340865-insert-module-script

We need a wpt test to ensure this case works the same way in all the browsers.

Why is the test not racy? As far as I see, nothing guarantees module_setRan.js
is run before the timeout fires. Because of that, r-, but wpt test would be better.
Attachment #8840012 - Flags: review?(bugs) → review-
Updated patch with a non-racy WPT test.
Attachment #8840012 - Attachment is obsolete: true
Attachment #8840975 - Flags: review?(bugs)
Comment on attachment 8840975 [details] [diff] [review]
bug1340865-insert-module-script v2

I guess this behavior is fine, since nothing really guarantees the order.
I think the comment about spec violation isn't quite right, since the order could be anything.
Attachment #8840975 - Flags: review?(bugs) → review+
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/1ad2304b97a8
Handle non-parser-created module scripts r=smaug
https://hg.mozilla.org/mozilla-central/rev/1ad2304b97a8
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: