[webkit-changes] [WebKit/WebKit] 6c6195: Further adjust some heuristics in Document::urlFor...

Wenson Hsieh noreply at github.com
Thu Feb 2 09:52:38 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6c619520fb59603d2777e10a999cdf87d75343f1
      https://github.com/WebKit/WebKit/commit/6c619520fb59603d2777e10a999cdf87d75343f1
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-02-02 (Thu, 02 Feb 2023)

  Changed paths:
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/dom/ScriptExecutionContext.cpp
    M Source/WebCore/dom/ScriptExecutionContext.h

  Log Message:
  -----------
  Further adjust some heuristics in Document::urlForBindings()
https://bugs.webkit.org/show_bug.cgi?id=251549
Speculative fix for rdar://104792427

Reviewed by Chris Dumez.

Adjust some of the heuristics for determining whether to use the `adjustedURL` or not, inside
`Document::urlForBindings()`.

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::urlForBindings const):
(WebCore::Document::mayBeExecutingThirdPartyScript const):

Add a new helper method on `Document` to return whether or not we *might* be executing third party
script, by checking the registrable domain of the `currentSourceURL()`. Deploy this in
`urlForBindings()` above in place of the current `ScriptController::sourceURL()` check, which is
currently only populated when a script is initially evaluated.

* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::currentSourceURL const):

Add a helper method to grab the immediate source URL (first non-empty source URL) by walking call
frames, starting from the VM's top call frame.

(WebCore::ScriptExecutionContext::globalObject const):
(WebCore::ScriptExecutionContext::globalObject): Deleted.

Mark this method `const` so that we can use it from `currentSourceURL()`, and subsequently,
`Document::urlForBindings`.

* Source/WebCore/dom/ScriptExecutionContext.h:

Canonical link: https://commits.webkit.org/259760@main




More information about the webkit-changes mailing list