summaryrefslogtreecommitdiff
path: root/Tools/TestWebKitAPI/Tests/mac
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/TestWebKitAPI/Tests/mac')
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.html9
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.mm92
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorOnBack.mm109
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/DynamicDeviceScaleFactor.mm90
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/RenderedImageFromDOMRange.mm70
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm67
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/SubresourceErrorCrash.mm37
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/devicePixelRatio.html23
8 files changed, 497 insertions, 0 deletions
diff --git a/Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.html b/Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.html
new file mode 100644
index 000000000..539cc0a53
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<body>
+ There is only a single needle in this stack of hay.
+ <iframe src="data:text/html,
+ There are no feathers in here.
+ "></iframe>
+</body>
+</html>
diff --git a/Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.mm b/Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.mm
new file mode 100644
index 000000000..1e8080539
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/DOMRangeOfString.mm
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2011 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/WebViewPrivate.h>
+#import <WebKit/DOM.h>
+#import <wtf/RetainPtr.h>
+
+@interface DOMRangeOfStringFrameLoadDelegate : NSObject {
+}
+@end
+
+static bool didFinishLoad;
+
+@implementation DOMRangeOfStringFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ didFinishLoad = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, DOMRangeOfString)
+{
+ 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"]]];
+
+ Util::run(&didFinishLoad);
+
+ DOMRange *resultRange = [webView.get() DOMRangeOfString:@"needles" relativeTo:nil options:0];
+ EXPECT_EQ(nil, resultRange);
+
+ DOMRange *needleRange = [webView.get() DOMRangeOfString:@"needle" relativeTo:nil options:0];
+ EXPECT_EQ(28, needleRange.startOffset);
+
+ resultRange = [webView.get() DOMRangeOfString:@"stack" relativeTo:needleRange options:0];
+ EXPECT_EQ(43, resultRange.startOffset);
+
+ resultRange = [webView.get() DOMRangeOfString:@"stack" relativeTo:needleRange options:WebFindOptionsBackwards];
+ EXPECT_EQ(nil, resultRange);
+
+ resultRange = [webView.get() DOMRangeOfString:@"n" relativeTo:needleRange options:0];
+ EXPECT_EQ(36, resultRange.startOffset);
+
+ 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]);
+ DOMRange *foreignRange = [[[otherWebView.get() mainFrame] DOMDocument] createRange];
+ resultRange = [webView.get() DOMRangeOfString:@"needle" relativeTo:foreignRange options:0];
+ EXPECT_EQ(nil, resultRange);
+
+ resultRange = [webView.get() DOMRangeOfString:@"here" relativeTo:needleRange options:0];
+ EXPECT_EQ(1, resultRange.startOffset);
+
+ resultRange = [webView.get() DOMRangeOfString:@"here" relativeTo:resultRange options:0];
+ EXPECT_EQ(25, resultRange.startOffset);
+
+ resultRange = [webView.get() DOMRangeOfString:@"here" relativeTo:resultRange options:WebFindOptionsWrapAround];
+ EXPECT_EQ(6, resultRange.startOffset);
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorOnBack.mm b/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorOnBack.mm
new file mode 100644
index 000000000..154b8c32c
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorOnBack.mm
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2011 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 "WebKitAgnosticTest.h"
+
+#include "JavaScriptTest.h"
+#include "PlatformUtilities.h"
+#include "SyntheticBackingScaleFactorWindow.h"
+#include <WebKit2/WKViewPrivate.h>
+#include <wtf/RetainPtr.h>
+
+namespace TestWebKitAPI {
+
+class DeviceScaleFactorOnBack : public WebKitAgnosticTest {
+public:
+ RetainPtr<SyntheticBackingScaleFactorWindow> createWindow();
+
+ template <typename View> void runTest(View);
+
+ // WebKitAgnosticTest
+ virtual NSURL *url() const { return [[NSBundle mainBundle] URLForResource:@"devicePixelRatio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]; }
+ virtual void didLoadURL(WebView *webView) { runTest(webView); }
+ virtual void didLoadURL(WKView *wkView) { runTest(wkView); }
+ virtual void initializeView(WebView *);
+ virtual void initializeView(WKView *);
+};
+
+RetainPtr<SyntheticBackingScaleFactorWindow> DeviceScaleFactorOnBack::createWindow()
+{
+ RetainPtr<SyntheticBackingScaleFactorWindow> window(AdoptNS, [[SyntheticBackingScaleFactorWindow alloc] initWithContentRect:viewFrame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+ [window.get() setReleasedWhenClosed:NO];
+ return window;
+}
+
+void DeviceScaleFactorOnBack::initializeView(WebView *view)
+{
+ // The default cache model has a capacity of 0, so it is necessary to switch to a cache
+ // model that actuall caches things.
+ [[view preferences] setCacheModel:WebCacheModelDocumentBrowser];
+}
+
+void DeviceScaleFactorOnBack::initializeView(WKView *view)
+{
+ // The default cache model has a capacity of 0, so it is necessary to switch to a cache
+ // model that actuall caches things.
+ WKContextSetCacheModel(WKPageGetContext([view pageRef]), kWKCacheModelDocumentBrowser);
+}
+
+template <typename View>
+void DeviceScaleFactorOnBack::runTest(View view)
+{
+ EXPECT_JS_EQ(view, "window.devicePixelRatio", "1");
+ EXPECT_JS_EQ(view, "devicePixelRatioFromStyle()", "1");
+
+ // Navigate to new URL
+ loadURL(view, [NSURL URLWithString:@"about:blank"]);
+ waitForLoadToFinish();
+
+ // Change the scale factor
+ RetainPtr<SyntheticBackingScaleFactorWindow> window1 = createWindow();
+ [window1.get() setBackingScaleFactor:3];
+
+ [[window1.get() contentView] addSubview:view];
+
+ // Navigate back to the first page
+ goBack(view);
+ waitForLoadToFinish();
+
+ // Ensure that the cached page has updated its scale factor
+ EXPECT_JS_EQ(view, "window.devicePixelRatio", "3");
+ EXPECT_JS_EQ(view, "devicePixelRatioFromStyle()", "3");
+
+ [view removeFromSuperview];
+}
+
+TEST_F(DeviceScaleFactorOnBack, WebKit)
+{
+ runWebKit1Test();
+}
+
+TEST_F(DeviceScaleFactorOnBack, WebKit2)
+{
+ runWebKit2Test();
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/DynamicDeviceScaleFactor.mm b/Tools/TestWebKitAPI/Tests/mac/DynamicDeviceScaleFactor.mm
new file mode 100644
index 000000000..d0ebd5177
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/DynamicDeviceScaleFactor.mm
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2011 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 "WebKitAgnosticTest.h"
+
+#include "JavaScriptTest.h"
+#include "PlatformUtilities.h"
+#include "SyntheticBackingScaleFactorWindow.h"
+#include <wtf/RetainPtr.h>
+
+namespace TestWebKitAPI {
+
+class DynamicDeviceScaleFactor : public WebKitAgnosticTest {
+public:
+ RetainPtr<SyntheticBackingScaleFactorWindow> createWindow();
+
+ template <typename View> void runTest(View);
+
+ // WebKitAgnosticTest
+ virtual NSURL *url() const { return [[NSBundle mainBundle] URLForResource:@"devicePixelRatio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]; }
+ virtual void didLoadURL(WebView *webView) { runTest(webView); }
+ virtual void didLoadURL(WKView *wkView) { runTest(wkView); }
+};
+
+RetainPtr<SyntheticBackingScaleFactorWindow> DynamicDeviceScaleFactor::createWindow()
+{
+ RetainPtr<SyntheticBackingScaleFactorWindow> window(AdoptNS, [[SyntheticBackingScaleFactorWindow alloc] initWithContentRect:viewFrame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+ [window.get() setReleasedWhenClosed:NO];
+ return window;
+}
+
+template <typename View>
+void DynamicDeviceScaleFactor::runTest(View view)
+{
+ EXPECT_JS_EQ(view, "window.devicePixelRatio", "1");
+ EXPECT_JS_EQ(view, "devicePixelRatioFromStyle()", "1");
+
+ RetainPtr<SyntheticBackingScaleFactorWindow> window1 = createWindow();
+ [window1.get() setBackingScaleFactor:3];
+
+ [[window1.get() contentView] addSubview:view];
+ EXPECT_JS_EQ(view, "window.devicePixelRatio", "3");
+ EXPECT_JS_EQ(view, "devicePixelRatioFromStyle()", "3");
+
+ RetainPtr<SyntheticBackingScaleFactorWindow> window2 = createWindow();
+ [window2.get() setBackingScaleFactor:4];
+
+ [[window2.get() contentView] addSubview:view];
+ EXPECT_JS_EQ(view, "window.devicePixelRatio", "4");
+ EXPECT_JS_EQ(view, "devicePixelRatioFromStyle()", "4");
+
+ [view removeFromSuperview];
+ EXPECT_JS_EQ(view, "window.devicePixelRatio", "1");
+ EXPECT_JS_EQ(view, "devicePixelRatioFromStyle()", "1");
+}
+
+TEST_F(DynamicDeviceScaleFactor, WebKit)
+{
+ runWebKit1Test();
+}
+
+TEST_F(DynamicDeviceScaleFactor, WebKit2)
+{
+ runWebKit2Test();
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/RenderedImageFromDOMRange.mm b/Tools/TestWebKitAPI/Tests/mac/RenderedImageFromDOMRange.mm
new file mode 100644
index 000000000..4bda16798
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/RenderedImageFromDOMRange.mm
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2011 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/WebDocumentPrivate.h>
+#import <WebKit/DOMPrivate.h>
+#import <wtf/RetainPtr.h>
+
+@interface RenderedImageFromDOMRangeFrameLoadDelegate : NSObject {
+}
+@end
+
+static bool didFinishLoad;
+
+@implementation RenderedImageFromDOMRangeFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ didFinishLoad = true;
+}
+
+@end
+
+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]);
+
+ 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"]];
+
+ Util::run(&didFinishLoad);
+
+ DOMDocument *document = webView.get().mainFrameDocument;
+ DOMRange *range = [document createRange];
+ [range selectNode:[document getElementById:@"target"]];
+ NSImage *actualImage = [range renderedImageForcingBlackText:YES];
+
+ [webView.get() setSelectedDOMRange:range affinity:NSSelectionAffinityDownstream];
+ id <WebDocumentView> documentView = webView.get().mainFrame.frameView.documentView;
+ NSImage *expectedImage = [(id <WebDocumentSelection>)documentView selectionImageForcingBlackText:YES];
+ EXPECT_TRUE([actualImage.TIFFRepresentation isEqual:expectedImage.TIFFRepresentation]);
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm b/Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm
new file mode 100644
index 000000000..1e64fb794
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2007, 2011 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>
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, StringByEvaluatingJavaScriptFromString)
+{
+ // maps expected result <= JavaScript expression
+ RetainPtr<NSDictionary> expressions(AdoptNS, [[NSDictionary alloc] initWithObjectsAndKeys:
+ @"0", @"0",
+ @"0", @"'0'",
+ @"", @"",
+ @"", @"''",
+ @"", @"new String()",
+ @"", @"new String('0')",
+ @"", @"throw 1",
+ @"", @"{ }",
+ @"", @"[ ]",
+ @"", @"//",
+ @"", @"a.b.c",
+ @"", @"(function() { throw 'error'; })()",
+ @"", @"null",
+ @"", @"undefined",
+ @"true", @"true",
+ @"false", @"false",
+ @"", @"alert('Should not be result')",
+ nil
+ ]);
+
+ RetainPtr<WebView> webView (AdoptNS, [[WebView alloc] initWithFrame:NSZeroRect frameName:@"" groupName:@""]);
+
+ for (id expression in expressions.get()) {
+ NSString *expectedResult = [expressions.get() objectForKey:expression];
+ NSString *result = [webView.get() stringByEvaluatingJavaScriptFromString:expression];
+ EXPECT_WK_STREQ(expectedResult, result);
+ }
+
+ [webView.get() close];
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/SubresourceErrorCrash.mm b/Tools/TestWebKitAPI/Tests/mac/SubresourceErrorCrash.mm
new file mode 100644
index 000000000..870a4896a
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/SubresourceErrorCrash.mm
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2011 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"
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, SubresourceErrorCrash)
+{
+ WebView *webView = [[WebView alloc] initWithFrame:NSZeroRect frameName:@"" groupName:@""];
+ [webView.mainFrame loadHTMLString:@"<link rel=stylesheet href='x-error:error'>" baseURL:nil];
+ [webView release];
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/devicePixelRatio.html b/Tools/TestWebKitAPI/Tests/mac/devicePixelRatio.html
new file mode 100644
index 000000000..f6acf8678
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/devicePixelRatio.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<style>
+ #detector { width: 5px; }
+ @media (-webkit-device-pixel-ratio:1) { #detector { width: 10px; } }
+ @media (-webkit-device-pixel-ratio:3) { #detector { width: 30px; } }
+ @media (-webkit-device-pixel-ratio:4) { #detector { width: 40px; } }
+</style>
+<script>
+ function devicePixelRatioFromStyle() {
+ var width = getComputedStyle(document.getElementById("detector")).width;
+ switch (width) {
+ case "10px":
+ return 1;
+ case "30px":
+ return 3;
+ case "40px":
+ return 4;
+ default:
+ return "unknown width: " + width;
+ }
+ }
+</script>
+<div id="detector"></div>