Skip to content
Permalink
Browse files
WebCore: Using the decidePolicyForMIMEType delegate message in an asy…
…nchronous manner does not work

https://bugs.webkit.org/show_bug.cgi?id=48014
<rdar://problem/8202716>

Reviewed by Adam Barth and Darin Adler.

* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::continueAfterContentPolicy):
Resume loading.

(WebCore::MainResourceLoader::didReceiveResponse):
Defer loading until we hear back from the policy client.

WebKitTools: Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work
https://bugs.webkit.org/show_bug.cgi?id=48014
<rdar://problem/8202716>

Reviewed by Adam Barth and Darin Adler.

* DumpRenderTree/LayoutTestController.cpp:
(setCustomPolicyDelegateCallback):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

* DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

* DumpRenderTree/mac/LayoutTestControllerMac.mm:
(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

* DumpRenderTree/mac/PolicyDelegate.h:
* DumpRenderTree/mac/PolicyDelegate.mm:
(-[PolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]):
If _callIgnoreInDecidePolicyForMIMETypeAfterOneSecond is true, call [listener ignore] after one second.

(-[PolicyDelegate setCallIgnoreInDecidePolicyForMIMETypeAfterOneSecond:]):
Update _callIgnoreInDecidePolicyForMIMETypeAfterOneSecond.

* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

* DumpRenderTree/wx/LayoutTestControllerWx.cpp:
(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

LayoutTests: Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work
https://bugs.webkit.org/show_bug.cgi?id=48014
<rdar://problem/8202716>

Reviewed by Adam Barth and Darin Adler.

Add tests and update the skipped list.

* fast/loader/decide-policy-for-mime-type-async-expected.txt: Added.
* fast/loader/decide-policy-for-mime-type-async.html: Added.
* platform/gtk/Skipped:
* platform/mac-wk2/Skipped:
* platform/qt/Skipped:
* platform/qt-wk2/Skipped:
* platform/win/Skipped:

Canonical link: https://commits.webkit.org/60906@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70367 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Oct 22, 2010
1 parent 9015d3a commit 96e65aa4969ace1acda1a7d22071a2ae3f276e4d
Showing 20 changed files with 169 additions and 15 deletions.
@@ -1,3 +1,21 @@
2010-10-20 Anders Carlsson <andersca@apple.com>

Reviewed by Adam Barth and Darin Adler.

Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work
https://bugs.webkit.org/show_bug.cgi?id=48014
<rdar://problem/8202716>

Add tests and update the skipped list.

* fast/loader/decide-policy-for-mime-type-async-expected.txt: Added.
* fast/loader/decide-policy-for-mime-type-async.html: Added.
* platform/gtk/Skipped:
* platform/mac-wk2/Skipped:
* platform/qt/Skipped:
* platform/qt-wk2/Skipped:
* platform/win/Skipped:

2010-10-22 Dimitri Glazkov <dglazkov@chromium.org>

[Chromium/DRT] Update layout test expectations to match reality.
@@ -0,0 +1,5 @@
Policy delegate: attempt to load data:text/html,Hello,%20I%20am%20a%20subframe! with navigation type 'other'
Test for Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work. If the test passes, you should see the word "PASSED" below.

PASSED

@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.setCustomPolicyDelegate(true, true, true);
}

window.onload = function() {
var result = document.getElementById('result')
var frame = document.getElementById('frame')
if (!window.layoutTestController) {
result.innerText = "This test can only be run in DumpRenderTree.";
return;
}

// We shouldn't have any text in the frame since the load was ignored.
if (!frame.contentDocument.documentElement.innerText)
result.innerText = "PASSED";
}
</script>
</head>
<body>
<p>Test for <a href="http://webkit.org/b/48014">Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work</a>. If the test passes, you should see the word "PASSED" below.</p>
<div id=result>FAILED</div>
<iframe id="frame" src="data:text/html,Hello, I am a subframe!"></iframe>
</body>
</html>
@@ -1147,6 +1147,7 @@ fast/forms/textfield-onchange-deletion.html
fast/history/history_reload.html
fast/history/window-open.html
fast/html/tab-order.html
fast/loader/decide-policy-for-mime-type-async.html
fast/loader/main-document-url-for-non-http-loads.html
fast/loader/onload-policy-ignore-for-frame.html
fast/loader/policy-delegate-action-hit-test-zoomed.html
@@ -1524,6 +1524,7 @@ fast/dom/Geolocation/timeout-zero.html

# WebKitTestRunner needs layoutTestController.setCustomPolicyDelegate
# <https://bugs.webkit.org/show_bug.cgi?id=42546>
fast/loader/decide-policy-for-mime-type-async.html
fast/loader/javascript-url-hierarchical-execution.html
fast/loader/onload-policy-ignore-for-frame.html
fast/loader/reload-policy-delegate.html
@@ -1472,6 +1472,7 @@ fast/dom/Geolocation/timeout-zero.html

# WebKitTestRunner needs layoutTestController.setCustomPolicyDelegate
# <https://bugs.webkit.org/show_bug.cgi?id=42546>
fast/loader/decide-policy-for-mime-type-async.html
fast/loader/javascript-url-hierarchical-execution.html
fast/loader/onload-policy-ignore-for-frame.html
fast/loader/reload-policy-delegate.html
@@ -100,6 +100,7 @@ accessibility
transforms/3d
compositing

fast/loader/decide-policy-for-mime-type-async.html
fast/loader/subframe-navigate-during-main-frame-load.html

# Hyphenation is not implemented yet.
@@ -1041,3 +1041,6 @@ fast/events/click-focus-control.html

# Requires WebP support.
fast/images/webp-image-decoding.html

# Needs ovelroad of setCustomPolicyDelegate
fast/loader/decide-policy-for-mime-type-async.html
@@ -1,3 +1,18 @@
2010-10-20 Anders Carlsson <andersca@apple.com>

Reviewed by Adam Barth and Darin Adler.

Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work
https://bugs.webkit.org/show_bug.cgi?id=48014
<rdar://problem/8202716>

* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::continueAfterContentPolicy):
Resume loading.

(WebCore::MainResourceLoader::didReceiveResponse):
Defer loading until we hear back from the policy client.

2010-10-22 James Robinson <jamesr@chromium.org>

Reviewed by Dimitri Glazkov.
@@ -57,6 +57,7 @@ MainResourceLoader::MainResourceLoader(Frame* frame)
, m_dataLoadTimer(this, &MainResourceLoader::handleDataLoadNow)
, m_loadingMultipartContent(false)
, m_waitingForContentPolicy(false)
, m_deferLoadingCount(0)
{
}

@@ -231,7 +232,10 @@ void MainResourceLoader::continueAfterContentPolicy(PolicyAction contentPolicy,
{
KURL url = request().url();
const String& mimeType = r.mimeType();


// This is balanced by a call to setDefersLoading(true) in didReceiveResponse.
setDefersLoading(false);

switch (contentPolicy) {
case PolicyUse: {
// Prevent remote web archives from loading because they can claim to be from any domain and thus avoid cross-domain security checks (4120255).
@@ -373,6 +377,10 @@ void MainResourceLoader::didReceiveResponse(const ResourceResponse& r)
// reference to this object; one example of this is 3266216.
RefPtr<MainResourceLoader> protect(this);

// Defer loading while we're waiting for a response.
// This is balanced by a setDefersLoading(false) call in continueAfterContentPolicy.
setDefersLoading(true);

m_documentLoader->setResponse(r);

m_response = r;
@@ -595,6 +603,16 @@ bool MainResourceLoader::load(const ResourceRequest& r, const SubstituteData& su

void MainResourceLoader::setDefersLoading(bool defers)
{
if (defers) {
m_deferLoadingCount++;
if (m_deferLoadingCount > 1)
return;
} else {
ASSERT(m_deferLoadingCount);
m_deferLoadingCount--;
if (m_deferLoadingCount > 0)
return;
}
ResourceLoader::setDefersLoading(defers);

if (defers) {
@@ -108,6 +108,7 @@ namespace WebCore {
bool m_loadingMultipartContent;
bool m_waitingForContentPolicy;
double m_timeOfLastDataReceived;
unsigned m_deferLoadingCount;
};

}
@@ -1,3 +1,39 @@
2010-10-20 Anders Carlsson <andersca@apple.com>

Reviewed by Adam Barth and Darin Adler.

Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work
https://bugs.webkit.org/show_bug.cgi?id=48014
<rdar://problem/8202716>

* DumpRenderTree/LayoutTestController.cpp:
(setCustomPolicyDelegateCallback):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

* DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

* DumpRenderTree/mac/LayoutTestControllerMac.mm:
(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

* DumpRenderTree/mac/PolicyDelegate.h:
* DumpRenderTree/mac/PolicyDelegate.mm:
(-[PolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]):
If _callIgnoreInDecidePolicyForMIMETypeAfterOneSecond is true, call [listener ignore] after one second.

(-[PolicyDelegate setCallIgnoreInDecidePolicyForMIMETypeAfterOneSecond:]):
Update _callIgnoreInDecidePolicyForMIMETypeAfterOneSecond.

* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

* DumpRenderTree/wx/LayoutTestControllerWx.cpp:
(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

2010-10-22 Sam Weinig <sam@webkit.org>

Reviewed by Anders Carlsson.
@@ -971,8 +971,12 @@ static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObject
if (argumentCount >= 2)
permissive = JSValueToBoolean(context, arguments[1]);

bool callIgnoreInDecidePolicyForMIMETypeAfterOneSecond = false;
if (argumentCount >= 3)
callIgnoreInDecidePolicyForMIMETypeAfterOneSecond = JSValueToBoolean(context, arguments[2]);

LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive);
controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive, callIgnoreInDecidePolicyForMIMETypeAfterOneSecond);

return JSValueMakeUndefined(context);
}
@@ -84,7 +84,7 @@ class LayoutTestController : public RefCounted<LayoutTestController> {
void setApplicationCacheOriginQuota(unsigned long long quota);
void setAuthorAndUserStylesEnabled(bool);
void setCacheModel(int);
void setCustomPolicyDelegate(bool setDelegate, bool permissive);
void setCustomPolicyDelegate(bool setDelegate, bool permissive, bool callIgnoreInDecidePolicyForMIMETypeAfterOneSecond);
void setDatabaseQuota(unsigned long long quota);
void setDomainRelaxationForbiddenForURLScheme(bool forbidden, JSStringRef scheme);
void setIconDatabaseEnabled(bool iconDatabaseEnabled);
@@ -268,7 +268,7 @@ void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies)
#endif
}

void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive, bool callIgnoreInDecidePolicyForMIMETypeAfterOneSecond)
{
// FIXME: implement
}
@@ -319,9 +319,10 @@ - (NSInteger)tag
[[[mainFrame webView] preferences] setAuthorAndUserStylesEnabled:flag];
}

void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive, bool callIgnoreInDecidePolicyForMIMETypeAfterOneSecond)
{
if (setDelegate) {
[policyDelegate setCallIgnoreInDecidePolicyForMIMETypeAfterOneSecond:callIgnoreInDecidePolicyForMIMETypeAfterOneSecond];
[policyDelegate setPermissive:permissive];
[[mainFrame webView] setPolicyDelegate:policyDelegate];
} else
@@ -31,11 +31,13 @@
class LayoutTestController;

@interface PolicyDelegate : NSObject {
BOOL permissiveDelegate;
LayoutTestController* controllerToNotifyDone;
BOOL _permissiveDelegate;
BOOL _callIgnoreInDecidePolicyForMIMETypeAfterOneSecond;
LayoutTestController* _controllerToNotifyDone;
}

- (void)setPermissive:(BOOL)permissive;
- (void)setCallIgnoreInDecidePolicyForMIMETypeAfterOneSecond:(BOOL)callIgnoreInDecidePolicyForMIMETypeAfterOneSecond;
- (void)setControllerToNotifyDone:(LayoutTestController*)controller;

@end
@@ -83,31 +83,49 @@ - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary

printf("%s\n", [message UTF8String]);

if (permissiveDelegate)
if (_permissiveDelegate)
[listener use];
else
[listener ignore];

if (controllerToNotifyDone) {
controllerToNotifyDone->notifyDone();
controllerToNotifyDone = 0;
if (_controllerToNotifyDone) {
_controllerToNotifyDone->notifyDone();
_controllerToNotifyDone = 0;
}
}

- (void)webView:(WebView *)webView decidePolicyForMIMEType:(NSString *)type
request:(NSURLRequest *)request
frame:(WebFrame *)frame
decisionListener:(id<WebPolicyDecisionListener>)listener
{
if (!_callIgnoreInDecidePolicyForMIMETypeAfterOneSecond) {
[listener use];
return;
}

[(NSObject *)listener performSelector:@selector(ignore) withObject:nil afterDelay:1.0];
}

- (void)webView:(WebView *)webView unableToImplementPolicyWithError:(NSError *)error frame:(WebFrame *)frame
{
NSString *message = [NSString stringWithFormat:@"Policy delegate: unable to implement policy with error domain '%@', error code %d, in frame '%@'", [error domain], [error code], [frame name]];
printf("%s\n", [message UTF8String]);
}

- (void)setCallIgnoreInDecidePolicyForMIMETypeAfterOneSecond:(BOOL)callIgnoreInDecidePolicyForMIMETypeAfterOneSecond
{
_callIgnoreInDecidePolicyForMIMETypeAfterOneSecond = callIgnoreInDecidePolicyForMIMETypeAfterOneSecond;
}

- (void)setPermissive:(BOOL)permissive
{
permissiveDelegate = permissive;
_permissiveDelegate = permissive;
}

- (void)setControllerToNotifyDone:(LayoutTestController*)controller
{
controllerToNotifyDone = controller;
_controllerToNotifyDone = controller;
}

@end
@@ -368,7 +368,7 @@ void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
prefsPrivate->setAuthorAndUserStylesEnabled(flag);
}

void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive , bool callIgnoreInDecidePolicyForMIMETypeAfterOneSecond)
{
COMPtr<IWebView> webView;
if (FAILED(frame->webView(&webView)))
@@ -107,7 +107,7 @@ void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies)
// FIXME: Implement this (and restore the default value before running each test in DumpRenderTree.cpp).
}

void LayoutTestController::setCustomPolicyDelegate(bool, bool)
void LayoutTestController::setCustomPolicyDelegate(bool, bool, bool)
{
// FIXME: implement
}

0 comments on commit 96e65aa

Please sign in to comment.