summaryrefslogtreecommitdiff
path: root/Tools/TestWebKitAPI/Tests/mac
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-13 12:51:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-19 20:50:05 +0200
commitd441d6f39bb846989d95bcf5caf387b42414718d (patch)
treee367e64a75991c554930278175d403c072de6bb8 /Tools/TestWebKitAPI/Tests/mac
parent0060b2994c07842f4c59de64b5e3e430525c4b90 (diff)
downloadqtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Tools/TestWebKitAPI/Tests/mac')
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/AcceptsFirstMouse.mm2
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/AttributedString.mm4
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/BackForwardList.mm4
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/CancelLoadFromResourceLoadDelegate.mm6
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/CloseNewWindowInNavigationPolicyDelegate.mm84
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.mm6
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/DOMHTMLTableCellCellAbove.mm77
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/DOMHTMLTableCellElementCellAbove.html30
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/DOMNodeFromJSObject.mm61
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.mm6
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm6
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorOnBack.mm2
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/DynamicDeviceScaleFactor.mm2
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/ElementAtPointInWebFrame.mm73
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/HTMLCollectionNamedItem.mm4
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/HTMLFormCollectionNamedItem.mm4
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm4
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/JSContextBackForwardCache1.html10
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/JSContextBackForwardCache2.html10
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm96
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.mm4
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/MemoryCachePruneWithinResourceLoadDelegate.mm8
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/OpenNewWindow.html7
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm2
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/PublicSuffix.mm79
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/RenderedImageFromDOMRange.mm4
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/SetAndUpdateCacheModel.mm6
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/SetDocumentURI.mm16
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/SimplifyMarkup.mm6
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/StopLoadingFromDidReceiveResponse.html1
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/StopLoadingFromDidReceiveResponse.mm73
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm4
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/WebViewDidCreateJavaScriptContext.mm287
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/WebViewDidRemoveFrameFromHierarchy.mm83
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/WillSendSubmitEvent.mm74
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.mm4
36 files changed, 1097 insertions, 52 deletions
diff --git a/Tools/TestWebKitAPI/Tests/mac/AcceptsFirstMouse.mm b/Tools/TestWebKitAPI/Tests/mac/AcceptsFirstMouse.mm
index bc2f786f8..dec788804 100644
--- a/Tools/TestWebKitAPI/Tests/mac/AcceptsFirstMouse.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/AcceptsFirstMouse.mm
@@ -47,7 +47,7 @@ public:
template <typename View>
void AcceptsFirstMouse::runTest(View view)
{
- RetainPtr<NSWindow> window(AdoptNS, [[NSWindow alloc] initWithContentRect:view.frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+ RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:view.frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
[[window.get() contentView] addSubview:view];
CGFloat viewHeight = view.bounds.size.height;
diff --git a/Tools/TestWebKitAPI/Tests/mac/AttributedString.mm b/Tools/TestWebKitAPI/Tests/mac/AttributedString.mm
index 18cce9c2d..6386cad5f 100644
--- a/Tools/TestWebKitAPI/Tests/mac/AttributedString.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/AttributedString.mm
@@ -52,8 +52,8 @@ static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
TEST(WebKit1, AttributedStringTest)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<AttributedStringTest> testController(AdoptNS, [AttributedStringTest new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<AttributedStringTest> testController = adoptNS([AttributedStringTest new]);
webView.get().frameLoadDelegate = testController.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"attributedStringCustomFont" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
diff --git a/Tools/TestWebKitAPI/Tests/mac/BackForwardList.mm b/Tools/TestWebKitAPI/Tests/mac/BackForwardList.mm
index 098453d18..82ddb3830 100644
--- a/Tools/TestWebKitAPI/Tests/mac/BackForwardList.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/BackForwardList.mm
@@ -54,8 +54,8 @@ namespace TestWebKitAPI {
TEST(WebKit1, ReloadBackForward)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<BackForwardListTest> testController(AdoptNS, [BackForwardListTest new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<BackForwardListTest> testController = adoptNS([BackForwardListTest new]);
webView.get().frameLoadDelegate = testController.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://does-not-exist.example"]]];
Util::run(&didFinishLoad);
diff --git a/Tools/TestWebKitAPI/Tests/mac/CancelLoadFromResourceLoadDelegate.mm b/Tools/TestWebKitAPI/Tests/mac/CancelLoadFromResourceLoadDelegate.mm
index 3729eb53c..9a19f936c 100644
--- a/Tools/TestWebKitAPI/Tests/mac/CancelLoadFromResourceLoadDelegate.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/CancelLoadFromResourceLoadDelegate.mm
@@ -64,11 +64,11 @@ TEST(WebKit1, CancelLoadFromResourceLoadDelegate)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<CancelLoadFromResourceLoadDelegate> resourceLoadDelegate(AdoptNS, [[CancelLoadFromResourceLoadDelegate alloc] init]);
+ RetainPtr<CancelLoadFromResourceLoadDelegate> resourceLoadDelegate = adoptNS([[CancelLoadFromResourceLoadDelegate alloc] init]);
webView.get().resourceLoadDelegate = resourceLoadDelegate.get();
- RetainPtr<CancelLoadFromResourceLoadDelegateFrameLoadDelegate> frameLoadDelegate(AdoptNS, [[CancelLoadFromResourceLoadDelegateFrameLoadDelegate alloc] init]);
+ RetainPtr<CancelLoadFromResourceLoadDelegateFrameLoadDelegate> frameLoadDelegate = adoptNS([[CancelLoadFromResourceLoadDelegateFrameLoadDelegate alloc] init]);
webView.get().frameLoadDelegate = frameLoadDelegate.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"CancelLoadFromResourceLoadDelegate" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
diff --git a/Tools/TestWebKitAPI/Tests/mac/CloseNewWindowInNavigationPolicyDelegate.mm b/Tools/TestWebKitAPI/Tests/mac/CloseNewWindowInNavigationPolicyDelegate.mm
new file mode 100644
index 000000000..367378609
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/CloseNewWindowInNavigationPolicyDelegate.mm
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "PlatformUtilities.h"
+#import <wtf/RetainPtr.h>
+
+static bool testFinished = false;
+
+@interface TestDelegate : NSObject
+
++ (TestDelegate *)shared;
+
+@end
+
+@implementation TestDelegate
+
++ (TestDelegate *)shared
+{
+ static TestDelegate *sharedTestDelegate = [[TestDelegate alloc] init];
+ return sharedTestDelegate;
+}
+
+- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener
+{
+ if (!request) {
+ [listener use];
+ return;
+ }
+
+ [webView close];
+ [listener ignore];
+ testFinished = true;
+}
+
+- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request
+{
+ WebView *webView = [[WebView alloc] init];
+ webView.policyDelegate = [TestDelegate shared];
+ [[webView mainFrame] loadRequest:request];
+ return webView;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, CloseNewWindowInNavigationPolicyDelegate)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] init]);
+ webView.get().preferences.javaScriptCanOpenWindowsAutomatically = YES;
+ webView.get().UIDelegate = [TestDelegate shared];
+ [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"OpenNewWindow" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+
+ Util::run(&testFinished);
+
+ [pool drain];
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.mm b/Tools/TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.mm
index 40ac377e1..f79535f64 100644
--- a/Tools/TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.mm
@@ -88,9 +88,9 @@ static void contextMenuCopyLink(WebView* webView, int itemIndex)
TEST(WebKit1, ContextMenuCanCopyURL)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0,0,800,600) frameName:nil groupName:nil]);
- RetainPtr<NSWindow> window(AdoptNS, [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 100, 800, 600) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
- RetainPtr<ContextMenuCanCopyURLDelegate> delegate(AdoptNS, [[ContextMenuCanCopyURLDelegate alloc] init]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0,0,800,600) frameName:nil groupName:nil]);
+ RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:NSMakeRect(100, 100, 800, 600) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+ RetainPtr<ContextMenuCanCopyURLDelegate> delegate = adoptNS([[ContextMenuCanCopyURLDelegate alloc] init]);
[window.get().contentView addSubview:webView.get()];
webView.get().frameLoadDelegate = delegate.get();
diff --git a/Tools/TestWebKitAPI/Tests/mac/DOMHTMLTableCellCellAbove.mm b/Tools/TestWebKitAPI/Tests/mac/DOMHTMLTableCellCellAbove.mm
new file mode 100644
index 000000000..2c8ca3986
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/DOMHTMLTableCellCellAbove.mm
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include <wtf/RetainPtr.h>
+
+#import <WebKit/DOMPrivate.h>
+#import <WebKit/WebViewPrivate.h>
+
+@interface HTMLTableCellElementCellAboveTest : NSObject
+@end
+
+static bool didFinishLoad;
+
+@implementation HTMLTableCellElementCellAboveTest
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ didFinishLoad = true;
+}
+@end
+
+namespace TestWebKitAPI {
+
+static void expectCellAboveCell(DOMDocument *document, NSString *cellID, NSString *cellAboveID)
+{
+ DOMHTMLTableCellElement *cell = (DOMHTMLTableCellElement *)[document getElementById:cellID];
+ DOMHTMLTableCellElement *cellAbove = [cell _cellAbove];
+
+ EXPECT_WK_STREQ(cellAboveID, [cellAbove getAttribute:@"id"]);
+}
+
+TEST(WebKit1, HTMLTableCellElementCellAbove)
+{
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<HTMLTableCellElementCellAboveTest> testController = adoptNS([HTMLTableCellElementCellAboveTest new]);
+
+ webView.get().frameLoadDelegate = testController.get();
+ [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle]
+ URLForResource:@"DOMHTMLTableCellElementCellAbove" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+
+ Util::run(&didFinishLoad);
+ didFinishLoad = false;
+
+ DOMDocument *document = webView.get().mainFrameDocument;
+
+ expectCellAboveCell(document, @"cell-4-2", @"cell-3-2");
+ expectCellAboveCell(document, @"cell-3-1", @"cell-2-1");
+ expectCellAboveCell(document, @"cell-2-1", @"cell-1-1");
+ expectCellAboveCell(document, @"cell-1-2", @"cell-h-2");
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/DOMHTMLTableCellElementCellAbove.html b/Tools/TestWebKitAPI/Tests/mac/DOMHTMLTableCellElementCellAbove.html
new file mode 100644
index 000000000..79135fd27
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/DOMHTMLTableCellElementCellAbove.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<body>
+ <table>
+ <tbody>
+ <tr>
+ <td id="cell-1-1">1-1</td>
+ <td id="cell-1-2">1-2</td>
+ </tr>
+ <tr>
+ <td id="cell-2-1">2-1</td>
+ <td id="cell-2-2">2-2</td>
+ </tr>
+ </tbody>
+ <thead>
+ <tr>
+ <th id="cell-h-1">h-1</th>
+ <th id="cell-h-2">h-2</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td id="cell-3-1">3-1</td>
+ <td id="cell-3-2">3-2</td>
+ </tr>
+ <tr>
+ <td id="cell-4-1">4-1</td>
+ <td id="cell-4-2">4-2</td>
+ </tr>
+ </tbody>
+</body>
diff --git a/Tools/TestWebKitAPI/Tests/mac/DOMNodeFromJSObject.mm b/Tools/TestWebKitAPI/Tests/mac/DOMNodeFromJSObject.mm
new file mode 100644
index 000000000..7bd23ea98
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/DOMNodeFromJSObject.mm
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import <JavaScriptCore/JSRetainPtr.h>
+#import <WebKit/DOMPrivate.h>
+#import <WebKit/WebFramePrivate.h>
+#import <WebKit/WebScriptWorld.h>
+#import <objc/runtime.h>
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, DOMNodeFromJSObject)
+{
+ WebView *webView = [[WebView alloc] initWithFrame:NSZeroRect frameName:nil groupName:nil];
+
+ [webView stringByEvaluatingJavaScriptFromString:@"document.body.mainWorldProperty = true"];
+
+ WebScriptWorld *isolatedWorld = [WebScriptWorld world];
+ JSGlobalContextRef context = [[webView mainFrame] _globalContextForScriptWorld:isolatedWorld];
+
+ JSRetainPtr<JSStringRef> script(Adopt, JSStringCreateWithUTF8CString("document.body"));
+
+ JSValueRef value = JSEvaluateScript(context, script.get(), 0, 0, 0, 0);
+ JSObjectRef jsBody = JSValueToObject(context, value, 0);
+
+ id objcBody = [DOMNode _nodeFromJSWrapper:jsBody];
+
+ EXPECT_STREQ("DOMHTMLBodyElement", class_getName([objcBody class]));
+ EXPECT_EQ([[[webView mainFrame] DOMDocument] body], objcBody);
+
+ // Verify that the Objective-C wrapper is for the main world JS wrapper.
+ EXPECT_TRUE([[objcBody valueForKey:@"mainWorldProperty"] boolValue]);
+
+ [webView release];
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.mm b/Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.mm
index 1e8080539..a4485178d 100644
--- a/Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.mm
@@ -48,8 +48,8 @@ namespace TestWebKitAPI {
TEST(WebKit1, DOMRangeOfString)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSZeroRect frameName:nil groupName:nil]);
- RetainPtr<DOMRangeOfStringFrameLoadDelegate> frameLoadDelegate(AdoptNS, [DOMRangeOfStringFrameLoadDelegate new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSZeroRect frameName:nil groupName:nil]);
+ RetainPtr<DOMRangeOfStringFrameLoadDelegate> frameLoadDelegate = adoptNS([DOMRangeOfStringFrameLoadDelegate new]);
webView.get().frameLoadDelegate = frameLoadDelegate.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"DOMRangeOfString" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
@@ -74,7 +74,7 @@ TEST(WebKit1, DOMRangeOfString)
resultRange = [webView.get() DOMRangeOfString:@"n" relativeTo:needleRange options:WebFindOptionsStartInSelection];
EXPECT_EQ(28, resultRange.startOffset);
- RetainPtr<WebView> otherWebView(AdoptNS, [[WebView alloc] initWithFrame:NSZeroRect frameName:nil groupName:nil]);
+ RetainPtr<WebView> otherWebView = adoptNS([[WebView alloc] initWithFrame:NSZeroRect frameName:nil groupName:nil]);
DOMRange *foreignRange = [[[otherWebView.get() mainFrame] DOMDocument] createRange];
resultRange = [webView.get() DOMRangeOfString:@"needle" relativeTo:foreignRange options:0];
EXPECT_EQ(nil, resultRange);
diff --git a/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm b/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm
index f20356429..68ecbf819 100644
--- a/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm
@@ -53,12 +53,12 @@ namespace TestWebKitAPI {
TEST(WebKit1, DeviceScaleFactorInDashboardRegions)
{
NSRect viewFrame = NSMakeRect(0, 0, 800, 600);
- RetainPtr<SyntheticBackingScaleFactorWindow> window(AdoptNS, [[SyntheticBackingScaleFactorWindow alloc] initWithContentRect:viewFrame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+ RetainPtr<SyntheticBackingScaleFactorWindow> window = adoptNS([[SyntheticBackingScaleFactorWindow alloc] initWithContentRect:viewFrame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
[window.get() setReleasedWhenClosed:NO];
[window.get() setBackingScaleFactor:2];
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:viewFrame frameName:nil groupName:nil]);
- RetainPtr<DeviceScaleFactorInDashboardRegionsUIDelegate> uiDelegate(AdoptNS, [DeviceScaleFactorInDashboardRegionsUIDelegate new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:viewFrame frameName:nil groupName:nil]);
+ RetainPtr<DeviceScaleFactorInDashboardRegionsUIDelegate> uiDelegate = adoptNS([DeviceScaleFactorInDashboardRegionsUIDelegate new]);
webView.get().UIDelegate = uiDelegate.get();
[window.get().contentView addSubview:webView.get()];
diff --git a/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorOnBack.mm b/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorOnBack.mm
index 154b8c32c..8c454282a 100644
--- a/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorOnBack.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorOnBack.mm
@@ -50,7 +50,7 @@ public:
RetainPtr<SyntheticBackingScaleFactorWindow> DeviceScaleFactorOnBack::createWindow()
{
- RetainPtr<SyntheticBackingScaleFactorWindow> window(AdoptNS, [[SyntheticBackingScaleFactorWindow alloc] initWithContentRect:viewFrame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+ RetainPtr<SyntheticBackingScaleFactorWindow> window = adoptNS([[SyntheticBackingScaleFactorWindow alloc] initWithContentRect:viewFrame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
[window.get() setReleasedWhenClosed:NO];
return window;
}
diff --git a/Tools/TestWebKitAPI/Tests/mac/DynamicDeviceScaleFactor.mm b/Tools/TestWebKitAPI/Tests/mac/DynamicDeviceScaleFactor.mm
index d0ebd5177..61a1efed7 100644
--- a/Tools/TestWebKitAPI/Tests/mac/DynamicDeviceScaleFactor.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/DynamicDeviceScaleFactor.mm
@@ -47,7 +47,7 @@ public:
RetainPtr<SyntheticBackingScaleFactorWindow> DynamicDeviceScaleFactor::createWindow()
{
- RetainPtr<SyntheticBackingScaleFactorWindow> window(AdoptNS, [[SyntheticBackingScaleFactorWindow alloc] initWithContentRect:viewFrame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+ RetainPtr<SyntheticBackingScaleFactorWindow> window = adoptNS([[SyntheticBackingScaleFactorWindow alloc] initWithContentRect:viewFrame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
[window.get() setReleasedWhenClosed:NO];
return window;
}
diff --git a/Tools/TestWebKitAPI/Tests/mac/ElementAtPointInWebFrame.mm b/Tools/TestWebKitAPI/Tests/mac/ElementAtPointInWebFrame.mm
new file mode 100644
index 000000000..10fc581f4
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/ElementAtPointInWebFrame.mm
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "PlatformUtilities.h"
+#import <WebKit/WebFramePrivate.h>
+#import <wtf/RetainPtr.h>
+
+@interface ElementAtPointFrameLoadDelegate : NSObject
+@end
+
+static bool didFinishLoad;
+
+@implementation ElementAtPointFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ didFinishLoad = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, ElementAtPoint)
+{
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<ElementAtPointFrameLoadDelegate> frameLoadDelegate = adoptNS([[ElementAtPointFrameLoadDelegate alloc] init]);
+
+ webView.get().frameLoadDelegate = frameLoadDelegate.get();
+ WebFrame *mainFrame = webView.get().mainFrame;
+
+ [mainFrame loadHTMLString:@"<style> div { position:absolute; width:60px; height:100px; } </style> <div name='first'></div> <div name='second' style='left:60px; top:100px;'></div>"
+ baseURL:[NSURL URLWithString:@"about:blank"]];
+
+ Util::run(&didFinishLoad);
+
+ NSDictionary *elementDictionary = [mainFrame elementAtPoint:NSMakePoint(30, 50)];
+ DOMElement *domElement = [elementDictionary objectForKey:WebElementDOMNodeKey];
+ EXPECT_WK_STREQ(@"first", [domElement getAttribute:@"name"]);
+
+ elementDictionary = [mainFrame elementAtPoint:NSMakePoint(90, 150)];
+ domElement = [elementDictionary objectForKey:WebElementDOMNodeKey];
+ EXPECT_WK_STREQ(@"second", [domElement getAttribute:@"name"]);
+
+ elementDictionary = [mainFrame elementAtPoint:NSMakePoint(30, 150)];
+ domElement = [elementDictionary objectForKey:WebElementDOMNodeKey];
+ EXPECT_WK_STREQ(@"BODY", [domElement tagName]);
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/HTMLCollectionNamedItem.mm b/Tools/TestWebKitAPI/Tests/mac/HTMLCollectionNamedItem.mm
index 50aafeeba..62cb79751 100644
--- a/Tools/TestWebKitAPI/Tests/mac/HTMLCollectionNamedItem.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/HTMLCollectionNamedItem.mm
@@ -50,8 +50,8 @@ namespace TestWebKitAPI {
TEST(WebKit1, HTMLCollectionNamedItemTest)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<HTMLCollectionNamedItemTest> testController(AdoptNS, [HTMLCollectionNamedItemTest new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<HTMLCollectionNamedItemTest> testController = adoptNS([HTMLCollectionNamedItemTest new]);
webView.get().frameLoadDelegate = testController.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle]
diff --git a/Tools/TestWebKitAPI/Tests/mac/HTMLFormCollectionNamedItem.mm b/Tools/TestWebKitAPI/Tests/mac/HTMLFormCollectionNamedItem.mm
index cf2da2dfb..a716ab92f 100644
--- a/Tools/TestWebKitAPI/Tests/mac/HTMLFormCollectionNamedItem.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/HTMLFormCollectionNamedItem.mm
@@ -50,8 +50,8 @@ namespace TestWebKitAPI {
TEST(WebKit1, HTMLFormCollectionNamedItemTest)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<HTMLFormCollectionNamedItemTest> testController(AdoptNS, [HTMLFormCollectionNamedItemTest new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<HTMLFormCollectionNamedItemTest> testController = adoptNS([HTMLFormCollectionNamedItemTest new]);
webView.get().frameLoadDelegate = testController.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle]
diff --git a/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm b/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm
index 0a51e2fb4..5f2205be8 100644
--- a/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm
@@ -52,8 +52,8 @@ namespace TestWebKitAPI {
TEST(WebKit1, InspectorBarTest)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<InspectorBarController> inspectorBarController(AdoptNS, [InspectorBarController new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<InspectorBarController> inspectorBarController = adoptNS([InspectorBarController new]);
webView.get().frameLoadDelegate = inspectorBarController.get();
[webView.get().mainFrame loadHTMLString:@"<body contenteditable style=\"color: green\"><u>Lorem ipsum sit amet</u></body>" baseURL:[NSURL URLWithString:@"about:blank"]];
diff --git a/Tools/TestWebKitAPI/Tests/mac/JSContextBackForwardCache1.html b/Tools/TestWebKitAPI/Tests/mac/JSContextBackForwardCache1.html
new file mode 100644
index 000000000..f736a7890
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/JSContextBackForwardCache1.html
@@ -0,0 +1,10 @@
+<body>
+ <div id="test-div"></div>
+ <script>
+ var testDiv = document.getElementById("test-div");
+ if (!testDiv.myCustomProperty)
+ insertMyCustomProperty(testDiv);
+ else
+ checkForMyCustomProperty(testDiv);
+ </script>
+</body>
diff --git a/Tools/TestWebKitAPI/Tests/mac/JSContextBackForwardCache2.html b/Tools/TestWebKitAPI/Tests/mac/JSContextBackForwardCache2.html
new file mode 100644
index 000000000..1d26d21b4
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/JSContextBackForwardCache2.html
@@ -0,0 +1,10 @@
+<body>
+ <div id="test-div"></div>
+ <script>
+ var testDiv = document.getElementById("test-div");
+ if (testDiv.myCustomProperty)
+ myConsole.log("ERROR: found myCustomProperty.");
+ else
+ didCompleteTestSuccessfully();
+ </script>
+</body>
diff --git a/Tools/TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm b/Tools/TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm
new file mode 100644
index 000000000..5c41aaab5
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "PlatformUtilities.h"
+#import <WebKit/WebFramePrivate.h>
+#import <WebKit/WebScriptWorld.h>
+#import <JavaScriptCore/JSContextRef.h>
+#import <JavaScriptCore/JSRetainPtr.h>
+#import <JavaScriptCore/JSStringRef.h>
+#import <JavaScriptCore/JSValueRef.h>
+#import <wtf/RetainPtr.h>
+
+@interface JSWrapperForNodeFrameLoadDelegate : NSObject {
+}
+@end
+
+static bool didFinishLoad;
+
+@implementation JSWrapperForNodeFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ didFinishLoad = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, JSWrapperForNode)
+{
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<JSWrapperForNodeFrameLoadDelegate> frameLoadDelegate = adoptNS([[JSWrapperForNodeFrameLoadDelegate alloc] init]);
+
+ webView.get().frameLoadDelegate = frameLoadDelegate.get();
+ WebFrame *mainFrame = webView.get().mainFrame;
+ [mainFrame loadHTMLString:@"<div id=\"target\"</div>" baseURL:[NSURL URLWithString:@"about:blank"]];
+ Util::run(&didFinishLoad);
+ DOMDocument *document = webView.get().mainFrameDocument;
+ DOMNode *target = [document getElementById:@"target"]; // This script object is in standard world.
+
+ // In an isolated script world, add a new property to the target node.
+ NSString *isolatedScriptString = @"var target = document.getElementById(\"target\"); target.isolatedProperty = true;";
+ WebScriptWorld *isolatedWorld = [WebScriptWorld world];
+ JSGlobalContextRef isolatedCtx = [mainFrame _globalContextForScriptWorld:isolatedWorld];
+ [mainFrame _stringByEvaluatingJavaScriptFromString:isolatedScriptString withGlobalObject:JSContextGetGlobalObject(isolatedCtx) inScriptWorld:isolatedWorld];
+ JSValueRef isolatedNodeJSValue = [mainFrame jsWrapperForNode:target inScriptWorld:isolatedWorld];
+ ASSERT_TRUE(JSValueIsObject(isolatedCtx, isolatedNodeJSValue));
+ JSObjectRef isolatedNodeJSObject = JSValueToObject(isolatedCtx, isolatedNodeJSValue, 0);
+
+ // In the standard script world, add a different property to the target node
+ NSString *normalScriptString = @"var target = document.getElementById(\"target\"); target.normalProperty = true;";
+ WebScriptWorld *normalWorld = [WebScriptWorld standardWorld];
+ JSGlobalContextRef normalCtx = [mainFrame _globalContextForScriptWorld:normalWorld];
+ [mainFrame _stringByEvaluatingJavaScriptFromString:normalScriptString withGlobalObject:JSContextGetGlobalObject(normalCtx) inScriptWorld:normalWorld];
+ JSValueRef normalNodeJSValue = [mainFrame jsWrapperForNode:target inScriptWorld:normalWorld];
+ ASSERT_TRUE(JSValueIsObject(normalCtx, normalNodeJSValue));
+ JSObjectRef normalNodeJSObject = JSValueToObject(normalCtx, normalNodeJSValue, 0);
+
+ JSRetainPtr<JSStringRef> isolatedPropertyJSString = JSStringCreateWithUTF8CString("isolatedProperty");
+ // Test for successful retrieval of the first property in the isolated script world
+ EXPECT_TRUE(JSValueIsBoolean(isolatedCtx, JSObjectGetProperty(isolatedCtx, isolatedNodeJSObject, isolatedPropertyJSString.get(), 0)));
+ // Test for failed retrieval of the first property in the standard script world
+ EXPECT_TRUE(JSValueIsUndefined(normalCtx, JSObjectGetProperty(normalCtx, normalNodeJSObject, isolatedPropertyJSString.get(), 0)));
+
+ JSRetainPtr<JSStringRef> normalPropertyJSString = JSStringCreateWithUTF8CString("normalProperty");
+ // Test for successful retrieval of the second property in the standard script world
+ EXPECT_TRUE(JSValueIsBoolean(normalCtx, JSObjectGetProperty(normalCtx, normalNodeJSObject, normalPropertyJSString.get(), 0)));
+ // Test for failed retrieval of the second property in the isolated script world
+ EXPECT_TRUE(JSValueIsUndefined(isolatedCtx, JSObjectGetProperty(isolatedCtx, isolatedNodeJSObject, normalPropertyJSString.get(), 0)));
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.mm b/Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.mm
index aeb955508..e2ecdeac4 100644
--- a/Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.mm
@@ -74,9 +74,9 @@ TEST(WebKit1, MemoryCacheDisableWithinResourceLoadDelegate)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<MemoryCacheDisableTestResourceLoadDelegate> resourceLoadDelegate(AdoptNS, [[MemoryCacheDisableTestResourceLoadDelegate alloc] init]);
+ RetainPtr<MemoryCacheDisableTestResourceLoadDelegate> resourceLoadDelegate = adoptNS([[MemoryCacheDisableTestResourceLoadDelegate alloc] init]);
webView.get().resourceLoadDelegate = resourceLoadDelegate.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"MemoryCacheDisableWithinResourceLoadDelegate" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
diff --git a/Tools/TestWebKitAPI/Tests/mac/MemoryCachePruneWithinResourceLoadDelegate.mm b/Tools/TestWebKitAPI/Tests/mac/MemoryCachePruneWithinResourceLoadDelegate.mm
index b178abd63..212820e0a 100644
--- a/Tools/TestWebKitAPI/Tests/mac/MemoryCachePruneWithinResourceLoadDelegate.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/MemoryCachePruneWithinResourceLoadDelegate.mm
@@ -75,17 +75,17 @@ static bool didFinishLoad;
namespace TestWebKitAPI {
-TEST(WebKit1, MemoryCachePruneWithinResourceLoadDelegate)
+TEST(WebKit1, DISABLED_MemoryCachePruneWithinResourceLoadDelegate)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- RetainPtr<WebView> webView1(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<WebView> webView2(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<WebView> webView1 = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<WebView> webView2 = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
NSWindow* window = [[NSWindow alloc] initWithContentRect:webView2.get().frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
[window.contentView addSubview:webView2.get()];
- RetainPtr<MemoryCachePruneTestResourceLoadDelegate> resourceLoadDelegate(AdoptNS, [[MemoryCachePruneTestResourceLoadDelegate alloc] init]);
+ RetainPtr<MemoryCachePruneTestResourceLoadDelegate> resourceLoadDelegate = adoptNS([[MemoryCachePruneTestResourceLoadDelegate alloc] init]);
resourceLoadDelegate.get()->_window = window;
webView1.get().resourceLoadDelegate = resourceLoadDelegate.get();
diff --git a/Tools/TestWebKitAPI/Tests/mac/OpenNewWindow.html b/Tools/TestWebKitAPI/Tests/mac/OpenNewWindow.html
new file mode 100644
index 000000000..975f6d98d
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/OpenNewWindow.html
@@ -0,0 +1,7 @@
+<a href="#" onclick="openWindow()"></a>
+<script>
+ function openWindow() {
+ window.open("window-to-ignore.html", "newWindow");
+ }
+ document.getElementsByTagName("a")[0].click();
+</script>
diff --git a/Tools/TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm b/Tools/TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm
index 9254ffb60..9a614ab7a 100644
--- a/Tools/TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm
@@ -111,7 +111,7 @@ void PageVisibilityStateWithWindowChanges::runTest(View view)
EXPECT_JS_EQ(view, "document.visibilityState", "hidden");
// Add it to a non-visible window. PageVisibility should still be "hidden".
- RetainPtr<NSWindow> window(AdoptNS, [[NSWindow alloc] initWithContentRect:view.frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
+ RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:view.frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
[window.get().contentView addSubview:view];
EXPECT_NOT_NULL([view window]);
EXPECT_NOT_NULL([view superview]);
diff --git a/Tools/TestWebKitAPI/Tests/mac/PublicSuffix.mm b/Tools/TestWebKitAPI/Tests/mac/PublicSuffix.mm
new file mode 100644
index 000000000..cb72414f3
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/PublicSuffix.mm
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if USE(PUBLIC_SUFFIX_LIST)
+
+#include "WTFStringUtilities.h"
+#include <WebCore/PublicSuffix.h>
+#include <wtf/MainThread.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+class PublicSuffix: public testing::Test {
+public:
+ virtual void SetUp()
+ {
+ WTF::initializeMainThread();
+ [WebView initialize];
+ }
+};
+
+TEST_F(PublicSuffix, IsPublicSuffix)
+{
+ EXPECT_TRUE(isPublicSuffix("com"));
+ EXPECT_FALSE(isPublicSuffix("test.com"));
+ EXPECT_FALSE(isPublicSuffix("com.com"));
+ EXPECT_TRUE(isPublicSuffix("net"));
+ EXPECT_TRUE(isPublicSuffix("org"));
+ EXPECT_TRUE(isPublicSuffix("co.uk"));
+ EXPECT_FALSE(isPublicSuffix("bl.uk"));
+ EXPECT_FALSE(isPublicSuffix("test.co.uk"));
+ EXPECT_TRUE(isPublicSuffix("xn--zf0ao64a.tw"));
+}
+
+TEST_F(PublicSuffix, TopPrivatelyControlledDomain)
+{
+ EXPECT_EQ(String("test.com"), topPrivatelyControlledDomain("test.com"));
+ EXPECT_EQ(String("test.com"), topPrivatelyControlledDomain("com.test.com"));
+ EXPECT_EQ(String("test.com"), topPrivatelyControlledDomain("subdomain.test.com"));
+ EXPECT_EQ(String("com.com"), topPrivatelyControlledDomain("www.com.com"));
+ EXPECT_EQ(String("test.co.uk"), topPrivatelyControlledDomain("test.co.uk"));
+ EXPECT_EQ(String("test.co.uk"), topPrivatelyControlledDomain("subdomain.test.co.uk"));
+ EXPECT_EQ(String("bl.uk"), topPrivatelyControlledDomain("bl.uk"));
+ EXPECT_EQ(String("bl.uk"), topPrivatelyControlledDomain("subdomain.bl.uk"));
+ EXPECT_EQ(String("test.xn--zf0ao64a.tw"), topPrivatelyControlledDomain("test.xn--zf0ao64a.tw"));
+ EXPECT_EQ(String("test.xn--zf0ao64a.tw"), topPrivatelyControlledDomain("www.test.xn--zf0ao64a.tw"));
+ EXPECT_EQ(String("127.0.0.1"), topPrivatelyControlledDomain("127.0.0.1"));
+ EXPECT_EQ(String(), topPrivatelyControlledDomain("1"));
+ EXPECT_EQ(String(), topPrivatelyControlledDomain("com"));
+}
+
+}
+
+#endif
diff --git a/Tools/TestWebKitAPI/Tests/mac/RenderedImageFromDOMRange.mm b/Tools/TestWebKitAPI/Tests/mac/RenderedImageFromDOMRange.mm
index 5ad43bd25..bc3a11db3 100644
--- a/Tools/TestWebKitAPI/Tests/mac/RenderedImageFromDOMRange.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/RenderedImageFromDOMRange.mm
@@ -48,8 +48,8 @@ namespace TestWebKitAPI {
TEST(WebKit1, RenderedImageFromDOMRange)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<RenderedImageFromDOMRangeFrameLoadDelegate> frameLoadDelegate(AdoptNS, [RenderedImageFromDOMRangeFrameLoadDelegate new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<RenderedImageFromDOMRangeFrameLoadDelegate> frameLoadDelegate = adoptNS([RenderedImageFromDOMRangeFrameLoadDelegate new]);
webView.get().frameLoadDelegate = frameLoadDelegate.get();
[webView.get().mainFrame loadHTMLString:@"<div style=\"width: 100px;\">Lorem <span id=\"target\">ipsum dolor</span> sit amet</div>" baseURL:[NSURL URLWithString:@"about:blank"]];
diff --git a/Tools/TestWebKitAPI/Tests/mac/SetAndUpdateCacheModel.mm b/Tools/TestWebKitAPI/Tests/mac/SetAndUpdateCacheModel.mm
index eed1f8180..003755235 100644
--- a/Tools/TestWebKitAPI/Tests/mac/SetAndUpdateCacheModel.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/SetAndUpdateCacheModel.mm
@@ -39,7 +39,7 @@ TEST(WebKit1, SetAndUpdateCacheModelInitialModel)
{
EXPECT_EQ((int)WebCacheModelDocumentViewer, (int)[WebView _cacheModel]);
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
EXPECT_EQ((int)WebCacheModelDocumentBrowser, (int)[WebView _cacheModel]);
}
@@ -64,7 +64,7 @@ TEST(WebKit1, SetAndUpdateCacheModelPreferencesChangeMix)
EXPECT_EQ((int)WebCacheModelDocumentViewer, (int)[WebView _cacheModel]);
WebPreferences *standardPreferences = [WebPreferences standardPreferences];
- RetainPtr<WebPreferences> customPreferences(AdoptNS, [[WebPreferences alloc] initWithIdentifier:@"SetAndUpdateCacheModelPreferencesChangeMix"]);
+ RetainPtr<WebPreferences> customPreferences = adoptNS([[WebPreferences alloc] initWithIdentifier:@"SetAndUpdateCacheModelPreferencesChangeMix"]);
// 1) The customPreferences is not set on a view.
EXPECT_EQ((int)WebCacheModelDocumentBrowser, (int)[WebView _cacheModel]);
@@ -79,7 +79,7 @@ TEST(WebKit1, SetAndUpdateCacheModelPreferencesChangeMix)
// 2) The cache model should follow the highest value of cache model between the two preferences.
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
[webView.get() setPreferences:customPreferences.get()];
EXPECT_EQ((int)WebCacheModelPrimaryWebBrowser, (int)[WebView _cacheModel]);
diff --git a/Tools/TestWebKitAPI/Tests/mac/SetDocumentURI.mm b/Tools/TestWebKitAPI/Tests/mac/SetDocumentURI.mm
index f077ed95b..44ecc3e9b 100644
--- a/Tools/TestWebKitAPI/Tests/mac/SetDocumentURI.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/SetDocumentURI.mm
@@ -49,8 +49,8 @@ namespace TestWebKitAPI {
TEST(WebKit1, SetDocumentURITestFile)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<SetDocumentURITest> testController(AdoptNS, [SetDocumentURITest new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<SetDocumentURITest> testController = adoptNS([SetDocumentURITest new]);
webView.get().frameLoadDelegate = testController.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"SetDocumentURI" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
Util::run(&didFinishLoad);
@@ -66,8 +66,8 @@ TEST(WebKit1, SetDocumentURITestFile)
TEST(WebKit1, SetDocumentURITestURL)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<SetDocumentURITest> testController(AdoptNS, [SetDocumentURITest new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<SetDocumentURITest> testController = adoptNS([SetDocumentURITest new]);
webView.get().frameLoadDelegate = testController.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"SetDocumentURI" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
Util::run(&didFinishLoad);
@@ -86,8 +86,8 @@ TEST(WebKit1, SetDocumentURITestURL)
TEST(WebKit1, SetDocumentURITestString)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<SetDocumentURITest> testController(AdoptNS, [SetDocumentURITest new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<SetDocumentURITest> testController = adoptNS([SetDocumentURITest new]);
webView.get().frameLoadDelegate = testController.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"SetDocumentURI" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
Util::run(&didFinishLoad);
@@ -103,8 +103,8 @@ TEST(WebKit1, SetDocumentURITestString)
TEST(WebKit1, SetDocumentURITestNull)
{
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<SetDocumentURITest> testController(AdoptNS, [SetDocumentURITest new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<SetDocumentURITest> testController = adoptNS([SetDocumentURITest new]);
webView.get().frameLoadDelegate = testController.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"SetDocumentURI" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
Util::run(&didFinishLoad);
diff --git a/Tools/TestWebKitAPI/Tests/mac/SimplifyMarkup.mm b/Tools/TestWebKitAPI/Tests/mac/SimplifyMarkup.mm
index 70ec47d57..9d443ad04 100644
--- a/Tools/TestWebKitAPI/Tests/mac/SimplifyMarkup.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/SimplifyMarkup.mm
@@ -49,9 +49,9 @@ namespace TestWebKitAPI {
TEST(WebKit1, SimplifyMarkupTest)
{
- RetainPtr<WebView> webView1(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<WebView> webView2(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<SimplifyMarkupTest> testController(AdoptNS, [SimplifyMarkupTest new]);
+ RetainPtr<WebView> webView1 = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<WebView> webView2 = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<SimplifyMarkupTest> testController = adoptNS([SimplifyMarkupTest new]);
webView1.get().frameLoadDelegate = testController.get();
[[webView1.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"verboseMarkup" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
diff --git a/Tools/TestWebKitAPI/Tests/mac/StopLoadingFromDidReceiveResponse.html b/Tools/TestWebKitAPI/Tests/mac/StopLoadingFromDidReceiveResponse.html
new file mode 100644
index 000000000..92af0012c
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/StopLoadingFromDidReceiveResponse.html
@@ -0,0 +1 @@
+<script src="data:text/javascript,document.write('SUCCESS')"></script>
diff --git a/Tools/TestWebKitAPI/Tests/mac/StopLoadingFromDidReceiveResponse.mm b/Tools/TestWebKitAPI/Tests/mac/StopLoadingFromDidReceiveResponse.mm
new file mode 100644
index 000000000..8eb269df0
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/StopLoadingFromDidReceiveResponse.mm
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "PlatformUtilities.h"
+#import <WebKit/WebCache.h>
+#import <wtf/RetainPtr.h>
+
+@interface StopLoadingFromDidReceiveResponse : NSObject {
+}
+@end
+
+static bool didFinishLoad;
+
+@implementation StopLoadingFromDidReceiveResponse
+
+- (void)webView:(WebView *)sender resource:(id)identifier didReceiveResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)dataSource
+{
+ static BOOL mainResourceReceived;
+ if (!mainResourceReceived) {
+ mainResourceReceived = YES;
+ return;
+ }
+
+ [sender stopLoading:identifier];
+
+ didFinishLoad = YES;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, StopLoadingFromDidReceiveResponse)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+
+ RetainPtr<StopLoadingFromDidReceiveResponse> resourceLoadDelegate = adoptNS([[StopLoadingFromDidReceiveResponse alloc] init]);
+ webView.get().resourceLoadDelegate = resourceLoadDelegate.get();
+
+ [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"StopLoadingFromDidReceiveResponse" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+
+ Util::run(&didFinishLoad);
+
+ [pool drain];
+ // If we finished without crashing, the test passed.
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm b/Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm
index 4e3e3ec75..260a5a53e 100644
--- a/Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm
@@ -32,7 +32,7 @@ namespace TestWebKitAPI {
TEST(WebKit1, StringByEvaluatingJavaScriptFromString)
{
// maps expected result <= JavaScript expression
- RetainPtr<NSDictionary> expressions(AdoptNS, [[NSDictionary alloc] initWithObjectsAndKeys:
+ RetainPtr<NSDictionary> expressions = adoptNS([[NSDictionary alloc] initWithObjectsAndKeys:
@"0", @"0",
@"0", @"'0'",
@"", @"",
@@ -53,7 +53,7 @@ TEST(WebKit1, StringByEvaluatingJavaScriptFromString)
nil
]);
- RetainPtr<WebView> webView (AdoptNS, [[WebView alloc] initWithFrame:NSZeroRect frameName:@"" groupName:@""]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSZeroRect frameName:@"" groupName:@""]);
// Test a nil string
NSString *result = [webView.get() stringByEvaluatingJavaScriptFromString:nil];
diff --git a/Tools/TestWebKitAPI/Tests/mac/WebViewDidCreateJavaScriptContext.mm b/Tools/TestWebKitAPI/Tests/mac/WebViewDidCreateJavaScriptContext.mm
new file mode 100644
index 000000000..39504dda8
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/WebViewDidCreateJavaScriptContext.mm
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "PlatformUtilities.h"
+#import <JavaScriptCore/JSExport.h>
+#import <JavaScriptCore/JSContext.h>
+#import <WebKit/WebFrameLoadDelegatePrivate.h>
+#import <wtf/RetainPtr.h>
+
+#if JSC_OBJC_API_ENABLED
+
+@class MyConsole;
+
+static bool didFinishLoad = false;
+static bool didCompleteTestSuccessfully = false;
+static bool didCallWindowCallback = false;
+static bool didFindMyCustomProperty = false;
+static bool didInsertMyCustomProperty = true;
+
+@protocol MyConsole<JSExport>
+- (void)log:(NSString *)s;
+- (void)printHelloWorld;
+- (int)add:(int)a to:(int)b;
+@end
+
+@interface MyConsole : NSObject<MyConsole>
+@end
+
+@implementation MyConsole
+- (void)log:(NSString *)s
+{
+ NSLog(@"%@", s);
+}
+
+- (void)printHelloWorld
+{
+ NSLog(@"Hello, World!");
+}
+
+- (int)add:(int)a to:(int)b
+{
+ return a + b;
+}
+@end
+
+@interface DidCreateJavaScriptContextFrameLoadDelegate : NSObject
+@end
+
+@implementation DidCreateJavaScriptContextFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ didFinishLoad = true;
+}
+
+- (void)webView:(WebView *)webView didCreateJavaScriptContext:(JSContext *)context forFrame:(WebFrame *)frame
+{
+ MyConsole *myConsole = [[MyConsole alloc] init];
+ context[@"myConsole"] = myConsole;
+ context.exceptionHandler = nil;
+ [myConsole release];
+
+ context[@"windowCallback"] = ^(JSValue *thisObject){
+ didCallWindowCallback = true;
+ };
+
+ context[@"didCompleteTestSuccessfully"] = ^{
+ didCompleteTestSuccessfully = true;
+ };
+
+ context[@"callMeBack"] = ^(JSValue *functionValue) {
+ [functionValue callWithArguments:[NSArray array]];
+ };
+
+ context[@"checkForMyCustomProperty"] = ^(JSValue *element) {
+ if ([element hasProperty:@"myCustomProperty"] && [[element valueForProperty:@"myCustomProperty"] toInt32] == 42)
+ didFindMyCustomProperty = true;
+ else
+ NSLog(@"ERROR: Did not find myCustomProperty.");
+ };
+
+ context[@"insertMyCustomProperty"] = ^(JSValue *element) {
+ JSValue *fortyTwo = [JSValue valueWithInt32:42 inContext:[JSContext currentContext]];
+ [element setValue:fortyTwo forProperty:@"myCustomProperty"];
+ didInsertMyCustomProperty = true;
+ };
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, DidCreateJavaScriptContextSanity1)
+{
+ didFinishLoad = false;
+ @autoreleasepool {
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<DidCreateJavaScriptContextFrameLoadDelegate> frameLoadDelegate = adoptNS([[DidCreateJavaScriptContextFrameLoadDelegate alloc] init]);
+
+ webView.get().frameLoadDelegate = frameLoadDelegate.get();
+ WebFrame *mainFrame = webView.get().mainFrame;
+
+ NSString *bodyString =
+ @"<body> \
+ <script> \
+ myConsole.printHelloWorld(); \
+ myConsole.log(\"Loaded custom stuff.\"); \
+ myConsole.log(myConsole.addTo(40, 2)); \
+ didCompleteTestSuccessfully(); \
+ </script> \
+ </body>";
+ NSURL *aboutBlankURL = [NSURL URLWithString:@"about:blank"];
+
+ [mainFrame loadHTMLString:bodyString baseURL:aboutBlankURL];
+ Util::run(&didCompleteTestSuccessfully);
+ }
+}
+
+TEST(WebKit1, DidCreateJavaScriptContextSanity2)
+{
+ didCallWindowCallback = false;
+ @autoreleasepool {
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<DidCreateJavaScriptContextFrameLoadDelegate> frameLoadDelegate = adoptNS([[DidCreateJavaScriptContextFrameLoadDelegate alloc] init]);
+
+ webView.get().frameLoadDelegate = frameLoadDelegate.get();
+ WebFrame *mainFrame = webView.get().mainFrame;
+
+ NSString *bodyString =
+ @"<body> \
+ <script> \
+ setTimeout(windowCallback, 100); \
+ </script> \
+ </body>";
+ NSURL *aboutBlankURL = [NSURL URLWithString:@"about:blank"];
+
+ [mainFrame loadHTMLString:bodyString baseURL:aboutBlankURL];
+ Util::run(&didCallWindowCallback);
+ }
+}
+
+TEST(WebKit1, DidCreateJavaScriptContextCallJSFunctionFromObjCCallbackTest)
+{
+ @autoreleasepool {
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<DidCreateJavaScriptContextFrameLoadDelegate> frameLoadDelegate = adoptNS([[DidCreateJavaScriptContextFrameLoadDelegate alloc] init]);
+
+ webView.get().frameLoadDelegate = frameLoadDelegate.get();
+ WebFrame *mainFrame = webView.get().mainFrame;
+
+ NSString *bodyString =
+ @"<body> \
+ <script> \
+ callMeBack(function() { \
+ didCompleteTestSuccessfully(); \
+ }); \
+ </script> \
+ </body>";
+ NSURL *aboutBlankURL = [NSURL URLWithString:@"about:blank"];
+
+ [mainFrame loadHTMLString:bodyString baseURL:aboutBlankURL];
+ Util::run(&didCompleteTestSuccessfully);
+ }
+}
+
+TEST(WebKit1, DidCreateJavaScriptContextAddCustomPropertiesFromJSTest)
+{
+ didFindMyCustomProperty = false;
+ @autoreleasepool {
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<DidCreateJavaScriptContextFrameLoadDelegate> frameLoadDelegate = adoptNS([[DidCreateJavaScriptContextFrameLoadDelegate alloc] init]);
+
+ webView.get().frameLoadDelegate = frameLoadDelegate.get();
+ WebFrame *mainFrame = webView.get().mainFrame;
+
+ NSString *bodyString =
+ @"<body> \
+ <div id=\"test-div\"></div> \
+ <script> \
+ var testDiv = document.getElementById(\"test-div\"); \
+ testDiv.myCustomProperty = 42; \
+ checkForMyCustomProperty(testDiv); \
+ </script> \
+ </body>";
+ NSURL *aboutBlankURL = [NSURL URLWithString:@"about:blank"];
+
+ [mainFrame loadHTMLString:bodyString baseURL:aboutBlankURL];
+ Util::run(&didFindMyCustomProperty);
+ }
+}
+
+TEST(WebKit1, DidCreateJavaScriptContextAddCustomPropertiesFromObjCTest)
+{
+ didFindMyCustomProperty = false;
+ @autoreleasepool {
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<DidCreateJavaScriptContextFrameLoadDelegate> frameLoadDelegate = adoptNS([[DidCreateJavaScriptContextFrameLoadDelegate alloc] init]);
+
+ webView.get().frameLoadDelegate = frameLoadDelegate.get();
+ WebFrame *mainFrame = webView.get().mainFrame;
+
+ NSString *bodyString =
+ @"<body> \
+ <div id=\"test-div\"></div> \
+ <script> \
+ var testDiv = document.getElementById(\"test-div\"); \
+ insertMyCustomProperty(testDiv); \
+ if (testDiv.myCustomProperty === 42) { \
+ checkForMyCustomProperty(testDiv); \
+ } \
+ </script> \
+ </body>";
+ NSURL *aboutBlankURL = [NSURL URLWithString:@"about:blank"];
+
+ [mainFrame loadHTMLString:bodyString baseURL:aboutBlankURL];
+ Util::run(&didFindMyCustomProperty);
+ }
+}
+
+TEST(WebKit1, DidCreateJavaScriptContextBackForwardCacheTest)
+{
+ didInsertMyCustomProperty = false;
+ didFindMyCustomProperty = false;
+ didCompleteTestSuccessfully = false;
+ @autoreleasepool {
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<DidCreateJavaScriptContextFrameLoadDelegate> frameLoadDelegate = adoptNS([[DidCreateJavaScriptContextFrameLoadDelegate alloc] init]);
+
+ webView.get().frameLoadDelegate = frameLoadDelegate.get();
+ WebFrame *mainFrame = webView.get().mainFrame;
+
+ NSURL *url1 = [[NSBundle mainBundle] URLForResource:@"JSContextBackForwardCache1"
+ withExtension:@"html"
+ subdirectory:@"TestWebKitAPI.resources"];
+ [mainFrame loadRequest:[NSURLRequest requestWithURL:url1]];
+ Util::run(&didInsertMyCustomProperty);
+
+ NSURL *url2 = [[NSBundle mainBundle] URLForResource:@"JSContextBackForwardCache2"
+ withExtension:@"html"
+ subdirectory:@"TestWebKitAPI.resources"];
+ [mainFrame loadRequest:[NSURLRequest requestWithURL:url2]];
+ Util::run(&didCompleteTestSuccessfully);
+
+ didCompleteTestSuccessfully = false;
+ [[mainFrame javaScriptContext] evaluateScript:
+ @"var testDiv = document.getElementById(\"test-div\"); \
+ if (!testDiv.myCustomProperty) { \
+ didCompleteTestSuccessfully(); \
+ }"];
+ EXPECT_TRUE(didCompleteTestSuccessfully);
+
+ if ([webView.get() goBack]) {
+ [[mainFrame javaScriptContext] evaluateScript:
+ @"var testDiv = document.getElementById(\"test-div\"); \
+ checkForMyCustomProperty(testDiv);"];
+ EXPECT_TRUE(didFindMyCustomProperty);
+ } else
+ EXPECT_TRUE(false);
+ }
+}
+
+} // namespace TestWebKitAPI
+
+#endif // ENABLE(JSC_OBJC_API)
diff --git a/Tools/TestWebKitAPI/Tests/mac/WebViewDidRemoveFrameFromHierarchy.mm b/Tools/TestWebKitAPI/Tests/mac/WebViewDidRemoveFrameFromHierarchy.mm
new file mode 100644
index 000000000..fbe8af52a
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/WebViewDidRemoveFrameFromHierarchy.mm
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "PlatformUtilities.h"
+#import <WebKit/WebFrameLoadDelegatePrivate.h>
+#import <wtf/RetainPtr.h>
+
+@interface DidRemoveFrameFromHierarchyFrameLoadDelegate : NSObject
+@end
+
+static bool didFinishLoad;
+static bool didRemoveFrame;
+
+@implementation DidRemoveFrameFromHierarchyFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ didFinishLoad = true;
+}
+
+- (void)webView:(WebView *)sender didRemoveFrameFromHierarchy:(WebFrame *)frame
+{
+ didRemoveFrame = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, DidRemoveFrameFromHierarchy)
+{
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<DidRemoveFrameFromHierarchyFrameLoadDelegate> frameLoadDelegate = adoptNS([[DidRemoveFrameFromHierarchyFrameLoadDelegate alloc] init]);
+
+ webView.get().frameLoadDelegate = frameLoadDelegate.get();
+ WebFrame *mainFrame = webView.get().mainFrame;
+
+ NSString *bodyWithIFrameString = @"<body><iframe id='iframe'></iframe></body>";
+ NSURL *aboutBlankURL = [NSURL URLWithString:@"about:blank"];
+
+ [mainFrame loadHTMLString:bodyWithIFrameString baseURL:aboutBlankURL];
+ Util::run(&didFinishLoad);
+
+ EXPECT_FALSE(didRemoveFrame);
+ [webView.get() stringByEvaluatingJavaScriptFromString:@"document.body.removeChild(document.getElementById('iframe'))"];
+ EXPECT_TRUE(didRemoveFrame);
+
+ didFinishLoad = false;
+ didRemoveFrame = false;
+
+ [mainFrame loadHTMLString:bodyWithIFrameString baseURL:aboutBlankURL];
+ Util::run(&didFinishLoad);
+
+ // The delegate method is not called when the frame is removed due to navigation in an ancestor frame.
+ EXPECT_FALSE(didRemoveFrame);
+ [mainFrame loadHTMLString:@"<body></body>" baseURL:aboutBlankURL];
+ EXPECT_FALSE(didRemoveFrame);
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/WillSendSubmitEvent.mm b/Tools/TestWebKitAPI/Tests/mac/WillSendSubmitEvent.mm
new file mode 100644
index 000000000..1654f9ca8
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/WillSendSubmitEvent.mm
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "PlatformUtilities.h"
+#import "PlatformWebView.h"
+#import "Test.h"
+
+#import <WebKit/WebFormDelegate.h>
+#import <WebKit/WebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+static bool didFinishLoad;
+
+@interface FormDelegate : WebFormDelegate
+@end
+
+@implementation FormDelegate
+
+- (void)willSendSubmitEventToForm:(DOMHTMLFormElement *)element inFrame:(WebFrame *)sourceFrame withValues:(NSDictionary *)values
+{
+ EXPECT_NOT_NULL(element);
+ EXPECT_NOT_NULL(sourceFrame);
+
+ EXPECT_WK_STREQ([values objectForKey:@"textField"], @"text field");
+ EXPECT_WK_STREQ([values objectForKey:@"passwordField"], @"password field");
+
+ // <input type="hidden"> fields are not sent.
+ EXPECT_NULL([values objectForKey:@"hiddenField"]);
+
+ didFinishLoad = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, WillSendSubmitEvent)
+{
+ @autoreleasepool {
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+
+ RetainPtr<FormDelegate> formDelegate = [[FormDelegate alloc] init];
+ [webView _setFormDelegate:formDelegate.get()];
+
+ [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"auto-submitting-form" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+
+ Util::run(&didFinishLoad);
+ }
+}
+
+}
diff --git a/Tools/TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.mm b/Tools/TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.mm
index bf593e6ef..9225783ab 100644
--- a/Tools/TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.mm
@@ -65,8 +65,8 @@ TEST(WebKit1, WindowlessWebViewWithMedia)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
- RetainPtr<WindowlessWebViewWithMediaFrameLoadDelegate> testController(AdoptNS, [WindowlessWebViewWithMediaFrameLoadDelegate new]);
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<WindowlessWebViewWithMediaFrameLoadDelegate> testController = adoptNS([WindowlessWebViewWithMediaFrameLoadDelegate new]);
webView.get().frameLoadDelegate = testController.get();
[[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"WindowlessWebViewWithMedia" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];