From: ap@apple.com Date: Thu, 19 Jan 2012 01:54:40 +0000 (+0000) Subject: Need infrastructure to test Content-Disposition filename encoding support X-Git-Tag: 070512121124~15039 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8630180581b067104722c46f0bc1033d0e7da22e;p=profile%2Fivi%2Fwebkit-efl.git Need infrastructure to test Content-Disposition filename encoding support https://bugs.webkit.org/show_bug.cgi?id=76572 Reviewed by Sam Weinig. Made policy delegate log suggested file name when resource has Content-Disposition: attachment. WebKitTestRunner does not have a policy delegate yet, bug 42546. * DumpRenderTree/mac/PolicyDelegate.mm: (dispositionTypeFromContentDispositionHeader): (-[PolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105369 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 851afd9..e385174 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,25 @@ +2012-01-18 Alexey Proskuryakov + + Need infrastructure to test Content-Disposition filename encoding support + https://bugs.webkit.org/show_bug.cgi?id=76572 + + + Reviewed by Sam Weinig. + + Added a very simple test just to check that it works. + + * http/tests/download: Added. + * http/tests/download/basic-ascii-expected.txt: Added. + * http/tests/download/basic-ascii.html: Added. + * http/tests/download/resources: Added. + * http/tests/download/resources/basic-ascii.php: Added. + * platform/chromium/test_expectations.txt: + * platform/efl/Skipped: + * platform/gtk/Skipped: + * platform/qt/Skipped: + * platform/win/Skipped: + * platform/wk2/Skipped: + 2012-01-18 James Robinson [chromium] Update a few chromium expectations. diff --git a/LayoutTests/http/tests/download/basic-ascii-expected.txt b/LayoutTests/http/tests/download/basic-ascii-expected.txt new file mode 100644 index 0000000..51e584c --- /dev/null +++ b/LayoutTests/http/tests/download/basic-ascii-expected.txt @@ -0,0 +1,5 @@ +Policy delegate: attempt to load http://127.0.0.1:8000/download/resources/basic-ascii.php with navigation type 'other' +Policy delegate: resource is an attachment, suggested file name 'test file.txt' +Download file name should be "test file.txt". + + diff --git a/LayoutTests/http/tests/download/basic-ascii.html b/LayoutTests/http/tests/download/basic-ascii.html new file mode 100644 index 0000000..ed6bef0 --- /dev/null +++ b/LayoutTests/http/tests/download/basic-ascii.html @@ -0,0 +1,9 @@ + + +

Download file name should be "test file.txt".

+ diff --git a/LayoutTests/http/tests/download/resources/basic-ascii.php b/LayoutTests/http/tests/download/resources/basic-ascii.php new file mode 100755 index 0000000..ffb1e15 --- /dev/null +++ b/LayoutTests/http/tests/download/resources/basic-ascii.php @@ -0,0 +1,6 @@ + + +Test file content. diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt index 461af55..45d3192 100644 --- a/LayoutTests/platform/chromium/test_expectations.txt +++ b/LayoutTests/platform/chromium/test_expectations.txt @@ -3919,3 +3919,6 @@ BUGWK76446 : svg/custom/pointer-events-text.svg = TEXT // RenderSVGRoot now reports a correct size. BUGWK76646 : svg/foreignObject/text-tref-02-b.svg = TEXT + +// Need to implement file name logging. +BUGWK76572 : http/tests/download = FAIL diff --git a/LayoutTests/platform/efl/Skipped b/LayoutTests/platform/efl/Skipped index 1098448..b4b98c5 100644 --- a/LayoutTests/platform/efl/Skipped +++ b/LayoutTests/platform/efl/Skipped @@ -442,6 +442,7 @@ fast/loader/javascript-url-hierarchical-execution.html fast/loader/onload-policy-ignore-for-frame.html fast/loader/policy-delegate-action-hit-test-zoomed.html fast/loader/reload-policy-delegate.html +http/tests/download # EFL's LayoutTestController does not implement setScrollbarPolicy fast/overflow/scrollbar-restored-and-then-locked.html diff --git a/LayoutTests/platform/gtk/Skipped b/LayoutTests/platform/gtk/Skipped index 0f92222..2533f2c 100644 --- a/LayoutTests/platform/gtk/Skipped +++ b/LayoutTests/platform/gtk/Skipped @@ -1628,3 +1628,6 @@ fast/text/international/spaces-combined-in-vertical-text.html # https://bugs.webkit.org/show_bug.cgi?id=76048 fast/text/font-kerning.html + +# Needs custom policy delegate enhancement to log downloads +http/tests/download diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped index 50b5fae..323a980 100644 --- a/LayoutTests/platform/qt/Skipped +++ b/LayoutTests/platform/qt/Skipped @@ -2591,3 +2591,6 @@ http/tests/misc/iframe-invalid-source-crash.html # https://bugs.webkit.org/show_bug.cgi?id=76566 http/tests/inspector/console-resource-errors.html http/tests/inspector/console-cross-origin-iframe-logging.html + +# Needs custom policy delegate enhancement to log downloads +http/tests/download diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped index 2bc1d17..9c2e26d 100644 --- a/LayoutTests/platform/win/Skipped +++ b/LayoutTests/platform/win/Skipped @@ -501,6 +501,7 @@ editing/execCommand/enabling-and-selection-2.html # Needs custom policy delegate enhancement in DRT http/tests/navigation/post-goback-repost-policy.html +http/tests/download # Needs scheduleAsynchronousClick method for EventSender fast/events/popup-blocking-click-in-iframe.html diff --git a/LayoutTests/platform/wk2/Skipped b/LayoutTests/platform/wk2/Skipped index 50c6765..7396f3d 100644 --- a/LayoutTests/platform/wk2/Skipped +++ b/LayoutTests/platform/wk2/Skipped @@ -581,6 +581,7 @@ fast/loader/reload-policy-delegate.html http/tests/misc/policy-delegate-called-twice.html http/tests/misc/redirect-to-external-url.html http/tests/security/feed-urls-from-remote.html +http/tests/download # WebKitTestRunner needs layoutTestController.setDashboardCompatibilityMode # diff --git a/Tools/ChangeLog b/Tools/ChangeLog index e352c61..e81fdad 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,19 @@ +2012-01-18 Alexey Proskuryakov + + Need infrastructure to test Content-Disposition filename encoding support + https://bugs.webkit.org/show_bug.cgi?id=76572 + + + Reviewed by Sam Weinig. + + Made policy delegate log suggested file name when resource has Content-Disposition: attachment. + + WebKitTestRunner does not have a policy delegate yet, bug 42546. + + * DumpRenderTree/mac/PolicyDelegate.mm: + (dispositionTypeFromContentDispositionHeader): + (-[PolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]): + 2012-01-18 Ojan Vafai Fix tests from http://trac.webkit.org/changeset/105332. diff --git a/Tools/DumpRenderTree/mac/PolicyDelegate.mm b/Tools/DumpRenderTree/mac/PolicyDelegate.mm index 6935ea7..d0cfd89 100644 --- a/Tools/DumpRenderTree/mac/PolicyDelegate.mm +++ b/Tools/DumpRenderTree/mac/PolicyDelegate.mm @@ -32,6 +32,7 @@ #import "DumpRenderTree.h" #import "LayoutTestController.h" #import +#import #import #import @@ -100,6 +101,33 @@ printf("%s\n", [message UTF8String]); } +static NSString *dispositionTypeFromContentDispositionHeader(NSString *header) +{ + NSMutableString *result = [[[[header componentsSeparatedByString:@";"] objectAtIndex:0] mutableCopy] autorelease]; + if (result) + CFStringTrimWhitespace((CFMutableStringRef)result); + return result; +} + +- (void)webView:(WebView *)c decidePolicyForMIMEType:(NSString *)type + request:(NSURLRequest *)request + frame:(WebFrame *)frame + decisionListener:(id)listener +{ + NSHTTPURLResponse *HTTPResponse = (NSHTTPURLResponse *)[[frame provisionalDataSource] response]; + if (![HTTPResponse isKindOfClass:[NSHTTPURLResponse class]]) + HTTPResponse = nil; + + NSString *dispositionType = dispositionTypeFromContentDispositionHeader([[HTTPResponse allHeaderFields] objectForKey:@"Content-Disposition"]); + if (dispositionType && [dispositionType compare:@"attachment" options:NSCaseInsensitiveSearch] == NSOrderedSame) { + printf("Policy delegate: resource is an attachment, suggested file name '%s'\n", [[HTTPResponse suggestedFilename] UTF8String]); + [listener ignore]; + return; + } + + [listener use]; +} + - (void)setPermissive:(BOOL)permissive { permissiveDelegate = permissive;