Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: Tools/TestWebKitAPI/Tests/mac/SetDocumentURI.mm

Issue 13602008: Remove non-chromium code from TestWebKitAPI (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"
27 #include "PlatformUtilities.h"
28 #include "PlatformWebView.h"
29 #include <wtf/RetainPtr.h>
30
31 #import <WebKit/DOM.h>
32 #import <WebKit/WebViewPrivate.h>
33
34 @interface SetDocumentURITest : NSObject {
35 }
36 @end
37
38 static bool didFinishLoad;
39
40 @implementation SetDocumentURITest
41
42 - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
43 {
44 didFinishLoad = true;
45 }
46 @end
47
48 namespace TestWebKitAPI {
49
50 TEST(WebKit1, SetDocumentURITestFile)
51 {
52 RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRec t(0, 0, 120, 200) frameName:nil groupName:nil]);
53 RetainPtr<SetDocumentURITest> testController(AdoptNS, [SetDocumentURITest ne w]);
54 webView.get().frameLoadDelegate = testController.get();
55 [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBund le mainBundle] URLForResource:@"SetDocumentURI" withExtension:@"html" subdirecto ry:@"TestWebKitAPI.resources"]]];
56 Util::run(&didFinishLoad);
57 didFinishLoad = false;
58 DOMDocument *document = webView.get().mainFrameDocument;
59
60 [document setDocumentURI:@"file:///test"];
61 // documentURI set correctly.
62 EXPECT_WK_STREQ(@"file:///test", [document documentURI]);
63 // baseURI follows along.
64 EXPECT_WK_STREQ(@"file:///test", [document baseURI]);
65 }
66
67 TEST(WebKit1, SetDocumentURITestURL)
68 {
69 RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRec t(0, 0, 120, 200) frameName:nil groupName:nil]);
70 RetainPtr<SetDocumentURITest> testController(AdoptNS, [SetDocumentURITest ne w]);
71 webView.get().frameLoadDelegate = testController.get();
72 [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBund le mainBundle] URLForResource:@"SetDocumentURI" withExtension:@"html" subdirecto ry:@"TestWebKitAPI.resources"]]];
73 Util::run(&didFinishLoad);
74 didFinishLoad = false;
75 DOMDocument *document = webView.get().mainFrameDocument;
76
77 [document setDocumentURI:@"http://example.com/"];
78 // documentURI set correctly.
79 EXPECT_WK_STREQ(@"http://example.com/", [document documentURI]);
80 // baseURI follows along.
81 EXPECT_WK_STREQ(@"http://example.com/", [document baseURI]);
82 // Relative links too.
83 NSString *result = [webView.get() stringByEvaluatingJavaScriptFromString:@"d ocument.getElementById('relative').href"];
84 EXPECT_WK_STREQ(@"http://example.com/relativeURL.html", result);
85 }
86
87 TEST(WebKit1, SetDocumentURITestString)
88 {
89 RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRec t(0, 0, 120, 200) frameName:nil groupName:nil]);
90 RetainPtr<SetDocumentURITest> testController(AdoptNS, [SetDocumentURITest ne w]);
91 webView.get().frameLoadDelegate = testController.get();
92 [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBund le mainBundle] URLForResource:@"SetDocumentURI" withExtension:@"html" subdirecto ry:@"TestWebKitAPI.resources"]]];
93 Util::run(&didFinishLoad);
94 didFinishLoad = false;
95 DOMDocument *document = webView.get().mainFrameDocument;
96
97 [document setDocumentURI:@"A non-URL string."];
98 // documentURI accepts random strings.
99 EXPECT_WK_STREQ(@"A non-URL string.", [document documentURI]);
100 // baseURI is empty for non-URL strings.
101 EXPECT_WK_STREQ(@"", [document baseURI]);
102 }
103
104 TEST(WebKit1, SetDocumentURITestNull)
105 {
106 RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRec t(0, 0, 120, 200) frameName:nil groupName:nil]);
107 RetainPtr<SetDocumentURITest> testController(AdoptNS, [SetDocumentURITest ne w]);
108 webView.get().frameLoadDelegate = testController.get();
109 [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBund le mainBundle] URLForResource:@"SetDocumentURI" withExtension:@"html" subdirecto ry:@"TestWebKitAPI.resources"]]];
110 Util::run(&didFinishLoad);
111 didFinishLoad = false;
112 DOMDocument *document = webView.get().mainFrameDocument;
113
114 [document setDocumentURI:nil];
115 // documenturi is empty.
116 EXPECT_WK_STREQ(@"", [document documentURI]);
117 // baseURI is null as well.
118 EXPECT_WK_STREQ(@"", [document baseURI]);
119 }
120
121 } // namespace TestWebKitAPI
OLDNEW
« no previous file with comments | « Tools/TestWebKitAPI/Tests/mac/SetDocumentURI.html ('k') | Tools/TestWebKitAPI/Tests/mac/SimplifyMarkup.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698