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

Side by Side Diff: Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionNoCache.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 <wtf/Vector.h>
31
32 namespace TestWebKitAPI {
33
34 static bool finished;
35
36 static const char* expectedMessages[] = {
37 "GlobalObjectIsAvailableForFrame called",
38 "GlobalObjectIsAvailableForFrame called",
39 "GlobalObjectIsAvailableForFrame called",
40 "GlobalObjectIsAvailableForFrame called",
41 "Subframe finished loading",
42 "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\nFirst page, main frame, standard world - Uncreated\nFirst page, main frame, non-standard world - Uncreated\nFirst page, subframe, standard world - Uncreated\nFirst page, subframe, non-standard world - Uncreated",
43 "Main frame finished loading",
44 "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\nFirst page, main frame, standard world - Uncreated\nFirst page, main frame, non-standard world - Uncreated\nFirst page, subframe, standard world - Uncreated\nFirst page, subframe, non-standard world - Uncreated",
45 "WillDestroyDOMWindowExtensionToGlobalObject called",
46 "WillDestroyDOMWindowExtensionToGlobalObject called",
47 "WillDestroyDOMWindowExtensionToGlobalObject called",
48 "WillDestroyDOMWindowExtensionToGlobalObject called",
49 "GlobalObjectIsAvailableForFrame called",
50 "GlobalObjectIsAvailableForFrame called",
51 "Main frame finished loading",
52 "Extension states:\nFirst page, main frame, standard world - Destroyed\nFirst pa ge, main frame, non-standard world - Destroyed\nFirst page, subframe, standard w orld - Destroyed\nFirst page, subframe, non-standard world - Destroyed\nSecond p age, main frame, standard world - Connected\nSecond page, main frame, non-standa rd world - Connected\nFirst page, main frame, standard world - Uncreated\nFirst page, main frame, non-standard world - Uncreated\nFirst page, subframe, standard world - Uncreated\nFirst page, subframe, non-standard world - Uncreated",
53 "WillDestroyDOMWindowExtensionToGlobalObject called",
54 "WillDestroyDOMWindowExtensionToGlobalObject called",
55 "GlobalObjectIsAvailableForFrame called",
56 "GlobalObjectIsAvailableForFrame called",
57 "GlobalObjectIsAvailableForFrame called",
58 "GlobalObjectIsAvailableForFrame called",
59 "Subframe finished loading",
60 "Extension states:\nFirst page, main frame, standard world - Destroyed\nFirst pa ge, main frame, non-standard world - Destroyed\nFirst page, subframe, standard w orld - Destroyed\nFirst page, subframe, non-standard world - Destroyed\nSecond p age, main frame, standard world - Destroyed\nSecond page, main frame, non-standa rd world - Destroyed\nFirst page, main frame, standard world - Connected\nFirst page, main frame, non-standard world - Connected\nFirst page, subframe, standard world - Connected\nFirst page, subframe, non-standard world - Connected",
61 "Main frame finished loading",
62 "Extension states:\nFirst page, main frame, standard world - Destroyed\nFirst pa ge, main frame, non-standard world - Destroyed\nFirst page, subframe, standard w orld - Destroyed\nFirst page, subframe, non-standard world - Destroyed\nSecond p age, main frame, standard world - Destroyed\nSecond page, main frame, non-standa rd world - Destroyed\nFirst page, main frame, standard world - Connected\nFirst page, main frame, non-standard world - Connected\nFirst page, subframe, standard world - Connected\nFirst page, subframe, non-standard world - Connected",
63 "Extension states:\nFirst page, main frame, standard world - Destroyed\nFirst pa ge, main frame, non-standard world - Destroyed\nFirst page, subframe, standard w orld - Destroyed\nFirst page, subframe, non-standard world - Destroyed\nSecond p age, main frame, standard world - Destroyed\nSecond page, main frame, non-standa rd world - Destroyed\nFirst page, main frame, standard world - Removed\nFirst pa ge, main frame, non-standard world - Removed\nFirst page, subframe, standard wor ld - Removed\nFirst page, subframe, non-standard world - Removed",
64 "TestComplete"
65 };
66
67 static Vector<WKRetainPtr<WKStringRef> > messages;
68
69 static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messag eName, WKTypeRef messageBody, const void*)
70 {
71 ASSERT_NOT_NULL(messageBody);
72 EXPECT_EQ(WKStringGetTypeID(), WKGetTypeID(messageBody));
73
74 WKStringRef bodyString = (WKStringRef)messageBody;
75 messages.append(bodyString);
76
77 if (WKStringIsEqualToUTF8CString(messageName, "DidFinishLoadForMainFrame") | | WKStringIsEqualToUTF8CString(messageName, "TestComplete"))
78 finished = true;
79 }
80
81 TEST(WebKit2, DOMWindowExtensionNoCache)
82 {
83 WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifi er(WKStringCreateWithUTF8CString("DOMWindowExtensionNoCachePageGroup")));
84
85 WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBun dleTest("DOMWindowExtensionNoCache", pageGroup.get()));
86
87 WKContextInjectedBundleClient injectedBundleClient;
88 memset(&injectedBundleClient, 0, sizeof(injectedBundleClient));
89 injectedBundleClient.version = kWKContextInjectedBundleClientCurrentVersion;
90 injectedBundleClient.clientInfo = 0;
91 injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessage FromInjectedBundle;
92 WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient);
93
94 // Disable the page cache.
95 WKContextSetCacheModel(context.get(), kWKCacheModelDocumentViewer);
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 destroyed, and 2 new ones are inst alled.
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 2 are destroyed, and the first 4 are recreated.
114 WKPageGoBack(webView.page());
115
116 Util::run(&finished);
117 finished = false;
118
119 WKPageClose(webView.page());
120
121 Util::run(&finished);
122
123 const size_t expectedSize = sizeof(expectedMessages) / sizeof(const char*);
124 EXPECT_EQ(expectedSize, messages.size());
125
126 if (messages.size() != expectedSize)
127 return;
128
129 for (size_t i = 0; i < messages.size(); ++i)
130 EXPECT_WK_STREQ(expectedMessages[i], messages[i].get());
131 }
132
133 } // namespace TestWebKitAPI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698