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

Side by Side Diff: Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp

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 Apple 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 "Test.h"
30 #include <WebKit2/WKRetainPtr.h>
31 #include <wtf/Vector.h>
32
33 namespace TestWebKitAPI {
34
35 static bool finished;
36
37 static const char* expectedMessages[] = {
38 "GlobalObjectIsAvailableForFrame called",
39 "GlobalObjectIsAvailableForFrame called",
40 "GlobalObjectIsAvailableForFrame called",
41 "GlobalObjectIsAvailableForFrame called",
42 "Subframe finished loading",
43 "Extension states:\nFirst page, main frame, standard world - Connected\nFirst pa ge, main frame, non-standard world - Connected\nFirst page, subframe, standard w orld - Connected\nFirst page, subframe, non-standard world - Connected\nSecond p age, main frame, standard world - Uncreated\nSecond page, main frame, non-standa rd world - Uncreated",
44 "Main frame finished loading",
45 "Extension states:\nFirst page, main frame, standard world - Connected\nFirst pa ge, main frame, non-standard world - Connected\nFirst page, subframe, standard w orld - Connected\nFirst page, subframe, non-standard world - Connected\nSecond p age, main frame, standard world - Uncreated\nSecond page, main frame, non-standa rd world - Uncreated",
46 "WillDisconnectDOMWindowExtensionFromGlobalObject called",
47 "WillDisconnectDOMWindowExtensionFromGlobalObject called",
48 "WillDisconnectDOMWindowExtensionFromGlobalObject called",
49 "WillDisconnectDOMWindowExtensionFromGlobalObject called",
50 "GlobalObjectIsAvailableForFrame called",
51 "GlobalObjectIsAvailableForFrame called",
52 "Main frame finished loading",
53 "Extension states:\nFirst page, main frame, standard world - Disconnected\nFirst page, main frame, non-standard world - Disconnected\nFirst page, subframe, stan dard world - Disconnected\nFirst page, subframe, non-standard world - Disconnect ed\nSecond page, main frame, standard world - Connected\nSecond page, main frame , non-standard world - Connected",
54 "WillDisconnectDOMWindowExtensionFromGlobalObject called",
55 "WillDisconnectDOMWindowExtensionFromGlobalObject called",
56 "DidReconnectDOMWindowExtensionToGlobalObject called",
57 "DidReconnectDOMWindowExtensionToGlobalObject called",
58 "DidReconnectDOMWindowExtensionToGlobalObject called",
59 "DidReconnectDOMWindowExtensionToGlobalObject called",
60 "Main frame finished loading",
61 "Extension states:\nFirst page, main frame, standard world - Connected\nFirst pa ge, main frame, non-standard world - Connected\nFirst page, subframe, standard w orld - Connected\nFirst page, subframe, non-standard world - Connected\nSecond p age, main frame, standard world - Disconnected\nSecond page, main frame, non-sta ndard world - Disconnected",
62 "Extension states:\nFirst page, main frame, standard world - Removed\nFirst page , main frame, non-standard world - Removed\nFirst page, subframe, standard world - Removed\nFirst page, subframe, non-standard world - Removed\nSecond page, mai n frame, standard world - Removed\nSecond page, main frame, non-standard world - Removed",
63 "TestComplete"
64 };
65
66 static Vector<WKRetainPtr<WKStringRef> > messages;
67
68 static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messag eName, WKTypeRef messageBody, const void*)
69 {
70 ASSERT_NOT_NULL(messageBody);
71 EXPECT_EQ(WKStringGetTypeID(), WKGetTypeID(messageBody));
72
73 WKStringRef bodyString = (WKStringRef)messageBody;
74 messages.append(bodyString);
75
76 if (WKStringIsEqualToUTF8CString(messageName, "DidFinishLoadForMainFrame") | | WKStringIsEqualToUTF8CString(messageName, "TestComplete"))
77 finished = true;
78 }
79
80 TEST(WebKit2, DISABLED_DOMWindowExtensionBasic)
81 {
82 WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifi er(WKStringCreateWithUTF8CString("DOMWindowExtensionBasicPageGroup")));
83
84 WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBun dleTest("DOMWindowExtensionBasic", pageGroup.get()));
85
86 WKContextInjectedBundleClient injectedBundleClient;
87 memset(&injectedBundleClient, 0, sizeof(injectedBundleClient));
88 injectedBundleClient.version = 0;
89 injectedBundleClient.clientInfo = 0;
90 injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessage FromInjectedBundle;
91 WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient);
92
93 // The default cache model has a capacity of 0, so it is necessary to switch to a cache
94 // model that actually allows for a page cache.
95 WKContextSetCacheModel(context.get(), kWKCacheModelDocumentBrowser);
96
97 PlatformWebView webView(context.get(), pageGroup.get());
98
99 // Make sure the extensions for each frame are installed in each world.
100 WKRetainPtr<WKURLRef> url1(AdoptWK, Util::createURLForResource("simple-ifram e", "html"));
101 WKPageLoadURL(webView.page(), url1.get());
102
103 Util::run(&finished);
104 finished = false;
105
106 // Make sure those first 4 extensions are disconnected, and 2 new ones are i nstalled.
107 WKRetainPtr<WKURLRef> url2(AdoptWK, Util::createURLForResource("simple", "ht ml"));
108 WKPageLoadURL(webView.page(), url2.get());
109
110 Util::run(&finished);
111 finished = false;
112
113 // Make sure those two are disconnected, and the first four are reconnected.
114 WKPageGoBack(webView.page());
115
116 Util::run(&finished);
117 finished = false;
118
119 // Make sure the 2 disconnected extensions in the page cache and the 4 activ e extensions are all removed.
120 WKPageClose(webView.page());
121
122 Util::run(&finished);
123
124 const size_t expectedSize = sizeof(expectedMessages) / sizeof(const char*);
125 EXPECT_EQ(expectedSize, messages.size());
126
127 if (messages.size() != expectedSize)
128 return;
129
130 for (size_t i = 0; i < messages.size(); ++i)
131 EXPECT_WK_STREQ(expectedMessages[i], messages[i].get());
132 }
133
134 } // namespace TestWebKitAPI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698