summaryrefslogtreecommitdiff
path: root/Tools/TestWebKitAPI
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-11 09:43:24 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-11 09:43:24 +0200
commit1b914638db989aaa98631a1c1e02c7b2d44805d8 (patch)
tree87f4fd2c7b38db320079a5de8877890d2ca3c485 /Tools/TestWebKitAPI
parent2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (diff)
downloadqtwebkit-1b914638db989aaa98631a1c1e02c7b2d44805d8.tar.gz
Imported WebKit commit 9a52e27980f47e8b0d8f8b7cc0fd7b5741bceb92 (http://svn.webkit.org/repository/webkit/trunk@116736)
New snapshot to include QDeclarative* -> QQml* build fixes
Diffstat (limited to 'Tools/TestWebKitAPI')
-rw-r--r--Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj26
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp26
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp42
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionNoCache.cpp133
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionNoCache_Bundle.cpp279
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp8
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2/simple-iframe-unload.html6
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2/simple-unload.html5
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.html14
-rw-r--r--Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.mm90
10 files changed, 590 insertions, 39 deletions
diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
index 85c365cc3..6225f04dd 100644
--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
@@ -141,9 +141,15 @@
C507E8A714C6545B005D6B3B /* InspectorBar.mm in Sources */ = {isa = PBXBuildFile; fileRef = C507E8A614C6545B005D6B3B /* InspectorBar.mm */; };
C540F776152E4DA000A40C8C /* SimplifyMarkup.mm in Sources */ = {isa = PBXBuildFile; fileRef = C540F775152E4DA000A40C8C /* SimplifyMarkup.mm */; };
C540F784152E5A9A00A40C8C /* verboseMarkup.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C540F783152E5A7800A40C8C /* verboseMarkup.html */; };
+ E1220DA0155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */; };
+ E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
E490296814E2E3A4002BEDD1 /* TypingStyleCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */; };
F3FC3EE313678B7300126A65 /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F3FC3EE213678B7300126A65 /* libgtest.a */; };
+ F6A6BFBB1558AC4800926107 /* simple-unload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F6A6BFB91558ABF800926107 /* simple-unload.html */; };
+ F6A6BFBC1558AC4B00926107 /* simple-iframe-unload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F6A6BFB81558ABF800926107 /* simple-iframe-unload.html */; };
F6F3F29113342FEB00A6BF19 /* CookieManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */; };
+ F6F49C6915545C8E0007F39D /* DOMWindowExtensionNoCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F49C6715545C8D0007F39D /* DOMWindowExtensionNoCache.cpp */; };
+ F6F49C6B15545CA70007F39D /* DOMWindowExtensionNoCache_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F49C6615545C8D0007F39D /* DOMWindowExtensionNoCache_Bundle.cpp */; };
F6FDDDD314241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */; };
F6FDDDD614241C6F004F1729 /* push-state.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F6FDDDD514241C48004F1729 /* push-state.html */; };
/* End PBXBuildFile section */
@@ -178,6 +184,7 @@
B55F11B71517D03300915916 /* attributedStringCustomFont.html in Copy Resources */,
76E182DF154767E600F1FADD /* auto-submitting-form.html in Copy Resources */,
5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */,
+ E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */,
517E7E04151119C100D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html in Copy Resources */,
379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */,
@@ -190,7 +197,9 @@
F6FDDDD614241C6F004F1729 /* push-state.html in Copy Resources */,
BCBD3737125ABBEB00D2C29F /* icon.png in Copy Resources */,
1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */,
+ F6A6BFBC1558AC4B00926107 /* simple-iframe-unload.html in Copy Resources */,
BC909784125571CF00083756 /* simple.html in Copy Resources */,
+ F6A6BFBB1558AC4800926107 /* simple-unload.html in Copy Resources */,
C0ADBE9612FCA79B00D2C129 /* simple-form.html in Copy Resources */,
BCAA485614A0444C0088FAC4 /* simple-tall.html in Copy Resources */,
C01A23F21266156700C9ED55 /* spacebar-scrolling.html in Copy Resources */,
@@ -354,9 +363,15 @@
C507E8A614C6545B005D6B3B /* InspectorBar.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InspectorBar.mm; sourceTree = "<group>"; };
C540F775152E4DA000A40C8C /* SimplifyMarkup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimplifyMarkup.mm; sourceTree = "<group>"; };
C540F783152E5A7800A40C8C /* verboseMarkup.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = verboseMarkup.html; sourceTree = "<group>"; };
+ E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheDisableWithinResourceLoadDelegate.mm; sourceTree = "<group>"; };
+ E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = MemoryCacheDisableWithinResourceLoadDelegate.html; sourceTree = "<group>"; };
E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TypingStyleCrash.mm; sourceTree = "<group>"; };
F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ F6A6BFB81558ABF800926107 /* simple-iframe-unload.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-iframe-unload.html"; sourceTree = "<group>"; };
+ F6A6BFB91558ABF800926107 /* simple-unload.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-unload.html"; sourceTree = "<group>"; };
F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CookieManager.cpp; sourceTree = "<group>"; };
+ F6F49C6615545C8D0007F39D /* DOMWindowExtensionNoCache_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionNoCache_Bundle.cpp; sourceTree = "<group>"; };
+ F6F49C6715545C8D0007F39D /* DOMWindowExtensionNoCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionNoCache.cpp; sourceTree = "<group>"; };
F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateBrowsingPushStateNoHistoryCallback.cpp; sourceTree = "<group>"; };
F6FDDDD514241C48004F1729 /* push-state.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "push-state.html"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -501,6 +516,8 @@
F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */,
51393E1E1523944A005F39C5 /* DOMWindowExtensionBasic.cpp */,
51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */,
+ F6F49C6715545C8D0007F39D /* DOMWindowExtensionNoCache.cpp */,
+ F6F49C6615545C8D0007F39D /* DOMWindowExtensionNoCache_Bundle.cpp */,
BCB6803F126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp */,
BCB68041126FBFF100642A61 /* DocumentStartUserScriptAlertCrash_Bundle.cpp */,
C045F9441385C2E900C0F3CD /* DownloadDecideDestinationCrash.cpp */,
@@ -589,7 +606,9 @@
1ADBEFBC130C6A0100D61D19 /* simple-accelerated-compositing.html */,
C0ADBE8412FCA6B600D2C129 /* simple-form.html */,
33DC890E1419539300747EF7 /* simple-iframe.html */,
+ F6A6BFB81558ABF800926107 /* simple-iframe-unload.html */,
BCAA485514A021640088FAC4 /* simple-tall.html */,
+ F6A6BFB91558ABF800926107 /* simple-unload.html */,
BC909778125571AB00083756 /* simple.html */,
C02B7882126615410026BF0F /* spacebar-scrolling.html */,
76E182DE15475A8300F1FADD /* auto-submitting-form.html */,
@@ -640,6 +659,7 @@
3776BC62150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm */,
939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */,
C507E8A614C6545B005D6B3B /* InspectorBar.mm */,
+ E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */,
517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */,
3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */,
C540F775152E4DA000A40C8C /* SimplifyMarkup.mm */,
@@ -659,8 +679,9 @@
379028B814FABE49007E6B43 /* acceptsFirstMouse.html */,
5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */,
37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */,
- C07E6CB113FD738A0038B22B /* devicePixelRatio.html */,
+ E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */,
517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */,
+ C07E6CB113FD738A0038B22B /* devicePixelRatio.html */,
C540F783152E5A7800A40C8C /* verboseMarkup.html */,
);
name = Resources;
@@ -864,6 +885,8 @@
51FCF79A1534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp in Sources */,
51393E201523944A005F39C5 /* DOMWindowExtensionBasic.cpp in Sources */,
76E182DA1547550100F1FADD /* WillSendSubmitEvent.cpp in Sources */,
+ E1220DA0155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm in Sources */,
+ F6F49C6915545C8E0007F39D /* DOMWindowExtensionNoCache.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -895,6 +918,7 @@
51FCF7A11534B2A000104491 /* ShouldGoToBackForwardListItem_Bundle.cpp in Sources */,
51393E221523952D005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp in Sources */,
76E182DD1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp in Sources */,
+ F6F49C6B15545CA70007F39D /* DOMWindowExtensionNoCache_Bundle.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp
index b78ee91af..8be4440c2 100644
--- a/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp
+++ b/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp
@@ -33,7 +33,6 @@
namespace TestWebKitAPI {
static bool finished;
-static int liveDOMExtensionCount;
static const char* expectedMessages[] = {
"GlobalObjectIsAvailableForFrame called",
@@ -60,13 +59,7 @@ static const char* expectedMessages[] = {
"DidReconnectDOMWindowExtensionToGlobalObject called",
"Main frame finished loading",
"Extension states:\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\nSecond page, main frame, standard world - Disconnected\nSecond page, main frame, non-standard world - Disconnected",
-"WillDestroyGlobalObjectForDOMWindowExtension called",
-"WillDestroyGlobalObjectForDOMWindowExtension called",
-"WillDestroyGlobalObjectForDOMWindowExtension called",
-"WillDestroyGlobalObjectForDOMWindowExtension called",
-"WillDestroyGlobalObjectForDOMWindowExtension called",
-"WillDestroyGlobalObjectForDOMWindowExtension called",
-"Extension states:\nFirst page, main frame, standard world - Destroyed\nFirst page, main frame, non-standard world - Destroyed\nFirst page, subframe, standard world - Destroyed\nFirst page, subframe, non-standard world - Destroyed\nSecond page, main frame, standard world - Destroyed\nSecond page, main frame, non-standard world - Destroyed",
+"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, main frame, standard world - Removed\nSecond page, main frame, non-standard world - Removed",
"TestComplete"
};
@@ -80,15 +73,8 @@ static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messag
WKStringRef bodyString = (WKStringRef)messageBody;
messages.append(bodyString);
- if (WKStringIsEqualToUTF8CString(messageName, "GlobalObjectIsAvailableForFrame"))
- liveDOMExtensionCount++;
- else if (WKStringIsEqualToUTF8CString(messageName, "WillDestroyGlobalObjectForDOMWindowExtension")) {
- liveDOMExtensionCount--;
- if (!liveDOMExtensionCount)
- finished = true;
- } else if (WKStringIsEqualToUTF8CString(messageName, "DidFinishLoadForMainFrame") || WKStringIsEqualToUTF8CString(messageName, "TestComplete"))
+ if (WKStringIsEqualToUTF8CString(messageName, "DidFinishLoadForMainFrame") || WKStringIsEqualToUTF8CString(messageName, "TestComplete"))
finished = true;
-
}
TEST(WebKit2, DOMWindowExtensionBasic)
@@ -129,20 +115,20 @@ TEST(WebKit2, DOMWindowExtensionBasic)
Util::run(&finished);
finished = false;
-
- // Make sure the 2 disconnected extensions in the page cache and the 4 active extensions are all destroyed.
+
+ // Make sure the 2 disconnected extensions in the page cache and the 4 active extensions are all removed.
WKPageClose(webView.page());
Util::run(&finished);
const size_t expectedSize = sizeof(expectedMessages) / sizeof(const char*);
- EXPECT_EQ(messages.size(), expectedSize);
+ EXPECT_EQ(expectedSize, messages.size());
if (messages.size() != expectedSize)
return;
for (size_t i = 0; i < messages.size(); ++i)
- EXPECT_EQ(WKStringIsEqualToUTF8CString(messages[i].get(), expectedMessages[i]), true);
+ EXPECT_WK_STREQ(expectedMessages[i], messages[i].get());
}
} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp
index 61ac1bdeb..bb5b1eb68 100644
--- a/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp
+++ b/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp
@@ -33,7 +33,6 @@
#include <WebKit2/WKBundleScriptWorld.h>
#include <WebKit2/WKRetainPtr.h>
#include <wtf/HashMap.h>
-#include <wtf/Vector.h>
#include <assert.h>
namespace TestWebKitAPI {
@@ -46,14 +45,15 @@ static void willDestroyGlobalObjectForDOMWindowExtensionCallback(WKBundlePageRef
enum ExtensionState {
- Uncreated = 0, Connected, Disconnected, Destroyed
+ Uncreated = 0, Connected, Disconnected, Destroyed, Removed
};
-const char* stateNames[4] = {
+const char* stateNames[5] = {
"Uncreated",
"Connected",
"Disconnected",
- "Destroyed"
+ "Destroyed",
+ "Removed"
};
typedef struct {
@@ -67,6 +67,7 @@ public:
virtual void initialize(WKBundleRef, WKTypeRef userData);
virtual void didCreatePage(WKBundleRef, WKBundlePageRef);
+ virtual void willDestroyPage(WKBundleRef, WKBundlePageRef);
void globalObjectIsAvailableForFrame(WKBundleFrameRef, WKBundleScriptWorldRef);
void willDisconnectDOMWindowExtensionFromGlobalObject(WKBundleDOMWindowExtensionRef);
@@ -85,7 +86,6 @@ private:
ExtensionRecord m_extensionRecords[6];
HashMap<WKBundleDOMWindowExtensionRef, int> m_extensionToRecordMap;
bool m_finishedOneMainFrameLoad;
- int m_numberOfDestroyedExtensions;
};
static InjectedBundleTest::Register<DOMWindowExtensionBasic> registrar("DOMWindowExtensionBasic");
@@ -93,7 +93,6 @@ static InjectedBundleTest::Register<DOMWindowExtensionBasic> registrar("DOMWindo
DOMWindowExtensionBasic::DOMWindowExtensionBasic(const std::string& identifier)
: InjectedBundleTest(identifier)
, m_finishedOneMainFrameLoad(false)
- , m_numberOfDestroyedExtensions(0)
{
m_extensionRecords[0].name = "First page, main frame, standard world";
m_extensionRecords[1].name = "First page, main frame, non-standard world";
@@ -167,6 +166,21 @@ void DOMWindowExtensionBasic::didCreatePage(WKBundleRef bundle, WKBundlePageRef
WKBundlePageSetPageLoaderClient(page, &pageLoaderClient);
}
+
+void DOMWindowExtensionBasic::willDestroyPage(WKBundleRef, WKBundlePageRef)
+{
+ HashMap<WKBundleDOMWindowExtensionRef, int>::iterator it = m_extensionToRecordMap.begin();
+ HashMap<WKBundleDOMWindowExtensionRef, int>::iterator end = m_extensionToRecordMap.end();
+ for (; it != end; ++it) {
+ updateExtensionStateRecord(it->first, Removed);
+ WKRelease(it->first);
+ }
+
+ m_extensionToRecordMap.clear();
+
+ sendExtensionStateMessage();
+ sendBundleMessage("TestComplete");
+}
void DOMWindowExtensionBasic::updateExtensionStateRecord(WKBundleDOMWindowExtensionRef extension, ExtensionState state)
{
@@ -211,19 +225,11 @@ void DOMWindowExtensionBasic::didReconnectDOMWindowExtensionToGlobalObject(WKBun
sendBundleMessage("DidReconnectDOMWindowExtensionToGlobalObject called");
}
-void DOMWindowExtensionBasic::willDestroyGlobalObjectForDOMWindowExtension(WKBundleDOMWindowExtensionRef extension)
+void DOMWindowExtensionBasic::willDestroyGlobalObjectForDOMWindowExtension(WKBundleDOMWindowExtensionRef)
{
- m_numberOfDestroyedExtensions++;
-
- updateExtensionStateRecord(extension, Destroyed);
- sendBundleMessage("WillDestroyGlobalObjectForDOMWindowExtension called");
-
- if (m_numberOfDestroyedExtensions == 6) {
- sendExtensionStateMessage();
- sendBundleMessage("TestComplete");
- }
-
- WKRelease(extension);
+ // All of the items are candidates for the page cache and should not be evicted from the page
+ // cache before the test completes.
+ ASSERT_NOT_REACHED();
}
static void didFinishLoadForFrameCallback(WKBundlePageRef, WKBundleFrameRef frame, WKTypeRef*, const void *clientInfo)
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionNoCache.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionNoCache.cpp
new file mode 100644
index 000000000..d59d0d1bb
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionNoCache.cpp
@@ -0,0 +1,133 @@
+/*
+* 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"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+#include <wtf/Vector.h>
+
+namespace TestWebKitAPI {
+
+static bool finished;
+
+static const char* expectedMessages[] = {
+"GlobalObjectIsAvailableForFrame called",
+"GlobalObjectIsAvailableForFrame called",
+"GlobalObjectIsAvailableForFrame called",
+"GlobalObjectIsAvailableForFrame called",
+"Subframe finished loading",
+"Extension states:\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\nSecond page, main frame, standard world - Uncreated\nSecond page, main frame, non-standard 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",
+"Main frame finished loading",
+"Extension states:\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\nSecond page, main frame, standard world - Uncreated\nSecond page, main frame, non-standard 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",
+"WillDestroyDOMWindowExtensionToGlobalObject called",
+"WillDestroyDOMWindowExtensionToGlobalObject called",
+"WillDestroyDOMWindowExtensionToGlobalObject called",
+"WillDestroyDOMWindowExtensionToGlobalObject called",
+"GlobalObjectIsAvailableForFrame called",
+"GlobalObjectIsAvailableForFrame called",
+"Main frame finished loading",
+"Extension states:\nFirst page, main frame, standard world - Destroyed\nFirst page, main frame, non-standard world - Destroyed\nFirst page, subframe, standard world - Destroyed\nFirst page, subframe, non-standard world - Destroyed\nSecond page, main frame, standard world - Connected\nSecond page, main frame, non-standard 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",
+"WillDestroyDOMWindowExtensionToGlobalObject called",
+"WillDestroyDOMWindowExtensionToGlobalObject called",
+"GlobalObjectIsAvailableForFrame called",
+"GlobalObjectIsAvailableForFrame called",
+"GlobalObjectIsAvailableForFrame called",
+"GlobalObjectIsAvailableForFrame called",
+"Subframe finished loading",
+"Extension states:\nFirst page, main frame, standard world - Destroyed\nFirst page, main frame, non-standard world - Destroyed\nFirst page, subframe, standard world - Destroyed\nFirst page, subframe, non-standard world - Destroyed\nSecond page, main frame, standard world - Destroyed\nSecond page, main frame, non-standard 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",
+"Main frame finished loading",
+"Extension states:\nFirst page, main frame, standard world - Destroyed\nFirst page, main frame, non-standard world - Destroyed\nFirst page, subframe, standard world - Destroyed\nFirst page, subframe, non-standard world - Destroyed\nSecond page, main frame, standard world - Destroyed\nSecond page, main frame, non-standard 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",
+"Extension states:\nFirst page, main frame, standard world - Destroyed\nFirst page, main frame, non-standard world - Destroyed\nFirst page, subframe, standard world - Destroyed\nFirst page, subframe, non-standard world - Destroyed\nSecond page, main frame, standard world - Destroyed\nSecond page, main frame, non-standard world - Destroyed\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",
+"TestComplete"
+};
+
+static Vector<WKRetainPtr<WKStringRef> > messages;
+
+static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void*)
+{
+ ASSERT_NOT_NULL(messageBody);
+ EXPECT_EQ(WKStringGetTypeID(), WKGetTypeID(messageBody));
+
+ WKStringRef bodyString = (WKStringRef)messageBody;
+ messages.append(bodyString);
+
+ if (WKStringIsEqualToUTF8CString(messageName, "DidFinishLoadForMainFrame") || WKStringIsEqualToUTF8CString(messageName, "TestComplete"))
+ finished = true;
+}
+
+TEST(WebKit2, DOMWindowExtensionNoCache)
+{
+ WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifier(WKStringCreateWithUTF8CString("DOMWindowExtensionNoCachePageGroup")));
+
+ WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("DOMWindowExtensionNoCache", pageGroup.get()));
+
+ WKContextInjectedBundleClient injectedBundleClient;
+ memset(&injectedBundleClient, 0, sizeof(injectedBundleClient));
+ injectedBundleClient.version = kWKContextInjectedBundleClientCurrentVersion;
+ injectedBundleClient.clientInfo = 0;
+ injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle;
+ WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient);
+
+ // FIXME 85891: Instead of using unload handlers to prevent use of the page cache, set the
+ // cache model to kWKCacheModelDocumentView, which sets page cache capacity to 0.
+
+ PlatformWebView webView(context.get(), pageGroup.get());
+
+ // Make sure the extensions for each frame are installed in each world.
+ WKRetainPtr<WKURLRef> url1(AdoptWK, Util::createURLForResource("simple-iframe-unload", "html"));
+ WKPageLoadURL(webView.page(), url1.get());
+
+ Util::run(&finished);
+ finished = false;
+
+ // Make sure those first 4 extensions are destroyed, and 2 new ones are installed.
+ WKRetainPtr<WKURLRef> url2(AdoptWK, Util::createURLForResource("simple-unload", "html"));
+ WKPageLoadURL(webView.page(), url2.get());
+
+ Util::run(&finished);
+ finished = false;
+
+ // Make sure those 2 are destroyed, and the first 4 are recreated.
+ WKPageGoBack(webView.page());
+
+ Util::run(&finished);
+ finished = false;
+
+ WKPageClose(webView.page());
+
+ Util::run(&finished);
+
+ const size_t expectedSize = sizeof(expectedMessages) / sizeof(const char*);
+ EXPECT_EQ(expectedSize, messages.size());
+
+ if (messages.size() != expectedSize)
+ return;
+
+ for (size_t i = 0; i < messages.size(); ++i)
+ EXPECT_WK_STREQ(expectedMessages[i], messages[i].get());
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionNoCache_Bundle.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionNoCache_Bundle.cpp
new file mode 100644
index 000000000..fcc0c72f6
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionNoCache_Bundle.cpp
@@ -0,0 +1,279 @@
+/*
+ * 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"
+#include "InjectedBundleTest.h"
+#include <WebKit2/WKBundleDOMWindowExtension.h>
+#include <WebKit2/WKBundleFrame.h>
+#include <WebKit2/WKBundlePage.h>
+#include <WebKit2/WKBundlePageGroup.h>
+#include <WebKit2/WKBundlePrivate.h>
+#include <WebKit2/WKBundleScriptWorld.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <wtf/HashMap.h>
+#include <assert.h>
+
+namespace TestWebKitAPI {
+
+static void didFinishLoadForFrameCallback(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void* clientInfo);
+static void globalObjectIsAvailableForFrameCallback(WKBundlePageRef, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo);
+static void willDisconnectDOMWindowExtensionFromGlobalObjectCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef, const void* clientInfo);
+static void didReconnectDOMWindowExtensionToGlobalObjectCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef, const void* clientInfo);
+static void willDestroyGlobalObjectForDOMWindowExtensionCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef, const void* clientInfo);
+
+enum ExtensionState {
+ Uncreated = 0, Connected, Disconnected, Destroyed, Removed
+};
+
+const char* states[5] = {
+ "Uncreated",
+ "Connected",
+ "Disconnected",
+ "Destroyed",
+ "Removed"
+};
+
+typedef struct {
+ const char* name;
+ ExtensionState state;
+} ExtensionRecord;
+
+class DOMWindowExtensionNoCache : public InjectedBundleTest {
+public:
+ DOMWindowExtensionNoCache(const std::string& identifier);
+
+ virtual void initialize(WKBundleRef, WKTypeRef userData);
+ virtual void didCreatePage(WKBundleRef, WKBundlePageRef);
+ virtual void willDestroyPage(WKBundleRef, WKBundlePageRef);
+
+ void globalObjectIsAvailableForFrame(WKBundleFrameRef, WKBundleScriptWorldRef);
+ void willDisconnectDOMWindowExtensionFromGlobalObject(WKBundleDOMWindowExtensionRef);
+ void didReconnectDOMWindowExtensionToGlobalObject(WKBundleDOMWindowExtensionRef);
+ void willDestroyGlobalObjectForDOMWindowExtension(WKBundleDOMWindowExtensionRef);
+
+ void frameLoadFinished(WKBundleFrameRef);
+
+private:
+ void updateExtensionStateRecord(WKBundleDOMWindowExtensionRef, ExtensionState);
+ void sendExtensionStateMessage();
+ void sendBundleMessage(const char*);
+
+ WKBundlePageGroupRef m_pageGroup;
+ WKBundleRef m_bundle;
+ ExtensionRecord m_extensionRecords[10];
+ HashMap<WKBundleDOMWindowExtensionRef, int> m_extensionToRecordMap;
+ int m_numberMainFrameLoads;
+};
+
+static InjectedBundleTest::Register<DOMWindowExtensionNoCache> registrar("DOMWindowExtensionNoCache");
+
+DOMWindowExtensionNoCache::DOMWindowExtensionNoCache(const std::string& identifier)
+ : InjectedBundleTest(identifier)
+ , m_numberMainFrameLoads(0)
+{
+ m_extensionRecords[0].name = "First page, main frame, standard world";
+ m_extensionRecords[1].name = "First page, main frame, non-standard world";
+ m_extensionRecords[2].name = "First page, subframe, standard world";
+ m_extensionRecords[3].name = "First page, subframe, non-standard world";
+ m_extensionRecords[4].name = "Second page, main frame, standard world";
+ m_extensionRecords[5].name = "Second page, main frame, non-standard world";
+ m_extensionRecords[6].name = "First page, main frame, standard world";
+ m_extensionRecords[7].name = "First page, main frame, non-standard world";
+ m_extensionRecords[8].name = "First page, subframe, standard world";
+ m_extensionRecords[9].name = "First page, subframe, non-standard world";
+
+ for (size_t i = 0; i < 10; ++i)
+ m_extensionRecords[i].state = Uncreated;
+}
+
+void DOMWindowExtensionNoCache::frameLoadFinished(WKBundleFrameRef frame)
+{
+ bool mainFrame = !WKBundleFrameGetParentFrame(frame);
+ if (mainFrame)
+ m_numberMainFrameLoads++;
+
+ char body[16384];
+ sprintf(body, "%s finished loading", mainFrame ? "Main frame" : "Subframe");
+
+ // Only consider load finished for the main frame
+ const char* name = mainFrame ? "DidFinishLoadForMainFrame" : "DidFinishLoadForFrame";
+
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString(name));
+ WKRetainPtr<WKStringRef> messageBody = adoptWK(WKStringCreateWithUTF8CString(body));
+ WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+
+ sendExtensionStateMessage();
+}
+
+void DOMWindowExtensionNoCache::sendExtensionStateMessage()
+{
+ char body[16384];
+ sprintf(body, "Extension states:\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s",
+ m_extensionRecords[0].name, states[m_extensionRecords[0].state],
+ m_extensionRecords[1].name, states[m_extensionRecords[1].state],
+ m_extensionRecords[2].name, states[m_extensionRecords[2].state],
+ m_extensionRecords[3].name, states[m_extensionRecords[3].state],
+ m_extensionRecords[4].name, states[m_extensionRecords[4].state],
+ m_extensionRecords[5].name, states[m_extensionRecords[5].state],
+ m_extensionRecords[6].name, states[m_extensionRecords[6].state],
+ m_extensionRecords[7].name, states[m_extensionRecords[7].state],
+ m_extensionRecords[8].name, states[m_extensionRecords[8].state],
+ m_extensionRecords[9].name, states[m_extensionRecords[9].state]);
+
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("ExtensionStates"));
+ WKRetainPtr<WKStringRef> messageBody = adoptWK(WKStringCreateWithUTF8CString(body));
+ WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+}
+
+void DOMWindowExtensionNoCache::initialize(WKBundleRef bundle, WKTypeRef userData)
+{
+ assert(WKGetTypeID(userData) == WKBundlePageGroupGetTypeID());
+ WKBundlePageGroupRef pageGroup = static_cast<WKBundlePageGroupRef>(userData);
+
+ WKRetainPtr<WKStringRef> source(AdoptWK, WKStringCreateWithUTF8CString("alert('Unimportant alert');"));
+ WKBundleAddUserScript(bundle, pageGroup, WKBundleScriptWorldCreateWorld(), source.get(), 0, 0, 0, kWKInjectAtDocumentStart, kWKInjectInAllFrames);
+}
+
+void DOMWindowExtensionNoCache::didCreatePage(WKBundleRef bundle, WKBundlePageRef page)
+{
+ m_bundle = bundle;
+
+ WKBundlePageLoaderClient pageLoaderClient;
+ memset(&pageLoaderClient, 0, sizeof(pageLoaderClient));
+
+ pageLoaderClient.version = kWKBundlePageLoaderClientCurrentVersion;
+ pageLoaderClient.clientInfo = this;
+ pageLoaderClient.didFinishLoadForFrame = didFinishLoadForFrameCallback;
+ pageLoaderClient.globalObjectIsAvailableForFrame = globalObjectIsAvailableForFrameCallback;
+ pageLoaderClient.willDisconnectDOMWindowExtensionFromGlobalObject = willDisconnectDOMWindowExtensionFromGlobalObjectCallback;
+ pageLoaderClient.didReconnectDOMWindowExtensionToGlobalObject = didReconnectDOMWindowExtensionToGlobalObjectCallback;
+ pageLoaderClient.willDestroyGlobalObjectForDOMWindowExtension = willDestroyGlobalObjectForDOMWindowExtensionCallback;
+
+ WKBundlePageSetPageLoaderClient(page, &pageLoaderClient);
+}
+
+void DOMWindowExtensionNoCache::willDestroyPage(WKBundleRef, WKBundlePageRef)
+{
+ HashMap<WKBundleDOMWindowExtensionRef, int>::iterator it = m_extensionToRecordMap.begin();
+ HashMap<WKBundleDOMWindowExtensionRef, int>::iterator end = m_extensionToRecordMap.end();
+ for (; it != end; ++it) {
+ updateExtensionStateRecord(it->first, Removed);
+ WKRelease(it->first);
+ }
+
+ m_extensionToRecordMap.clear();
+
+ sendExtensionStateMessage();
+ sendBundleMessage("TestComplete");
+}
+
+void DOMWindowExtensionNoCache::updateExtensionStateRecord(WKBundleDOMWindowExtensionRef extension, ExtensionState state)
+{
+ int index = m_extensionToRecordMap.get(extension);
+ m_extensionRecords[index].state = state;
+}
+
+void DOMWindowExtensionNoCache::sendBundleMessage(const char* message)
+{
+ WKRetainPtr<WKStringRef> wkMessage = adoptWK(WKStringCreateWithUTF8CString(message));
+ WKBundlePostMessage(m_bundle, wkMessage.get(), wkMessage.get());
+}
+
+void DOMWindowExtensionNoCache::globalObjectIsAvailableForFrame(WKBundleFrameRef frame, WKBundleScriptWorldRef world)
+{
+ WKBundleDOMWindowExtensionRef extension = WKBundleDOMWindowExtensionCreate(frame, world);
+
+ int index;
+ bool standard;
+ standard = world == WKBundleScriptWorldNormalWorld();
+
+ bool mainFrame = !WKBundleFrameGetParentFrame(frame);
+ switch (m_numberMainFrameLoads) {
+ case 0:
+ index = mainFrame ? (standard ? 0 : 1) : (standard ? 2 : 3);
+ break;
+ case 1:
+ index = standard ? 4 : 5;
+ break;
+ case 2:
+ index = mainFrame ? (standard ? 6 : 7) : (standard ? 8 : 9);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+
+ m_extensionToRecordMap.set(extension, index);
+
+ updateExtensionStateRecord(extension, Connected);
+ sendBundleMessage("GlobalObjectIsAvailableForFrame called");
+}
+
+void DOMWindowExtensionNoCache::willDisconnectDOMWindowExtensionFromGlobalObject(WKBundleDOMWindowExtensionRef extension)
+{
+ // No items should be going into a 0-capacity page cache.
+ ASSERT_NOT_REACHED();
+}
+
+void DOMWindowExtensionNoCache::didReconnectDOMWindowExtensionToGlobalObject(WKBundleDOMWindowExtensionRef)
+{
+ // No items should be coming out of a 0-capacity page cache.
+ ASSERT_NOT_REACHED();
+}
+
+void DOMWindowExtensionNoCache::willDestroyGlobalObjectForDOMWindowExtension(WKBundleDOMWindowExtensionRef extension)
+{
+ sendBundleMessage("WillDestroyDOMWindowExtensionToGlobalObject called");
+ updateExtensionStateRecord(extension, Destroyed);
+ m_extensionToRecordMap.remove(extension);
+ WKRelease(extension);
+}
+
+static void didFinishLoadForFrameCallback(WKBundlePageRef, WKBundleFrameRef frame, WKTypeRef*, const void *clientInfo)
+{
+ ((DOMWindowExtensionNoCache*)clientInfo)->frameLoadFinished(frame);
+}
+
+static void globalObjectIsAvailableForFrameCallback(WKBundlePageRef, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void* clientInfo)
+{
+ ((DOMWindowExtensionNoCache*)clientInfo)->globalObjectIsAvailableForFrame(frame, world);
+}
+
+static void willDisconnectDOMWindowExtensionFromGlobalObjectCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef extension, const void* clientInfo)
+{
+ ((DOMWindowExtensionNoCache*)clientInfo)->willDisconnectDOMWindowExtensionFromGlobalObject(extension);
+}
+
+static void didReconnectDOMWindowExtensionToGlobalObjectCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef extension, const void* clientInfo)
+{
+ ((DOMWindowExtensionNoCache*)clientInfo)->didReconnectDOMWindowExtensionToGlobalObject(extension);
+}
+
+static void willDestroyGlobalObjectForDOMWindowExtensionCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef extension , const void* clientInfo)
+{
+ ((DOMWindowExtensionNoCache*)clientInfo)->willDestroyGlobalObjectForDOMWindowExtension(extension);
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp
index 9f69bca82..5f2f6e283 100644
--- a/Tools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp
+++ b/Tools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp
@@ -135,9 +135,17 @@ TEST(WebKit2, PageLoadBasic)
policyClient.decidePolicyForResponse = decidePolicyForResponse;
WKPageSetPagePolicyClient(webView.page(), &policyClient);
+ // Before loading anything, the active url should be null
+ EXPECT_NULL(WKPageCopyActiveURL(webView.page()));
+
WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));
WKPageLoadURL(webView.page(), url.get());
+ // But immediately after starting a load, the active url should reflect the request
+ WKRetainPtr<WKURLRef> activeUrl = adoptWK(WKPageCopyActiveURL(webView.page()));
+ ASSERT_NOT_NULL(activeUrl.get());
+ EXPECT_TRUE(WKURLIsEqual(activeUrl.get(), url.get()));
+
Util::run(&test1Done);
}
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/simple-iframe-unload.html b/Tools/TestWebKitAPI/Tests/WebKit2/simple-iframe-unload.html
new file mode 100644
index 000000000..bb8860c74
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/WebKit2/simple-iframe-unload.html
@@ -0,0 +1,6 @@
+<html>
+<body onunload="/* disable page cache */">
+ Simple HTML file with an unload handler.
+ <iframe src="simple-unload.html"></iframe>
+</body>
+</html>
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/simple-unload.html b/Tools/TestWebKitAPI/Tests/WebKit2/simple-unload.html
new file mode 100644
index 000000000..be38e24cb
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/WebKit2/simple-unload.html
@@ -0,0 +1,5 @@
+<html>
+<body onunload="/* disable page cache */">
+ Simple HTML file with an unload handler.
+</body>
+</html>
diff --git a/Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.html b/Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.html
new file mode 100644
index 000000000..033c79130
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.html
@@ -0,0 +1,14 @@
+<script>
+
+function loaded()
+{
+ var request = new XMLHttpRequest();
+ request.open('GET', 'http://www.iana.org/domains/example/', true);
+ request.send(null);
+}
+
+</script>
+
+<body onload="loaded();">
+We will do some XHR'ing now!
+</body>
diff --git a/Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.mm b/Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.mm
new file mode 100644
index 000000000..aeb955508
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/mac/MemoryCacheDisableWithinResourceLoadDelegate.mm
@@ -0,0 +1,90 @@
+/*
+ * 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/WebCache.h>
+#import <wtf/RetainPtr.h>
+
+@interface MemoryCacheDisableTestResourceLoadDelegate : NSObject {
+}
+@end
+
+static bool didFinishLoad;
+
+@implementation MemoryCacheDisableTestResourceLoadDelegate
+
+- (id)webView:(WebView *)sender identifierForInitialRequest:(NSURLRequest *)request fromDataSource:(WebDataSource *)dataSource
+{
+ [WebCache setDisabled:YES];
+ [WebCache setDisabled:NO];
+
+ return self;
+}
+
+- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource
+{
+ [WebCache setDisabled:YES];
+ [WebCache setDisabled:NO];
+
+ return request;
+}
+
+- (void)webView:(WebView *)sender resource:(id)identifier didFinishLoadingFromDataSource:(WebDataSource *)dataSource
+{
+ [WebCache setDisabled:YES];
+ [WebCache setDisabled:NO];
+
+ didFinishLoad = YES;
+}
+
+- (void)webView:(WebView *)sender resource:(id)identifier didFailLoadingWithError:(NSError *)error fromDataSource:(WebDataSource *)dataSource
+{
+ [WebCache setDisabled:YES];
+ [WebCache setDisabled:NO];
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+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<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"]]];
+
+ Util::run(&didFinishLoad);
+
+ [pool drain];
+ // If we finished without crashing, the test passed.
+}
+
+} // namespace TestWebKitAPI