WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
213104
Document.currentScript does not work for SVGScriptElements
https://bugs.webkit.org/show_bug.cgi?id=213104
Summary
Document.currentScript does not work for SVGScriptElements
Sam Weinig
Reported
2020-06-11 16:49:24 PDT
Document.currentScript does not work for SVGScriptElements
Attachments
Patch
(14.01 KB, patch)
2020-06-11 17:02 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(15.83 KB, patch)
2020-06-11 17:32 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(19.16 KB, patch)
2020-06-11 20:13 PDT
,
Sam Weinig
ysuzuki
: review+
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Sam Weinig
Comment 1
2020-06-11 16:51:04 PDT
Document.currentScript is specified to work with both HTMLScriptElements and SVGScriptElements (
https://html.spec.whatwg.org/multipage/dom.html#dom-document-currentscript
) but out implementation only works with HTMLScriptElements.
Sam Weinig
Comment 2
2020-06-11 17:02:30 PDT
This is manifest by the failing WPT test html/dom/documents/dom-tree-accessors/Document.currentScript.html
Sam Weinig
Comment 3
2020-06-11 17:02:37 PDT
Comment hidden (obsolete)
Created
attachment 401695
[details]
Patch
Sam Weinig
Comment 4
2020-06-11 17:32:54 PDT
Comment hidden (obsolete)
Created
attachment 401696
[details]
Patch
EWS Watchlist
Comment 5
2020-06-11 17:33:34 PDT
Comment hidden (obsolete)
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See
http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Sam Weinig
Comment 6
2020-06-11 20:13:39 PDT
Created
attachment 401702
[details]
Patch
Yusuke Suzuki
Comment 7
2020-06-11 20:42:10 PDT
Comment on
attachment 401702
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=401702&action=review
r=me
> Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp:1913 > + return NULL;
nullptr?
> Source/WebKitLegacy/mac/DOM/DOMDocument.mm:409 > + return NULL;
nil?
Sam Weinig
Comment 8
2020-06-12 07:28:45 PDT
Committed
r262945
: <
https://trac.webkit.org/changeset/262945
>
Radar WebKit Bug Importer
Comment 9
2020-06-12 07:29:14 PDT
<
rdar://problem/64296452
>
Darin Adler
Comment 10
2020-06-12 09:40:08 PDT
Comment on
attachment 401702
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=401702&action=review
> Source/WebCore/dom/Document.h:1040 > + void pushCurrentScript(Element*);
This should take Element&.
> Source/WebCore/dom/Document.h:1792 > + Vector<RefPtr<Element>> m_currentScriptStack;
This should be Vector<Ref<Element>>.
> Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp:1911 > + WebCore::Element* element = item->currentScript();
auto would make this better.
> Source/WebKitLegacy/mac/DOM/DOMDocument.mm:407 > + WebCore::Element* element = IMPL->currentScript();
auto would make this better.
Darin Adler
Comment 11
2020-06-12 10:03:24 PDT
Sorry, didn’t notice my comments were post-commit.
Yusuke Suzuki
Comment 12
2020-06-12 10:40:34 PDT
Comment on
attachment 401702
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=401702&action=review
>> Source/WebCore/dom/Document.h:1040 >> + void pushCurrentScript(Element*); > > This should take Element&.
This needs to be Element* since this can take `nullptr` in meaningful way. If the module script is executed (<script type="module">), currentScript needs to be `null` JS value. This is represented by `nullptr` here.
Sam Weinig
Comment 13
2020-06-12 10:56:50 PDT
(In reply to Darin Adler from
comment #10
)
> Comment on
attachment 401702
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=401702&action=review
> > > Source/WebCore/dom/Document.h:1040 > > + void pushCurrentScript(Element*); > > This should take Element&. > > > Source/WebCore/dom/Document.h:1792 > > + Vector<RefPtr<Element>> m_currentScriptStack; > > This should be Vector<Ref<Element>>.
Unfortunately, null is used in a meaningful way in this stack, so it can't use references here.
Darin Adler
Comment 14
2020-06-12 10:57:14 PDT
Comment on
attachment 401702
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=401702&action=review
>>>> Source/WebCore/dom/Document.h:1040 >>>> + void pushCurrentScript(Element*); >>> >>> This should take Element&. >> >> This needs to be Element* since this can take `nullptr` in meaningful way. >> If the module script is executed (<script type="module">), currentScript needs to be `null` JS value. >> This is represented by `nullptr` here. > > Unfortunately, null is used in a meaningful way in this stack, so it can't use references here.
So you’re saying that when executing a module script we explicitly push a nullptr? OK, got it.
Sam Weinig
Comment 15
2020-06-12 10:57:46 PDT
(In reply to Darin Adler from
comment #11
)
> Sorry, didn’t notice my comments were post-commit.
Oh, please don't ever worry about that. I think some of my best comments are post-commit!
Sam Weinig
Comment 16
2020-06-12 10:58:25 PDT
(In reply to Darin Adler from
comment #14
)
> Comment on
attachment 401702
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=401702&action=review
> > >>>> Source/WebCore/dom/Document.h:1040 > >>>> + void pushCurrentScript(Element*); > >>> > >>> This should take Element&. > >> > >> This needs to be Element* since this can take `nullptr` in meaningful way. > >> If the module script is executed (<script type="module">), currentScript needs to be `null` JS value. > >> This is represented by `nullptr` here. > > > > Unfortunately, null is used in a meaningful way in this stack, so it can't use references here. > > So you’re saying that when executing a module script we explicitly push a > nullptr? OK, got it.
Yeah. The code is: `m_document.pushCurrentScript(shouldPushNullForCurrentScript ? nullptr : &scriptElement.element());`
Yusuke Suzuki
Comment 17
2020-06-12 11:12:11 PDT
Comment on
attachment 401702
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=401702&action=review
>>>>>> Source/WebCore/dom/Document.h:1040 >>>>>> + void pushCurrentScript(Element*); >>>>> >>>>> This should take Element&. >>>> >>>> This needs to be Element* since this can take `nullptr` in meaningful way. >>>> If the module script is executed (<script type="module">), currentScript needs to be `null` JS value. >>>> This is represented by `nullptr` here. >>> >>> Unfortunately, null is used in a meaningful way in this stack, so it can't use references here. >> >> So you’re saying that when executing a module script we explicitly push a nullptr? OK, got it. > > Yeah. The code is: > > `m_document.pushCurrentScript(shouldPushNullForCurrentScript ? nullptr : &scriptElement.element());`
Yes. And this is specified behavior :)
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug