- Revision
- 152498
- Author
- [email protected]
- Date
- 2013-07-09 10:48:01 -0700 (Tue, 09 Jul 2013)
Log Message
DumpRenderTree should stop sending unsupported URLs to NSWorkspace
https://bugs.webkit.org/show_bug.cgi?id=118514
<rdar://problem/13686836>
Reviewed by Sam Weinig.
Add a new default policy delegate and override decidePolicyForNavigationAction: to not pass unhandled URLs to NSWorkspace.
* DumpRenderTree/DefaultPolicyDelegate.h: Added.
* DumpRenderTree/DefaultPolicyDelegate.m: Added.
(-[DefaultPolicyDelegate webView:decidePolicyForNavigationAction:request:frame:decisionListener:]):
* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
Add DefaultPolicyDelegate.h and DefaultPolicyDelegate.m.
* DumpRenderTree/mac/DumpRenderTree.mm:
(allocateGlobalControllers):
Allocate a DefaultPolicyDelegate object.
(resetWebViewToConsistentStateBeforeTesting):
Set the policy delegate to the default policy delegate.
* DumpRenderTree/mac/DumpRenderTreeMac.h:
Declare the defaultPolicyDelegate object.
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setCustomPolicyDelegate):
Set the policy delegate to the default delegate if setDelegate is false.
Modified Paths
Added Paths
Diff
Modified: trunk/Tools/ChangeLog (152497 => 152498)
--- trunk/Tools/ChangeLog 2013-07-09 17:34:51 UTC (rev 152497)
+++ trunk/Tools/ChangeLog 2013-07-09 17:48:01 UTC (rev 152498)
@@ -1,3 +1,33 @@
+2013-07-09 Anders Carlsson <[email protected]>
+
+ DumpRenderTree should stop sending unsupported URLs to NSWorkspace
+ https://bugs.webkit.org/show_bug.cgi?id=118514
+ <rdar://problem/13686836>
+
+ Reviewed by Sam Weinig.
+
+ Add a new default policy delegate and override decidePolicyForNavigationAction: to not pass unhandled URLs to NSWorkspace.
+
+ * DumpRenderTree/DefaultPolicyDelegate.h: Added.
+ * DumpRenderTree/DefaultPolicyDelegate.m: Added.
+ (-[DefaultPolicyDelegate webView:decidePolicyForNavigationAction:request:frame:decisionListener:]):
+ * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+ Add DefaultPolicyDelegate.h and DefaultPolicyDelegate.m.
+
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (allocateGlobalControllers):
+ Allocate a DefaultPolicyDelegate object.
+
+ (resetWebViewToConsistentStateBeforeTesting):
+ Set the policy delegate to the default policy delegate.
+
+ * DumpRenderTree/mac/DumpRenderTreeMac.h:
+ Declare the defaultPolicyDelegate object.
+
+ * DumpRenderTree/mac/TestRunnerMac.mm:
+ (TestRunner::setCustomPolicyDelegate):
+ Set the policy delegate to the default delegate if setDelegate is false.
+
2013-07-08 Zan Dobersek <[email protected]>
KURL unit test fixture class should have a meaningful name
Added: trunk/Tools/DumpRenderTree/DefaultPolicyDelegate.h (0 => 152498)
--- trunk/Tools/DumpRenderTree/DefaultPolicyDelegate.h (rev 0)
+++ trunk/Tools/DumpRenderTree/DefaultPolicyDelegate.h 2013-07-09 17:48:01 UTC (rev 152498)
@@ -0,0 +1,13 @@
+//
+// DefaultPolicyDelegate.h
+// DumpRenderTree
+//
+// Created by Anders Carlsson on 7/9/13.
+//
+//
+
+#import <WebKit/WebDefaultPolicyDelegate.h>
+
+@interface DefaultPolicyDelegate : WebDefaultPolicyDelegate
+
+@end
Added: trunk/Tools/DumpRenderTree/DefaultPolicyDelegate.m (0 => 152498)
--- trunk/Tools/DumpRenderTree/DefaultPolicyDelegate.m (rev 0)
+++ trunk/Tools/DumpRenderTree/DefaultPolicyDelegate.m 2013-07-09 17:48:01 UTC (rev 152498)
@@ -0,0 +1,34 @@
+//
+// DefaultPolicyDelegate.m
+// DumpRenderTree
+//
+// Created by Anders Carlsson on 7/9/13.
+//
+//
+
+#import "DefaultPolicyDelegate.h"
+
+#import <WebKit/WebPolicyDelegatePrivate.h>
+#import <WebKit/WebViewPrivate.h>
+
+@implementation DefaultPolicyDelegate
+
+- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id <WebPolicyDecisionListener>)listener
+{
+ if ([WebView _canHandleRequest:request]) {
+ [listener use];
+ return;
+ }
+
+ WebNavigationType navType = [[actionInformation objectForKey:WebActionNavigationTypeKey] intValue];
+ if (navType == WebNavigationTypePlugInRequest) {
+ [listener use];
+ return;
+ }
+
+ // The default WebKit policy delegate passes the URL along to -[NSWorkspace openURL:] here,
+ // but we don't want to do that so we just ignore the navigation completely.
+ [listener ignore];
+}
+
+@end
Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (152497 => 152498)
--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj 2013-07-09 17:34:51 UTC (rev 152497)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj 2013-07-09 17:48:01 UTC (rev 152498)
@@ -39,6 +39,8 @@
1A215A8211F2609C008AD0F5 /* PluginTest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A215A8011F2609C008AD0F5 /* PluginTest.h */; };
1A215BE711F27658008AD0F5 /* DocumentOpenInDestroyStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A215A7511F26072008AD0F5 /* DocumentOpenInDestroyStream.cpp */; };
1A24BAA9120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */; };
+ 1A2FB84E178C80930059FD96 /* DefaultPolicyDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2FB84C178C80920059FD96 /* DefaultPolicyDelegate.h */; };
+ 1A2FB84F178C80930059FD96 /* DefaultPolicyDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A2FB84D178C80930059FD96 /* DefaultPolicyDelegate.m */; };
1A31EB3813466AC100017372 /* ConvertPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A31EB3713466AC100017372 /* ConvertPoint.cpp */; };
1A3E28AA1311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */; };
1A4CCD4F171375A300981040 /* ToStringAndValueOfObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A4CCD4E171375A300981040 /* ToStringAndValueOfObject.cpp */; };
@@ -254,6 +256,8 @@
1A215A7F11F2609C008AD0F5 /* PluginTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginTest.cpp; sourceTree = "<group>"; };
1A215A8011F2609C008AD0F5 /* PluginTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginTest.h; sourceTree = "<group>"; };
1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRuntimeObjectFromDestroyedPlugin.cpp; sourceTree = "<group>"; };
+ 1A2FB84C178C80920059FD96 /* DefaultPolicyDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultPolicyDelegate.h; sourceTree = "<group>"; };
+ 1A2FB84D178C80930059FD96 /* DefaultPolicyDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DefaultPolicyDelegate.m; sourceTree = "<group>"; };
1A31EB3713466AC100017372 /* ConvertPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertPoint.cpp; sourceTree = "<group>"; };
1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURLDestroyingPlugin.cpp; sourceTree = "<group>"; };
1A4CCD4E171375A300981040 /* ToStringAndValueOfObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ToStringAndValueOfObject.cpp; sourceTree = "<group>"; };
@@ -446,6 +450,8 @@
08FB7794FE84155DC02AAC07 /* DumpRenderTree */ = {
isa = PBXGroup;
children = (
+ 1A2FB84C178C80920059FD96 /* DefaultPolicyDelegate.h */,
+ 1A2FB84D178C80930059FD96 /* DefaultPolicyDelegate.m */,
9830F31E15C81181005AB206 /* DumpRenderTreeCommon.cpp */,
32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */,
1422A2750AF6F4BD00E1A883 /* Delegates */,
@@ -756,6 +762,7 @@
BCB284C70CFA83C4007E533E /* PixelDumpSupport.h in Headers */,
BCB284D00CFA83CC007E533E /* PixelDumpSupportCG.h in Headers */,
BCA18B650C9B08C200114369 /* PolicyDelegate.h in Headers */,
+ 1A2FB84E178C80930059FD96 /* DefaultPolicyDelegate.h in Headers */,
BCA18B670C9B08C200114369 /* ResourceLoadDelegate.h in Headers */,
3A5626CC131CA036002BE6D9 /* StorageTrackerDelegate.h in Headers */,
BC0131DB0C9772010087317D /* TestRunner.h in Headers */,
@@ -1002,6 +1009,7 @@
BC0131DA0C9772010087317D /* TestRunner.cpp in Sources */,
BCA18B240C9B014B00114369 /* TestRunnerMac.mm in Sources */,
BCA18B490C9B02C400114369 /* TextInputController.m in Sources */,
+ 1A2FB84F178C80930059FD96 /* DefaultPolicyDelegate.m in Sources */,
BCA18B6A0C9B08C200114369 /* UIDelegate.mm in Sources */,
4437730E125CBC3600AAE02C /* WebArchiveDumpSupport.cpp in Sources */,
440590711268453800CFD48D /* WebArchiveDumpSupportMac.mm in Sources */,
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (152497 => 152498)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2013-07-09 17:34:51 UTC (rev 152497)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2013-07-09 17:48:01 UTC (rev 152498)
@@ -32,6 +32,7 @@
#import "AccessibilityController.h"
#import "CheckedMalloc.h"
+#import "DefaultPolicyDelegate.h"
#import "DumpRenderTreeDraggingInfo.h"
#import "DumpRenderTreePasteboard.h"
#import "DumpRenderTreeWindow.h"
@@ -148,6 +149,7 @@
static ResourceLoadDelegate *resourceLoadDelegate;
static HistoryDelegate *historyDelegate;
PolicyDelegate *policyDelegate;
+DefaultPolicyDelegate *defaultPolicyDelegate;
StorageTrackerDelegate *storageDelegate;
static int dumpPixelsForAllTests = NO;
@@ -784,6 +786,7 @@
policyDelegate = [[PolicyDelegate alloc] init];
historyDelegate = [[HistoryDelegate alloc] init];
storageDelegate = [[StorageTrackerDelegate alloc] init];
+ defaultPolicyDelegate = [[DefaultPolicyDelegate alloc] init];
}
// ObjC++ doens't seem to let me pass NSObject*& sadly.
@@ -1284,7 +1287,7 @@
[webView _scaleWebView:1.0 atOrigin:NSZeroPoint];
[webView _setCustomBackingScaleFactor:0];
[webView setTabKeyCyclesThroughElements:YES];
- [webView setPolicyDelegate:nil];
+ [webView setPolicyDelegate:defaultPolicyDelegate];
[policyDelegate setPermissive:NO];
[policyDelegate setControllerToNotifyDone:0];
[frameLoadDelegate resetToConsistentState];
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTreeMac.h (152497 => 152498)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTreeMac.h 2013-07-09 17:34:51 UTC (rev 152497)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTreeMac.h 2013-07-09 17:48:01 UTC (rev 152498)
@@ -32,6 +32,7 @@
#include <CoreFoundation/CoreFoundation.h>
#ifdef __OBJC__
+@class DefaultPolicyDelegate;
@class DumpRenderTreeDraggingInfo;
@class NavigationController;
@class PolicyDelegate;
@@ -40,6 +41,7 @@
@class WebScriptWorld;
@class WebView;
#else
+class DefaultPolicyDelegate;
class DumpRenderTreeDraggingInfo;
class NavigationController;
class PolicyDelegate;
@@ -57,6 +59,7 @@
extern NavigationController* gNavigationController;
extern PolicyDelegate* policyDelegate;
extern StorageTrackerDelegate* storageDelegate;
+extern DefaultPolicyDelegate *defaultPolicyDelegate;
void setWaitToDumpWatchdog(CFRunLoopTimerRef);
bool shouldSetWaitToDumpWatchdog();
Modified: trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm (152497 => 152498)
--- trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm 2013-07-09 17:34:51 UTC (rev 152497)
+++ trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm 2013-07-09 17:48:01 UTC (rev 152498)
@@ -30,6 +30,7 @@
#import "DumpRenderTree.h"
#import "TestRunner.h"
+#import "DefaultPolicyDelegate.h"
#import "EditingDelegate.h"
#import "MockGeolocationProvider.h"
#import "MockWebNotificationProvider.h"
@@ -407,11 +408,13 @@
void TestRunner::setCustomPolicyDelegate(bool setDelegate, bool permissive)
{
- if (setDelegate) {
- [policyDelegate setPermissive:permissive];
- [[mainFrame webView] setPolicyDelegate:policyDelegate];
- } else
- [[mainFrame webView] setPolicyDelegate:nil];
+ if (!setDelegate) {
+ [[mainFrame webView] setPolicyDelegate:defaultPolicyDelegate];
+ return;
+ }
+
+ [policyDelegate setPermissive:permissive];
+ [[mainFrame webView] setPolicyDelegate:policyDelegate];
}
void TestRunner::setDatabaseQuota(unsigned long long quota)