diff options
author | Ben Murdoch <benm@google.com> | 2011-05-16 16:25:10 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-23 18:54:14 +0100 |
commit | ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb (patch) | |
tree | db769fadd053248f85db67434a5b275224defef7 /Tools/WebKitTestRunner | |
parent | 52e2557aeb8477967e97fd24f20f8f407a10fa15 (diff) | |
download | external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.zip external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.gz external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.bz2 |
Merge WebKit at r76408: Initial merge by git.
Change-Id: I5b91decbd693ccbf5c1b8354b37cd68cc9a1ea53
Diffstat (limited to 'Tools/WebKitTestRunner')
14 files changed, 135 insertions, 24 deletions
diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm b/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm index 0de2fd0..2f5c66f 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm @@ -256,6 +256,10 @@ EOF $self->_includeHeaders(\%contentsIncludes, $function->signature->type, $function->signature); + if ($function->signature->extendedAttributes->{"PassContext"}) { + push(@parameters, "context"); + } + foreach my $i (0..$#specifiedParameters) { my $parameter = $specifiedParameters[$i]; diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl index acc2f47..a88a838 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl @@ -76,6 +76,9 @@ module WTR { // Text search testing. boolean findString(in DOMString target, in object optionsArray); + + // Evaluating script in a special context + [PassContext] void evaluateScriptInIsolatedWorld(in unsigned long worldID, in DOMString script) }; } diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp index 999ca3a..972a606 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp @@ -47,6 +47,7 @@ InjectedBundle& InjectedBundle::shared() InjectedBundle::InjectedBundle() : m_bundle(0) + , m_topLoadingFrame(0) , m_state(Idle) { } @@ -161,6 +162,7 @@ void InjectedBundle::done() m_state = Stopping; page()->stopLoading(); + setTopLoadingFrame(0); WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithUTF8CString("Done")); WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithUTF8CString(m_outputStream.str().c_str())); diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h index c1d8b37..9778441 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h @@ -65,6 +65,9 @@ public: bool isTestRunning() { return m_state == Testing; } + WKBundleFrameRef topLoadingFrame() { return m_topLoadingFrame; } + void setTopLoadingFrame(WKBundleFrameRef frame) { m_topLoadingFrame = frame; } + private: InjectedBundle(); ~InjectedBundle(); @@ -89,6 +92,8 @@ private: RefPtr<GCController> m_gcController; RefPtr<EventSendingController> m_eventSendingController; + WKBundleFrameRef m_topLoadingFrame; + std::ostringstream m_outputStream; enum State { diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp index 4bcb3c8..c5f4909 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp @@ -168,7 +168,6 @@ static ostream& operator<<(ostream& out, WKBundleFrameRef frame) InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page) : m_page(page) , m_world(AdoptWK, WKBundleScriptWorldCreateWorld()) - , m_isLoading(false) { WKBundlePageLoaderClient loaderClient = { 0, @@ -233,7 +232,6 @@ InjectedBundlePage::~InjectedBundlePage() void InjectedBundlePage::stopLoading() { WKBundlePageStopLoading(m_page); - m_isLoading = false; } void InjectedBundlePage::reset() @@ -334,8 +332,9 @@ void InjectedBundlePage::didStartProvisionalLoadForFrame(WKBundleFrameRef frame) if (!InjectedBundle::shared().isTestRunning()) return; - if (frame == WKBundlePageGetMainFrame(m_page)) - m_isLoading = true; + if (InjectedBundle::shared().topLoadingFrame()) + return; + InjectedBundle::shared().setTopLoadingFrame(frame); } void InjectedBundlePage::didReceiveServerRedirectForProvisionalLoadForFrame(WKBundleFrameRef frame) @@ -344,6 +343,17 @@ void InjectedBundlePage::didReceiveServerRedirectForProvisionalLoadForFrame(WKBu void InjectedBundlePage::didFailProvisionalLoadWithErrorForFrame(WKBundleFrameRef frame, WKErrorRef error) { + if (!InjectedBundle::shared().isTestRunning()) + return; + + if (frame != InjectedBundle::shared().topLoadingFrame()) + return; + InjectedBundle::shared().setTopLoadingFrame(0); + + if (InjectedBundle::shared().layoutTestController()->waitToDump()) + return; + + InjectedBundle::shared().done(); } void InjectedBundlePage::didCommitLoadForFrame(WKBundleFrameRef frame) @@ -475,18 +485,14 @@ void InjectedBundlePage::didFinishLoadForFrame(WKBundleFrameRef frame) if (!InjectedBundle::shared().isTestRunning()) return; - if (!WKBundleFrameIsMainFrame(frame)) - return; - - m_isLoading = false; - - if (this != InjectedBundle::shared().page()) + if (frame != InjectedBundle::shared().topLoadingFrame()) return; + InjectedBundle::shared().setTopLoadingFrame(0); if (InjectedBundle::shared().layoutTestController()->waitToDump()) return; - dump(); + InjectedBundle::shared().page()->dump(); } void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundleFrameRef frame, WKErrorRef) @@ -494,12 +500,11 @@ void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundleFrameRef frame, WK if (!InjectedBundle::shared().isTestRunning()) return; - if (!WKBundleFrameIsMainFrame(frame)) + if (frame != InjectedBundle::shared().topLoadingFrame()) return; + InjectedBundle::shared().setTopLoadingFrame(0); - m_isLoading = false; - - if (this != InjectedBundle::shared().page()) + if (InjectedBundle::shared().layoutTestController()->waitToDump()) return; InjectedBundle::shared().done(); @@ -521,12 +526,14 @@ void InjectedBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, WKBundle if (!InjectedBundle::shared().isTestRunning()) return; - if (WKBundleScriptWorldNormalWorld() != world) - return; - JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, world); JSObjectRef window = JSContextGetGlobalObject(context); + if (WKBundleScriptWorldNormalWorld() != world) { + JSObjectSetProperty(context, window, toJS("__worldID").get(), JSValueMakeNumber(context, LayoutTestController::worldIDForWorld(world)), kJSPropertyAttributeReadOnly, 0); + return; + } + JSValueRef exception = 0; InjectedBundle::shared().layoutTestController()->makeWindowObject(context, window, &exception); InjectedBundle::shared().gcController()->makeWindowObject(context, window, &exception); diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h index e9462df..3b99109 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h @@ -41,7 +41,6 @@ public: void dump(); void stopLoading(); - bool isLoading() { return m_isLoading; } void reset(); @@ -124,7 +123,6 @@ private: WKBundlePageRef m_page; WKRetainPtr<WKBundleScriptWorldRef> m_world; WKRetainPtr<WKBundleBackForwardListItemRef> m_previousTestBackForwardListItem; - bool m_isLoading; }; } // namespace WTR diff --git a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp index aa3dbf4..13c7b10 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp @@ -37,6 +37,7 @@ #include <WebKit2/WKBundlePrivate.h> #include <WebKit2/WKRetainPtr.h> #include <WebKit2/WebKit2.h> +#include <wtf/HashMap.h> namespace WTR { @@ -132,8 +133,9 @@ void LayoutTestController::notifyDone() if (!InjectedBundle::shared().isTestRunning()) return; - if (m_waitToDump && !InjectedBundle::shared().page()->isLoading()) + if (m_waitToDump && !InjectedBundle::shared().topLoadingFrame()) InjectedBundle::shared().page()->dump(); + m_waitToDump = false; } @@ -307,4 +309,44 @@ void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef wi setProperty(context, windowObject, "layoutTestController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception); } +typedef WTF::HashMap<unsigned, WKRetainPtr<WKBundleScriptWorldRef> > WorldMap; +static WorldMap& worldMap() +{ + static WorldMap& map = *new WorldMap; + return map; +} + +unsigned LayoutTestController::worldIDForWorld(WKBundleScriptWorldRef world) +{ + WorldMap::const_iterator end = worldMap().end(); + for (WorldMap::const_iterator it = worldMap().begin(); it != end; ++it) { + if (it->second == world) + return it->first; + } + + return 0; +} + +void LayoutTestController::evaluateScriptInIsolatedWorld(JSContextRef context, unsigned worldID, JSStringRef script) +{ + // A worldID of 0 always corresponds to a new world. Any other worldID corresponds to a world + // that is created once and cached forever. + WKRetainPtr<WKBundleScriptWorldRef> world; + if (!worldID) + world.adopt(WKBundleScriptWorldCreateWorld()); + else { + WKRetainPtr<WKBundleScriptWorldRef>& worldSlot = worldMap().add(worldID, 0).first->second; + if (!worldSlot) + worldSlot.adopt(WKBundleScriptWorldCreateWorld()); + world = worldSlot; + } + + WKBundleFrameRef frame = WKBundleFrameForJavaScriptContext(context); + if (!frame) + frame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); + + JSGlobalContextRef jsContext = WKBundleFrameGetJavaScriptContextForWorld(frame, world.get()); + JSEvaluateScript(jsContext, script, 0, 0, 0, 0); +} + } // namespace WTR diff --git a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h index 2aaad08..1f81970 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h +++ b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h @@ -28,6 +28,7 @@ #include "JSWrappable.h" #include <JavaScriptCore/JSRetainPtr.h> +#include <WebKit2/WKBundleScriptWorld.h> #include <string> #include <wtf/PassRefPtr.h> @@ -122,6 +123,9 @@ public: bool shouldCloseExtraWindowsAfterRunningTest() const { return m_shouldCloseExtraWindows; } + void evaluateScriptInIsolatedWorld(JSContextRef, unsigned worldID, JSStringRef script); + static unsigned worldIDForWorld(WKBundleScriptWorldRef); + private: static const double waitToDumpWatchdogTimerInterval; diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp index 699982e..e856176 100644 --- a/Tools/WebKitTestRunner/TestController.cpp +++ b/Tools/WebKitTestRunner/TestController.cpp @@ -103,6 +103,11 @@ static bool runBeforeUnloadConfirmPanel(WKPageRef page, WKStringRef message, WKF return true; } +void TestController::runModal(WKPageRef page, const void* clientInfo) +{ + runModal(static_cast<PlatformWebView*>(const_cast<void*>(clientInfo))); +} + static void closeOtherPage(WKPageRef page, const void* clientInfo) { WKPageClose(page); @@ -110,7 +115,7 @@ static void closeOtherPage(WKPageRef page, const void* clientInfo) delete view; } -static WKPageRef createOtherPage(WKPageRef oldPage, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*) +WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*) { PlatformWebView* view = new PlatformWebView(WKPageGetContext(oldPage), WKPageGetPageGroup(oldPage)); WKPageRef newPage = view->page(); @@ -146,6 +151,12 @@ static WKPageRef createOtherPage(WKPageRef oldPage, WKDictionaryRef, WKEventModi 0, // exceededDatabaseQuota 0, // runOpenPanel 0, // decidePolicyForGeolocationPermissionRequest + 0, // headerHeight + 0, // footerHeight + 0, // drawHeader + 0, // drawFooter + 0, // printFrame + runModal, }; WKPageSetPageUIClient(newPage, &otherPageUIClient); @@ -251,6 +262,12 @@ void TestController::initialize(int argc, const char* argv[]) 0, // exceededDatabaseQuota 0, // runOpenPanel 0, // decidePolicyForGeolocationPermissionRequest + 0, // headerHeight + 0, // footerHeight + 0, // drawHeader + 0, // drawFooter + 0, // printFrame + 0, // runModal }; WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient); @@ -327,8 +344,11 @@ bool TestController::resetStateToConsistentValues() bool TestController::runTest(const char* test) { - if (!resetStateToConsistentValues()) + if (!resetStateToConsistentValues()) { + fputs("#CRASHED - WebProcess\n", stderr); + fflush(stderr); return false; + } m_state = RunningTest; m_currentInvocation.set(new TestInvocation(test)); @@ -386,6 +406,8 @@ void TestController::didReceiveSynchronousMessageFromInjectedBundle(WKContextRef void TestController::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody) { + if (!m_currentInvocation) + return; m_currentInvocation->didReceiveMessageFromInjectedBundle(messageName, messageBody); } diff --git a/Tools/WebKitTestRunner/TestController.h b/Tools/WebKitTestRunner/TestController.h index fc8bd30..65305a2 100644 --- a/Tools/WebKitTestRunner/TestController.h +++ b/Tools/WebKitTestRunner/TestController.h @@ -85,6 +85,10 @@ private: static void processDidCrash(WKPageRef, const void* clientInfo); void processDidCrash(WKPageRef); + static WKPageRef createOtherPage(WKPageRef oldPage, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*); + + static void runModal(WKPageRef, const void* clientInfo); + static void runModal(PlatformWebView*); OwnPtr<TestInvocation> m_currentInvocation; diff --git a/Tools/WebKitTestRunner/TestInvocation.h b/Tools/WebKitTestRunner/TestInvocation.h index fec1f7a..efc6635 100644 --- a/Tools/WebKitTestRunner/TestInvocation.h +++ b/Tools/WebKitTestRunner/TestInvocation.h @@ -31,7 +31,8 @@ namespace WTR { -class TestInvocation : public Noncopyable { +class TestInvocation { + WTF_MAKE_NONCOPYABLE(TestInvocation); public: TestInvocation(const char*); ~TestInvocation(); diff --git a/Tools/WebKitTestRunner/mac/TestControllerMac.mm b/Tools/WebKitTestRunner/mac/TestControllerMac.mm index 6a4444f..8107890 100644 --- a/Tools/WebKitTestRunner/mac/TestControllerMac.mm +++ b/Tools/WebKitTestRunner/mac/TestControllerMac.mm @@ -25,6 +25,7 @@ #include "TestController.h" +#include "PlatformWebView.h" #include <WebKit2/WKStringCF.h> #include <mach-o/dyld.h> @@ -62,4 +63,12 @@ void TestController::platformInitializeContext() { } +void TestController::runModal(PlatformWebView* view) +{ + NSWindow *window = [view->platformView() window]; + if (!window) + return; + [NSApp runModalForWindow:window]; +} + } // namespace WTR diff --git a/Tools/WebKitTestRunner/qt/TestControllerQt.cpp b/Tools/WebKitTestRunner/qt/TestControllerQt.cpp index ca0a00c..df977fb 100644 --- a/Tools/WebKitTestRunner/qt/TestControllerQt.cpp +++ b/Tools/WebKitTestRunner/qt/TestControllerQt.cpp @@ -128,6 +128,11 @@ void TestController::platformInitializeContext() { } +void TestController::runModal(PlatformWebView*) +{ + // FIXME: Need to implement this to test showModalDialog. +} + #include "TestControllerQt.moc" } // namespace WTR diff --git a/Tools/WebKitTestRunner/win/TestControllerWin.cpp b/Tools/WebKitTestRunner/win/TestControllerWin.cpp index e562ada..08f188f 100644 --- a/Tools/WebKitTestRunner/win/TestControllerWin.cpp +++ b/Tools/WebKitTestRunner/win/TestControllerWin.cpp @@ -152,4 +152,9 @@ void TestController::platformInitializeContext() WKContextSetShouldPaintNativeControls(m_context.get(), false); } +void TestController::runModal(PlatformWebView*) +{ + // FIXME: Need to implement this to test showModalDialog. +} + } // namespace WTR |