Title: [263008] trunk/Source/WebCore
Revision
263008
Author
[email protected]
Date
2020-06-13 23:34:43 -0700 (Sat, 13 Jun 2020)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=213166
Rename executeIfJavaScriptURL to executeJavaScriptURL

Patch by Rob Buis <[email protected]> on 2020-06-13
Reviewed by Darin Adler.

Rename executeIfJavaScriptURL to executeJavaScriptURL in order to make the function
unconditional, i.e.  the passed url is expected to have the _javascript_ protocol, this
is asserted first thing in the method.  This allows us to remove the return parameter
since the remaining return statements all return true.

* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::executeJavaScriptURL):
(WebCore::ScriptController::executeIfJavaScriptURL): Deleted.
* bindings/js/ScriptController.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::changeLocation):
(WebCore::FrameLoader::submitForm):
* loader/SubframeLoader.cpp:
(WebCore::FrameLoader::SubframeLoader::requestFrame):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (263007 => 263008)


--- trunk/Source/WebCore/ChangeLog	2020-06-14 00:39:13 UTC (rev 263007)
+++ trunk/Source/WebCore/ChangeLog	2020-06-14 06:34:43 UTC (rev 263008)
@@ -1,3 +1,25 @@
+2020-06-13  Rob Buis  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=213166
+        Rename executeIfJavaScriptURL to executeJavaScriptURL
+
+        Reviewed by Darin Adler.
+
+        Rename executeIfJavaScriptURL to executeJavaScriptURL in order to make the function
+        unconditional, i.e.  the passed url is expected to have the _javascript_ protocol, this
+        is asserted first thing in the method.  This allows us to remove the return parameter
+        since the remaining return statements all return true.
+
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::executeJavaScriptURL):
+        (WebCore::ScriptController::executeIfJavaScriptURL): Deleted.
+        * bindings/js/ScriptController.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::changeLocation):
+        (WebCore::FrameLoader::submitForm):
+        * loader/SubframeLoader.cpp:
+        (WebCore::FrameLoader::SubframeLoader::requestFrame):
+
 2020-06-13  Zalan Bujtas  <[email protected]>
 
         [LFC][Floats] Floating positioned box is always a float avoider.

Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (263007 => 263008)


--- trunk/Source/WebCore/bindings/js/ScriptController.cpp	2020-06-14 00:39:13 UTC (rev 263007)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp	2020-06-14 06:34:43 UTC (rev 263008)
@@ -806,16 +806,15 @@
     return m_frame.loader().client().allowScript(m_frame.settings().isScriptEnabled());
 }
 
-bool ScriptController::executeIfJavaScriptURL(const URL& url, RefPtr<SecurityOrigin> requesterSecurityOrigin, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL)
+void ScriptController::executeJavaScriptURL(const URL& url, RefPtr<SecurityOrigin> requesterSecurityOrigin, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL)
 {
-    if (!url.protocolIsJavaScript())
-        return false;
+    ASSERT(url.protocolIsJavaScript());
 
     if (requesterSecurityOrigin && !requesterSecurityOrigin->canAccess(m_frame.document()->securityOrigin()))
-        return true;
+        return;
 
     if (!m_frame.page() || !m_frame.document()->contentSecurityPolicy()->allowJavaScriptURLs(m_frame.document()->url().string(), eventHandlerPosition().m_line))
-        return true;
+        return;
 
     // We need to hold onto the Frame here because executing script can
     // destroy the frame.
@@ -835,17 +834,17 @@
     // If executing script caused this frame to be removed from the page, we
     // don't want to try to replace its document!
     if (!m_frame.page())
-        return true;
+        return;
 
     if (!result)
-        return true;
+        return;
 
     String scriptResult;
     bool isString = result.getString(globalObject, scriptResult);
-    RETURN_IF_EXCEPTION(throwScope, true);
+    RETURN_IF_EXCEPTION(throwScope, void());
 
     if (!isString)
-        return true;
+        return;
 
     // FIXME: We should always replace the document, but doing so
     //        synchronously can cause crashes:
@@ -865,7 +864,6 @@
         if (RefPtr<DocumentLoader> loader = m_frame.document()->loader())
             loader->writer().replaceDocumentWithResultOfExecutingJavascriptURL(scriptResult, ownerDocument.get());
     }
-    return true;
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/ScriptController.h (263007 => 263008)


--- trunk/Source/WebCore/bindings/js/ScriptController.h	2020-06-14 00:39:13 UTC (rev 263007)
+++ trunk/Source/WebCore/bindings/js/ScriptController.h	2020-06-14 06:34:43 UTC (rev 263008)
@@ -109,8 +109,8 @@
 
     Expected<void, ExceptionDetails> shouldAllowUserAgentScripts(Document&) const;
 
-    // Returns true if argument is a _javascript_ URL.
-    bool executeIfJavaScriptURL(const URL&, RefPtr<SecurityOrigin> = nullptr, ShouldReplaceDocumentIfJavaScriptURL = ReplaceDocumentIfJavaScriptURL);
+    // This asserts that URL argument is a _javascript_ URL.
+    void executeJavaScriptURL(const URL&, RefPtr<SecurityOrigin> = nullptr, ShouldReplaceDocumentIfJavaScriptURL = ReplaceDocumentIfJavaScriptURL);
 
     // This function must be called from the main thread. It is safe to call it repeatedly.
     // Darwin is an exception to this rule: it is OK to call this function from any thread, even reentrantly.

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (263007 => 263008)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2020-06-14 00:39:13 UTC (rev 263007)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2020-06-14 06:34:43 UTC (rev 263008)
@@ -436,7 +436,8 @@
 
     Ref<Frame> protect(m_frame);
 
-    if (m_frame.script().executeIfJavaScriptURL(frameRequest.resourceRequest().url(), &frameRequest.requester().securityOrigin(), frameRequest.shouldReplaceDocumentIfJavaScriptURL())) {
+    if (frameRequest.resourceRequest().url().protocolIsJavaScript()) {
+        m_frame.script().executeJavaScriptURL(frameRequest.resourceRequest().url(), &frameRequest.requester().securityOrigin(), frameRequest.shouldReplaceDocumentIfJavaScriptURL());
         m_quickRedirectComing = false;
         return;
     }
@@ -475,7 +476,7 @@
     if (formAction.protocolIsJavaScript()) {
         m_isExecutingJavaScriptFormAction = true;
         Ref<Frame> protect(m_frame);
-        m_frame.script().executeIfJavaScriptURL(submission->action(), nullptr, DoNotReplaceDocumentIfJavaScriptURL);
+        m_frame.script().executeJavaScriptURL(submission->action(), nullptr, DoNotReplaceDocumentIfJavaScriptURL);
         m_isExecutingJavaScriptFormAction = false;
         return;
     }

Modified: trunk/Source/WebCore/loader/SubframeLoader.cpp (263007 => 263008)


--- trunk/Source/WebCore/loader/SubframeLoader.cpp	2020-06-14 00:39:13 UTC (rev 263007)
+++ trunk/Source/WebCore/loader/SubframeLoader.cpp	2020-06-14 06:34:43 UTC (rev 263008)
@@ -103,7 +103,7 @@
         // FIXME: Some sites rely on the _javascript_:'' loading synchronously, which is why we have this special case.
         // Blink has the same workaround (https://bugs.chromium.org/p/chromium/issues/detail?id=923585).
         if (urlString == "_javascript_:''" || urlString == "_javascript_:\"\"")
-            frame->script().executeIfJavaScriptURL(scriptURL);
+            frame->script().executeJavaScriptURL(scriptURL);
         else
             frame->navigationScheduler().scheduleLocationChange(ownerElement.document(), ownerElement.document().securityOrigin(), scriptURL, m_frame.loader().outgoingReferrer(), lockHistory, lockBackForwardList, stopDelayingLoadEvent.release());
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to