Diff
Modified: trunk/LayoutTests/ChangeLog (118598 => 118599)
--- trunk/LayoutTests/ChangeLog 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/LayoutTests/ChangeLog 2012-05-26 02:05:47 UTC (rev 118599)
@@ -1,3 +1,18 @@
+2012-05-25 Mihai Parparita <[email protected]>
+
+ Allow synchronous XHRs to be disabled in documents
+ https://bugs.webkit.org/show_bug.cgi?id=87540
+
+ Reviewed by Eric Seidel.
+
+ Synchronous XMLHttpRequests are a problematic API, since they result
+ in blocked UI threads. Some clients may wish to always disable them;
+ give them a setting to do so (see also r103629 for other cases where
+ synchronous XHRs are disabled).
+
+ * fast/xmlhttprequest/xmlhttprequest-sync-disabled-expected.txt: Added.
+ * fast/xmlhttprequest/xmlhttprequest-sync-disabled.html: Added.
+
2012-05-25 Stephanie Lewis <[email protected]>
See https://bugs.webkit.org/show_bug.cgi?id=87558
Added: trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-sync-disabled-expected.txt (0 => 118599)
--- trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-sync-disabled-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-sync-disabled-expected.txt 2012-05-26 02:05:47 UTC (rev 118599)
@@ -0,0 +1,11 @@
+CONSOLE MESSAGE: Synchronous XMLHttpRequests cannot be made in the current window context.
+This tests that synchronous XMLHttpRequests fail when they are disabled for documents.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS xhr.open("GET", "http://mydomain/", false) threw exception Error: INVALID_ACCESS_ERR: DOM Exception 15.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-sync-disabled.html (0 => 118599)
--- trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-sync-disabled.html (rev 0)
+++ trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-sync-disabled.html 2012-05-26 02:05:47 UTC (rev 118599)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script>
+ if ('internals' in window) {
+ window.internals.settings.setSyncXHRInDocumentsEnabled(false);
+ } else {
+ document.write('This test depends on the syncXHRInDocumentsEnabled setting being false, so run in DumpRenderTree or manually enable it');
+ }
+
+ description('This tests that synchronous XMLHttpRequests fail when they are disabled for documents.');
+ var xhr = new XMLHttpRequest();
+ shouldThrow('xhr.open("GET", "http://mydomain/", false)');
+ </script>
+ <script src=""
+</head>
+<body>
+ <div id="description"></div>
+ <div id="console"></div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (118598 => 118599)
--- trunk/Source/WebCore/ChangeLog 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/Source/WebCore/ChangeLog 2012-05-26 02:05:47 UTC (rev 118599)
@@ -1,3 +1,35 @@
+2012-05-25 Mihai Parparita <[email protected]>
+
+ Allow synchronous XHRs to be disabled in documents
+ https://bugs.webkit.org/show_bug.cgi?id=87540
+
+ Reviewed by Eric Seidel.
+
+ Test: fast/xmlhttprequest/xmlhttprequest-sync-disabled.html
+
+ Synchronous XMLHttpRequests are a problematic API, since they result
+ in blocked UI threads. Some clients may wish to always disable them;
+ give them a setting to do so (see also r103629 for other cases where
+ synchronous XHRs are disabled).
+
+ * page/Settings.cpp:
+ (WebCore):
+ (WebCore::Settings::Settings):
+ * page/Settings.h:
+ (Settings):
+ (WebCore::Settings::setSyncXHRInDocumentsEnabled):
+ (WebCore::Settings::syncXHRInDocumentsEnabled):
+ * testing/InternalSettings.cpp:
+ (WebCore::InternalSettings::InternalSettings):
+ (WebCore::InternalSettings::restoreTo):
+ (WebCore::InternalSettings::setSyncXHRInDocumentsEnabled):
+ (WebCore):
+ * testing/InternalSettings.h:
+ (InternalSettings):
+ * testing/InternalSettings.idl:
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::open):
+
2012-05-25 Kinuko Yasuda <[email protected]>
[chromium] Deprecate FileUtilities::getFileSize and getFileModifiedTime in favor of getFileMetadata
Modified: trunk/Source/WebCore/page/Settings.cpp (118598 => 118599)
--- trunk/Source/WebCore/page/Settings.cpp 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/Source/WebCore/page/Settings.cpp 2012-05-26 02:05:47 UTC (rev 118599)
@@ -272,6 +272,7 @@
, m_requestAnimationFrameEnabled(true)
, m_needsDidFinishLoadOrderQuirk(false)
, m_fixedPositionCreatesStackingContext(false)
+ , m_syncXHRInDocumentsEnabled(true)
, m_loadsImagesAutomaticallyTimer(this, &Settings::loadsImagesAutomaticallyTimerFired)
, m_incrementalRenderingSuppressionTimeoutInSeconds(defaultIncrementalRenderingSuppressionTimeoutInSeconds)
{
Modified: trunk/Source/WebCore/page/Settings.h (118598 => 118599)
--- trunk/Source/WebCore/page/Settings.h 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/Source/WebCore/page/Settings.h 2012-05-26 02:05:47 UTC (rev 118599)
@@ -581,6 +581,9 @@
void setFixedPositionCreatesStackingContext(bool creates) { m_fixedPositionCreatesStackingContext = creates; }
bool fixedPositionCreatesStackingContext() const { return m_fixedPositionCreatesStackingContext; }
+ void setSyncXHRInDocumentsEnabled(bool enabled) { m_syncXHRInDocumentsEnabled = enabled; }
+ bool syncXHRInDocumentsEnabled() const { return m_syncXHRInDocumentsEnabled; }
+
#if USE(JSC)
static void setShouldRespectPriorityInCSSAttributeSetters(bool);
static bool shouldRespectPriorityInCSSAttributeSetters();
@@ -753,6 +756,7 @@
bool m_needsDidFinishLoadOrderQuirk : 1;
bool m_fixedPositionCreatesStackingContext : 1;
+ bool m_syncXHRInDocumentsEnabled : 1;
Timer<Settings> m_loadsImagesAutomaticallyTimer;
void loadsImagesAutomaticallyTimerFired(Timer<Settings>*);
Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (118598 => 118599)
--- trunk/Source/WebCore/testing/InternalSettings.cpp 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp 2012-05-26 02:05:47 UTC (rev 118599)
@@ -100,6 +100,7 @@
#endif
, m_originalEditingBehavior(settings()->editingBehaviorType())
, m_originalFixedPositionCreatesStackingContext(settings()->fixedPositionCreatesStackingContext())
+ , m_originalSyncXHRInDocumentsEnabled(settings()->syncXHRInDocumentsEnabled())
{
}
@@ -113,6 +114,7 @@
#endif
settings->setEditingBehaviorType(m_originalEditingBehavior);
settings->setFixedPositionCreatesStackingContext(m_originalFixedPositionCreatesStackingContext);
+ settings->setSyncXHRInDocumentsEnabled(m_originalSyncXHRInDocumentsEnabled);
}
Settings* InternalSettings::settings() const
@@ -352,4 +354,10 @@
settings()->setFixedPositionCreatesStackingContext(creates);
}
+void InternalSettings::setSyncXHRInDocumentsEnabled(bool creates, ExceptionCode& ec)
+{
+ InternalSettingsGuardForFrameView();
+ settings()->setSyncXHRInDocumentsEnabled(creates);
}
+
+}
Modified: trunk/Source/WebCore/testing/InternalSettings.h (118598 => 118599)
--- trunk/Source/WebCore/testing/InternalSettings.h 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/Source/WebCore/testing/InternalSettings.h 2012-05-26 02:05:47 UTC (rev 118599)
@@ -77,6 +77,7 @@
void setMediaPlaybackRequiresUserGesture(bool, ExceptionCode&);
void setEditingBehavior(const String&, ExceptionCode&);
void setFixedPositionCreatesStackingContext(bool, ExceptionCode&);
+ void setSyncXHRInDocumentsEnabled(bool, ExceptionCode&);
void restoreTo(Settings*);
@@ -95,6 +96,7 @@
#endif
EditingBehaviorType m_originalEditingBehavior;
bool m_originalFixedPositionCreatesStackingContext;
+ bool m_originalSyncXHRInDocumentsEnabled;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/testing/InternalSettings.idl (118598 => 118599)
--- trunk/Source/WebCore/testing/InternalSettings.idl 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/Source/WebCore/testing/InternalSettings.idl 2012-05-26 02:05:47 UTC (rev 118599)
@@ -55,6 +55,7 @@
void setMediaPlaybackRequiresUserGesture(in boolean enabled) raises(DOMException);
void setEditingBehavior(in DOMString behavior) raises(DOMException);
void setFixedPositionCreatesStackingContext(in boolean creates) raises(DOMException);
+ void setSyncXHRInDocumentsEnabled(in boolean enabled) raises(DOMException);
};
}
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (118598 => 118599)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2012-05-26 02:05:47 UTC (rev 118599)
@@ -484,14 +484,22 @@
return;
}
- // Newer functionality is not available to synchronous requests in window contexts, as a spec-mandated
- // attempt to discourage synchronous XHR use. responseType is one such piece of functionality.
- // We'll only disable this functionality for HTTP(S) requests since sync requests for local protocols
- // such as file: and data: still make sense to allow.
- if (!async && scriptExecutionContext()->isDocument() && url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDefault) {
- logConsoleError(scriptExecutionContext(), "Synchronous HTTP(S) requests made from the window context cannot have XMLHttpRequest.responseType set.");
- ec = INVALID_ACCESS_ERR;
- return;
+ if (!async && scriptExecutionContext()->isDocument()) {
+ if (!document()->settings()->syncXHRInDocumentsEnabled()) {
+ logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpRequests cannot be made in the current window context.");
+ ec = INVALID_ACCESS_ERR;
+ return;
+ }
+
+ // Newer functionality is not available to synchronous requests in window contexts, as a spec-mandated
+ // attempt to discourage synchronous XHR use. responseType is one such piece of functionality.
+ // We'll only disable this functionality for HTTP(S) requests since sync requests for local protocols
+ // such as file: and data: still make sense to allow.
+ if (url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDefault) {
+ logConsoleError(scriptExecutionContext(), "Synchronous HTTP(S) requests made from the window context cannot have XMLHttpRequest.responseType set.");
+ ec = INVALID_ACCESS_ERR;
+ return;
+ }
}
m_method = uppercaseKnownHTTPMethod(method);
Modified: trunk/Source/WebKit/chromium/ChangeLog (118598 => 118599)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-05-26 02:05:47 UTC (rev 118599)
@@ -1,3 +1,22 @@
+2012-05-25 Mihai Parparita <[email protected]>
+
+ Allow synchronous XHRs to be disabled in documents
+ https://bugs.webkit.org/show_bug.cgi?id=87540
+
+ Reviewed by Eric Seidel.
+
+ Synchronous XMLHttpRequests are a problematic API, since they result
+ in blocked UI threads. Some clients may wish to always disable them;
+ give them a setting to do so (see also r103629 for other cases where
+ synchronous XHRs are disabled).
+
+ * public/WebSettings.h:
+ * src/WebSettingsImpl.cpp:
+ (WebKit::WebSettingsImpl::setSyncXHRInDocumentsEnabled):
+ (WebKit):
+ * src/WebSettingsImpl.h:
+ (WebSettingsImpl):
+
2012-05-25 Kinuko Yasuda <[email protected]>
[chromium] Deprecate FileUtilities::getFileSize and getFileModifiedTime in favor of getFileMetadata
Modified: trunk/Source/WebKit/chromium/public/WebSettings.h (118598 => 118599)
--- trunk/Source/WebKit/chromium/public/WebSettings.h 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/Source/WebKit/chromium/public/WebSettings.h 2012-05-26 02:05:47 UTC (rev 118599)
@@ -153,8 +153,8 @@
virtual void setDefaultTileSize(WebSize) = 0;
virtual void setMaxUntiledLayerSize(WebSize) = 0;
virtual void setFixedPositionCreatesStackingContext(bool) = 0;
+ virtual void setSyncXHRInDocumentsEnabled(bool) = 0;
-
protected:
~WebSettings() { }
};
Modified: trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp (118598 => 118599)
--- trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp 2012-05-26 02:05:47 UTC (rev 118599)
@@ -611,4 +611,10 @@
m_maxUntiledLayerSize = size;
}
+void WebSettingsImpl::setSyncXHRInDocumentsEnabled(bool enabled)
+{
+ m_settings->setSyncXHRInDocumentsEnabled(enabled);
+}
+
+
} // namespace WebKit
Modified: trunk/Source/WebKit/chromium/src/WebSettingsImpl.h (118598 => 118599)
--- trunk/Source/WebKit/chromium/src/WebSettingsImpl.h 2012-05-26 01:53:06 UTC (rev 118598)
+++ trunk/Source/WebKit/chromium/src/WebSettingsImpl.h 2012-05-26 02:05:47 UTC (rev 118599)
@@ -147,6 +147,7 @@
virtual void setViewportEnabled(bool);
virtual void setMediaPlaybackRequiresUserGesture(bool);
virtual bool viewportEnabled() const { return m_viewportEnabled; }
+ virtual void setSyncXHRInDocumentsEnabled(bool);
bool showFPSCounter() const { return m_showFPSCounter; }
bool showPlatformLayerTree() const { return m_showPlatformLayerTree; }