https://bugs.webkit.org/show_bug.cgi?id=213166
Rename executeIfJavaScriptURL to executeJavaScriptURL
Patch by Rob Buis <rbuis@igalia.com> 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):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@263008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index de15bea..861e64c 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2020-06-13 Rob Buis <rbuis@igalia.com>
+
+ 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 <zalan@apple.com>
[LFC][Floats] Floating positioned box is always a float avoider.
diff --git a/Source/WebCore/bindings/js/ScriptController.cpp b/Source/WebCore/bindings/js/ScriptController.cpp
index f391a8b..43d7732 100644
--- a/Source/WebCore/bindings/js/ScriptController.cpp
+++ b/Source/WebCore/bindings/js/ScriptController.cpp
@@ -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
diff --git a/Source/WebCore/bindings/js/ScriptController.h b/Source/WebCore/bindings/js/ScriptController.h
index f7b2ec1..eceb47b 100644
--- a/Source/WebCore/bindings/js/ScriptController.h
+++ b/Source/WebCore/bindings/js/ScriptController.h
@@ -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.
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index f17e3a4..124681f 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -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;
}
diff --git a/Source/WebCore/loader/SubframeLoader.cpp b/Source/WebCore/loader/SubframeLoader.cpp
index 7584a4e..53af7d8 100644
--- a/Source/WebCore/loader/SubframeLoader.cpp
+++ b/Source/WebCore/loader/SubframeLoader.cpp
@@ -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());
}