2010-07-25 Darin Adler <darin@apple.com>
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Jul 2010 06:03:36 +0000 (06:03 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Jul 2010 06:03:36 +0000 (06:03 +0000)
        Reviewed by Maciej Stachowiak.

        WebKitTestRunner needs to support layoutTestController.keepWebHistory
        https://bugs.webkit.org/show_bug.cgi?id=42323

        * platform/mac-wk2/Skipped: Removed the tests that needed only keepWebHistory
        and computedStyleIncludingVisitedInfo. Moved the other tests in the
        keepWebHistory section of the file into the other appropriate lists.
2010-07-25  Darin Adler  <darin@apple.com>

        Reviewed by Maciej Stachowiak.

        WebKitTestRunner needs to support layoutTestController.keepWebHistory
        https://bugs.webkit.org/show_bug.cgi?id=42323

        Added keepWebHistory and computedStyleIncludingVisitedInfo.

        Also fixed misspellings of the word "receive".

        Also tweaked the names of some of the LayoutTestController members.

        * WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
        Added support for a type named "object" that is passed and returns as
        a JSValueRef.

        * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
        Added keepWebHistory and computedStyleIncludingVisitedInfo. Also
        put setAcceptsEditing up nearer the top.

        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
        (WTR::InjectedBundle::_didReceiveMessage): Fixed mispellings of receive.
        (WTR::InjectedBundle::initialize): Ditto.
        (WTR::InjectedBundle::didReceiveMessage): Ditto.
        (WTR::InjectedBundle::reset): Reset the state of visited links between
        tests. Also eliminated the unused argument to the LayoutTestController
        create function.
        (WTR::InjectedBundle::setShouldTrackVisitedLinks): Added.
        * WebKitTestRunner/InjectedBundle/InjectedBundle.h: Ditto.

        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
        (WTR::InjectedBundlePage::shouldBeginEditing): Call shouldAllowEditing
        instead of acceptsEditing.
        (WTR::InjectedBundlePage::shouldEndEditing): Ditto.
        (WTR::InjectedBundlePage::shouldInsertNode): Ditto.
        (WTR::InjectedBundlePage::shouldInsertText): Ditto.
        (WTR::InjectedBundlePage::shouldDeleteRange): Ditto.
        (WTR::InjectedBundlePage::shouldChangeSelectedRange): Ditto.
        (WTR::InjectedBundlePage::shouldApplyStyle): Ditto.

        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
        (WTR::LayoutTestController::create): Removed uneeded argument.
        (WTR::LayoutTestController::LayoutTestController): Removed unneeded
        argument. Updated for rename of m_acceptsEditing to m_shouldAllowEditing.
        (WTR::LayoutTestController::numberOfActiveAnimations): Added some FIXMEs
        about the fact that this works on the main frame.
        (WTR::LayoutTestController::pauseAnimationAtTimeOnElementWithId): Ditto.
        (WTR::LayoutTestController::keepWebHistory): Added.
        (WTR::LayoutTestController::computedStyleIncludingVisitedInfo): Added.
        (WTR::JSObjectSetProperty): Added. Helper to make the function below
        cleaner.
        (WTR::LayoutTestController::makeWindowObject): Changed to use the
        overload of JSObjectSetProperty above.

        * WebKitTestRunner/InjectedBundle/LayoutTestController.h: Changes to
        match above.

        * WebKitTestRunner/TestController.cpp:
        (WTR::TestController::initialize): Fixed mispellings of receive.
        (WTR::TestController::_didReceiveMessageFromInjectedBundle): Ditto.
        (WTR::TestController::didReceiveMessageFromInjectedBundle): Ditto.
        * WebKitTestRunner/TestController.h: Ditto.
        * WebKitTestRunner/TestInvocation.cpp:
        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): Ditto.
        * WebKitTestRunner/TestInvocation.h: Ditto.
2010-07-25  Darin Adler  <darin@apple.com>

        Reviewed by Maciej Stachowiak.

        WebKitTestRunner needs to support layoutTestController.keepWebHistory
        https://bugs.webkit.org/show_bug.cgi?id=42323

        Added WKBundleSetShouldTrackVisitedLinks, WKBundleRemoveAllVisitedLinks,
        and WKBundleFrameGetComputedStyleIncludingVisitedInfo.

        Also fixed misspellings of the word "receive".

        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
        (WKBundleSetShouldTrackVisitedLinks): Added.
        (WKBundleRemoveAllVisitedLinks): Added.
        * WebProcess/InjectedBundle/API/c/WKBundle.h: Added functions and
        fixed mispellings of receive.

        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
        (WKBundleFrameGetJavaScriptContext): Moved the code from here into WebFrame,
        to be consistent with the rest of the functions in this file.
        (WKBundleFrameGetComputedStyleIncludingVisitedInfo): Added.
        * WebProcess/InjectedBundle/API/c/WKBundleFrame.h: Added
        WKBundleFrameGetComputedStyleIncludingVisitedInfo and tried to rearrange the
        file to be more logically ordered and grouped.

        * WebProcess/InjectedBundle/InjectedBundle.cpp:
        (WebKit::InjectedBundle::setShouldTrackVisitedLinks): Added.
        (WebKit::InjectedBundle::removeAllVisitedLinks): Added.
        (WebKit::InjectedBundle::didReceiveMessage): Fixed mispellings of receive.
        * WebProcess/InjectedBundle/InjectedBundle.h: Ditto.

        * WebProcess/WebPage/WebFrame.cpp:
        (WebKit::WebFrame::jsContext): Added. Contains the code that used to be in
        WKBundleFrameGetJavaScriptContext.
        (WebKit::WebFrame::computedStyleIncludingVisitedInfo): Added.
        * WebProcess/WebPage/WebFrame.h: Ditto.

        * UIProcess/API/C/WKContext.h: Fixed misspellings of receive.
        * UIProcess/WebContext.cpp:
        (WebKit::WebContext::didReceiveMessageFromInjectedBundle): Ditto.
        * UIProcess/WebContext.h: Ditto.
        * UIProcess/WebContextInjectedBundleClient.cpp:
        (WebKit::WebContextInjectedBundleClient::didReceiveMessageFromInjectedBundle): Ditto.
        * UIProcess/WebContextInjectedBundleClient.h: Ditto.
        * UIProcess/WebProcessProxy.cpp:
        (WebKit::WebProcessProxy::forwardMessageToWebContext): Ditto.
        * WebProcess/WebProcess.cpp:
        (WebKit::WebProcess::forwardMessageToInjectedBundle): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64029 268f45cc-cd09-0410-ab3c-d52691b4dbfc

30 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-wk2/Skipped
WebKit2/ChangeLog
WebKit2/UIProcess/API/C/WKContext.h
WebKit2/UIProcess/WebContext.cpp
WebKit2/UIProcess/WebContext.h
WebKit2/UIProcess/WebContextInjectedBundleClient.cpp
WebKit2/UIProcess/WebContextInjectedBundleClient.h
WebKit2/UIProcess/WebProcessProxy.cpp
WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h
WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h
WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
WebKit2/WebProcess/WebPage/WebFrame.cpp
WebKit2/WebProcess/WebPage/WebFrame.h
WebKit2/WebProcess/WebProcess.cpp
WebKitTools/ChangeLog
WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
WebKitTools/WebKitTestRunner/TestController.cpp
WebKitTools/WebKitTestRunner/TestController.h
WebKitTools/WebKitTestRunner/TestInvocation.cpp
WebKitTools/WebKitTestRunner/TestInvocation.h

index 6fd77b1..c693340 100644 (file)
@@ -1,3 +1,14 @@
+2010-07-25  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        WebKitTestRunner needs to support layoutTestController.keepWebHistory
+        https://bugs.webkit.org/show_bug.cgi?id=42323
+
+        * platform/mac-wk2/Skipped: Removed the tests that needed only keepWebHistory
+        and computedStyleIncludingVisitedInfo. Moved the other tests in the
+        keepWebHistory section of the file into the other appropriate lists.
+
 2010-07-25  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Eric Seidel.
index 8f2b14a..9f7fd25 100644 (file)
@@ -1637,6 +1637,7 @@ fast/frames/sandboxed-iframe-navigation-windowopen.html
 fast/harness/page-cache-crash-on-data-urls.html
 fast/harness/show-modal-dialog.html
 fast/history/history_reload.html
+fast/history/window-open.html
 fast/loader/cancel-load-during-port-block-timer.html
 fast/loader/crash-copying-backforwardlist.html
 fast/loader/stateobjects/pushstate-without-history.html
@@ -1692,12 +1693,32 @@ fast/loader/frame-src-change-added-to-history.html
 fast/loader/frame-src-change-not-added-to-history.html
 fast/loader/stateobjects/pushstate-object-types.html
 fast/loader/subframe-navigate-during-main-frame-load.html
+http/tests/history/redirect-200-refresh-0-seconds.pl
 http/tests/history/redirect-200-refresh-2-seconds.pl
 http/tests/history/redirect-301.pl
 http/tests/history/redirect-302.pl
 http/tests/history/redirect-303.pl
 http/tests/history/redirect-307.pl
+http/tests/history/redirect-js-document-location-0-seconds.html
+http/tests/history/redirect-js-document-location-2-seconds.html
+http/tests/history/redirect-js-document-location-before-load.html
+http/tests/history/redirect-js-form-submit-0-seconds.html
+http/tests/history/redirect-js-form-submit-2-seconds.html
+http/tests/history/redirect-js-form-submit-before-load.html
+http/tests/history/redirect-js-location-0-seconds.html
 http/tests/history/redirect-js-location-2-seconds.html
+http/tests/history/redirect-js-location-assign-0-seconds.html
+http/tests/history/redirect-js-location-assign-2-seconds.html
+http/tests/history/redirect-js-location-assign-before-load.html
+http/tests/history/redirect-js-location-before-load.html
+http/tests/history/redirect-js-location-href-0-seconds.html
+http/tests/history/redirect-js-location-href-2-seconds.html
+http/tests/history/redirect-js-location-href-before-load.html
+http/tests/history/redirect-js-location-replace-0-seconds.html
+http/tests/history/redirect-js-location-replace-2-seconds.html
+http/tests/history/redirect-js-location-replace-before-load.html
+http/tests/history/redirect-meta-refresh-0-seconds.html
+http/tests/history/redirect-meta-refresh-2-seconds.html
 http/tests/incremental/frame-focus-before-load.html
 http/tests/navigation/anchor-basic.html
 http/tests/navigation/anchor-frames.html
@@ -1766,34 +1787,6 @@ http/tests/navigation/timerredirect-subframeload.html
 http/tests/navigation/window-open-adds-history-item.html
 http/tests/navigation/window-open-adds-history-item2.html
 
-# WebKitTestRunner needs to support layoutTestController.keepWebHistory
-# <https://bugs.webkit.org/show_bug.cgi?id=42323>
-fast/history/multiple-classes-visited.html
-fast/history/nested-visited-test.html
-fast/history/self-is-visited.html
-fast/history/sibling-visited-test.html
-fast/history/window-open.html
-http/tests/history/redirect-200-refresh-0-seconds.pl
-http/tests/history/redirect-js-document-location-0-seconds.html
-http/tests/history/redirect-js-document-location-2-seconds.html
-http/tests/history/redirect-js-document-location-before-load.html
-http/tests/history/redirect-js-form-submit-0-seconds.html
-http/tests/history/redirect-js-form-submit-before-load.html
-http/tests/history/redirect-js-location-0-seconds.html
-http/tests/history/redirect-js-location-assign-0-seconds.html
-http/tests/history/redirect-js-location-assign-2-seconds.html
-http/tests/history/redirect-js-location-assign-before-load.html
-http/tests/history/redirect-js-location-before-load.html
-http/tests/history/redirect-js-location-href-0-seconds.html
-http/tests/history/redirect-js-location-href-2-seconds.html
-http/tests/history/redirect-js-location-href-before-load.html
-http/tests/history/redirect-js-location-replace-0-seconds.html
-http/tests/history/redirect-js-location-replace-2-seconds.html
-http/tests/history/redirect-js-location-replace-before-load.html
-http/tests/history/redirect-meta-refresh-0-seconds.html
-http/tests/history/redirect-meta-refresh-2-seconds.html
-http/tests/history/redirect-js-form-submit-2-seconds.html
-
 # WebKitTestRunner needs to support layoutTestController.dumpDOMAsWebArchive
 # <https://bugs.webkit.org/show_bug.cgi?id=42324>
 http/tests/webarchive/cross-origin-stylesheet-crash.html
index 8aad2c9..069ac4b 100644 (file)
@@ -1,3 +1,53 @@
+2010-07-25  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        WebKitTestRunner needs to support layoutTestController.keepWebHistory
+        https://bugs.webkit.org/show_bug.cgi?id=42323
+
+        Added WKBundleSetShouldTrackVisitedLinks, WKBundleRemoveAllVisitedLinks,
+        and WKBundleFrameGetComputedStyleIncludingVisitedInfo.
+
+        Also fixed misspellings of the word "receive".
+
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundleSetShouldTrackVisitedLinks): Added.
+        (WKBundleRemoveAllVisitedLinks): Added.
+        * WebProcess/InjectedBundle/API/c/WKBundle.h: Added functions and
+        fixed mispellings of receive.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
+        (WKBundleFrameGetJavaScriptContext): Moved the code from here into WebFrame,
+        to be consistent with the rest of the functions in this file.
+        (WKBundleFrameGetComputedStyleIncludingVisitedInfo): Added.
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.h: Added
+        WKBundleFrameGetComputedStyleIncludingVisitedInfo and tried to rearrange the
+        file to be more logically ordered and grouped.
+
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::setShouldTrackVisitedLinks): Added.
+        (WebKit::InjectedBundle::removeAllVisitedLinks): Added.
+        (WebKit::InjectedBundle::didReceiveMessage): Fixed mispellings of receive.
+        * WebProcess/InjectedBundle/InjectedBundle.h: Ditto.
+
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::jsContext): Added. Contains the code that used to be in
+        WKBundleFrameGetJavaScriptContext.
+        (WebKit::WebFrame::computedStyleIncludingVisitedInfo): Added.
+        * WebProcess/WebPage/WebFrame.h: Ditto.
+
+        * UIProcess/API/C/WKContext.h: Fixed misspellings of receive.
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::didReceiveMessageFromInjectedBundle): Ditto.
+        * UIProcess/WebContext.h: Ditto.
+        * UIProcess/WebContextInjectedBundleClient.cpp:
+        (WebKit::WebContextInjectedBundleClient::didReceiveMessageFromInjectedBundle): Ditto.
+        * UIProcess/WebContextInjectedBundleClient.h: Ditto.
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::forwardMessageToWebContext): Ditto.
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::forwardMessageToInjectedBundle): Ditto.
+
 2010-07-25  Alexey Proskuryakov  <ap@apple.com>
 
         Reviewed by Sam Weinig.
index e0f7d4b..89f2812 100644 (file)
@@ -33,12 +33,12 @@ extern "C" {
 #endif
 
 // Policy Client.
-typedef void (*WKContextDidRecieveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef message, const void *clientInfo);
+typedef void (*WKContextDidReceiveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef message, const void *clientInfo);
 
 struct WKContextInjectedBundleClient {
     int                                                                 version;
     const void *                                                        clientInfo;
-    WKContextDidRecieveMessageFromInjectedBundleCallback                didRecieveMessageFromInjectedBundle;
+    WKContextDidReceiveMessageFromInjectedBundleCallback                didReceiveMessageFromInjectedBundle;
 };
 typedef struct WKContextInjectedBundleClient WKContextInjectedBundleClient;
 
index 0d2ea80..5403cbb 100644 (file)
@@ -149,9 +149,9 @@ void WebContext::preferencesDidChange()
 
 // InjectedBundle client
 
-void WebContext::didRecieveMessageFromInjectedBundle(const WebCore::String& message)
+void WebContext::didReceiveMessageFromInjectedBundle(const WebCore::String& message)
 {
-    m_injectedBundleClient.didRecieveMessageFromInjectedBundle(this, message);
+    m_injectedBundleClient.didReceiveMessageFromInjectedBundle(this, message);
 }
 
 void WebContext::postMessageToInjectedBundle(WebCore::StringImpl* message)
index 22d96c0..5aef0c1 100644 (file)
@@ -76,7 +76,7 @@ public:
     const WebCore::String& injectedBundlePath() const { return m_injectedBundlePath; }
 
     // InjectedBundle client
-    void didRecieveMessageFromInjectedBundle(const WebCore::String&);
+    void didReceiveMessageFromInjectedBundle(const WebCore::String&);
 
     void postMessageToInjectedBundle(WebCore::StringImpl*);
 
index 5341b6e..449516e 100644 (file)
@@ -45,12 +45,12 @@ void WebContextInjectedBundleClient::initialize(WKContextInjectedBundleClient* c
         memset(&m_client, 0, sizeof(m_client));
 }
 
-void WebContextInjectedBundleClient::didRecieveMessageFromInjectedBundle(WebContext* context, const String& message)
+void WebContextInjectedBundleClient::didReceiveMessageFromInjectedBundle(WebContext* context, const String& message)
 {
-    if (!m_client.didRecieveMessageFromInjectedBundle)
+    if (!m_client.didReceiveMessageFromInjectedBundle)
         return;
 
-    m_client.didRecieveMessageFromInjectedBundle(toRef(context), toRef(message.impl()), m_client.clientInfo);
+    m_client.didReceiveMessageFromInjectedBundle(toRef(context), toRef(message.impl()), m_client.clientInfo);
 }
 
 } // namespace WebKit
index a118c6c..3e875e8 100644 (file)
@@ -41,7 +41,7 @@ public:
     WebContextInjectedBundleClient();
     void initialize(WKContextInjectedBundleClient*);
 
-    void didRecieveMessageFromInjectedBundle(WebContext*, const WebCore::String&);
+    void didReceiveMessageFromInjectedBundle(WebContext*, const WebCore::String&);
 
 private:
     WKContextInjectedBundleClient m_client;
index 5db2776..12a8404 100644 (file)
@@ -184,7 +184,7 @@ WebBackForwardListItem* WebProcessProxy::webBackForwardItem(uint64_t itemID) con
 
 void WebProcessProxy::forwardMessageToWebContext(const String& message)
 {
-    m_context->didRecieveMessageFromInjectedBundle(message);
+    m_context->didReceiveMessageFromInjectedBundle(message);
 }
 
 void WebProcessProxy::getPlugins(bool refresh, Vector<PluginInfo>& plugins)
index 0e8db37..22b196c 100644 (file)
@@ -41,3 +41,13 @@ void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageRef)
 {
     toWK(bundleRef)->postMessage(toWK(messageRef));
 }
+
+void WKBundleSetShouldTrackVisitedLinks(WKBundleRef bundleRef, bool shouldTrackVisitedLinks)
+{
+    toWK(bundleRef)->setShouldTrackVisitedLinks(shouldTrackVisitedLinks);
+}
+
+void WKBundleRemoveAllVisitedLinks(WKBundleRef bundleRef)
+{
+    toWK(bundleRef)->removeAllVisitedLinks();
+}
index a4e0246..36e6631 100644 (file)
@@ -36,14 +36,14 @@ extern "C" {
 // Client
 typedef void (*WKBundleDidCreatePageCallback)(WKBundleRef bundle, WKBundlePageRef page, const void *clientInfo);
 typedef void (*WKBundleWillDestroyPageCallback)(WKBundleRef bundle, WKBundlePageRef page, const void *clientInfo);
-typedef void (*WKBundleDidRecieveMessageCallback)(WKBundleRef bundle, WKStringRef message, const void *clientInfo);
+typedef void (*WKBundleDidReceiveMessageCallback)(WKBundleRef bundle, WKStringRef message, const void *clientInfo);
 
 struct WKBundleClient {
     int                                                                 version;
     const void *                                                        clientInfo;
     WKBundleDidCreatePageCallback                                       didCreatePage;
     WKBundleWillDestroyPageCallback                                     willDestroyPage;
-    WKBundleDidRecieveMessageCallback                                   didRecieveMessage;
+    WKBundleDidReceiveMessageCallback                                   didReceiveMessage;
 };
 typedef struct WKBundleClient WKBundleClient;
 
@@ -51,6 +51,9 @@ WK_EXPORT void WKBundleSetClient(WKBundleRef bundle, WKBundleClient * client);
 
 WK_EXPORT void WKBundlePostMessage(WKBundleRef bundle, WKStringRef message);
 
+WK_EXPORT void WKBundleSetShouldTrackVisitedLinks(WKBundleRef bundle, bool shouldTrackVisitedLinks);
+WK_EXPORT void WKBundleRemoveAllVisitedLinks(WKBundleRef bundle);
+
 #ifdef __cplusplus
 }
 #endif
index ffb9659..e36442c 100644 (file)
@@ -28,7 +28,6 @@
 #include "WKAPICast.h"
 #include "WKBundleAPICast.h"
 #include "WebFrame.h"
-#include <JavaScriptCore/APICast.h>
 #include <WebCore/Frame.h>
 
 using namespace WebCore;
@@ -61,9 +60,7 @@ bool WKBundleFramePauseAnimationOnElementWithId(WKBundleFrameRef frameRef, WKStr
 
 JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frameRef)
 {
-    // FIXME: Is there a way to get this and know that it's a JSGlobalContextRef?
-    // The const_cast here is a bit ugly.
-    return const_cast<JSGlobalContextRef>(toRef(toWK(frameRef)->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec()));
+    return toWK(frameRef)->jsContext();
 }
 
 WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frameRef)
@@ -72,3 +69,8 @@ WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frameRef)
     string.impl()->ref();
     return toRef(string.impl());
 }
+
+JSValueRef WKBundleFrameGetComputedStyleIncludingVisitedInfo(WKBundleFrameRef frameRef, JSObjectRef element)
+{
+    return toWK(frameRef)->computedStyleIncludingVisitedInfo(element);
+}
index b7ca6f1..b9c13ca 100644 (file)
@@ -39,19 +39,17 @@ extern "C" {
 #endif
 
 WK_EXPORT bool WKBundleFrameIsMainFrame(WKBundleFrameRef frame);
+WK_EXPORT WKArrayRef WKBundleFrameCopyChildFrames(WKBundleFrameRef frame);
 
-WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frame);
-
+WK_EXPORT WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frame);
 WK_EXPORT WKURLRef WKBundleFrameGetURL(WKBundleFrameRef frame);
 
-WK_EXPORT WKArrayRef WKBundleFrameCopyChildFrames(WKBundleFrameRef frame);
+WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frame);
+WK_EXPORT JSValueRef WKBundleFrameGetComputedStyleIncludingVisitedInfo(WKBundleFrameRef frame, JSObjectRef element);
 
 WK_EXPORT unsigned WKBundleFrameGetNumberOfActiveAnimations(WKBundleFrameRef frame);
-
 WK_EXPORT bool WKBundleFramePauseAnimationOnElementWithId(WKBundleFrameRef frame, WKStringRef name, WKStringRef elementID, double time);
 
-WK_EXPORT WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frame);
-
 #ifdef __cplusplus
 }
 #endif
index c641522..cd15c3c 100644 (file)
@@ -30,6 +30,7 @@
 #include "WebCoreArgumentCoders.h"
 #include "WebProcess.h"
 #include "WebProcessProxyMessageKinds.h"
+#include <WebCore/PageGroup.h>
 
 using namespace WebCore;
 
@@ -59,6 +60,16 @@ void InjectedBundle::postMessage(StringImpl* message)
     WebProcess::shared().connection()->send(WebProcessProxyMessage::PostMessage, 0, CoreIPC::In(String(message)));
 }
 
+void InjectedBundle::setShouldTrackVisitedLinks(bool shouldTrackVisitedLinks)
+{
+    PageGroup::setShouldTrackVisitedLinks(shouldTrackVisitedLinks);
+}
+
+void InjectedBundle::removeAllVisitedLinks()
+{
+    PageGroup::removeAllVisitedLinks();
+}
+
 void InjectedBundle::didCreatePage(WebPage* page)
 {
     if (m_client.didCreatePage)
@@ -71,10 +82,10 @@ void InjectedBundle::willDestroyPage(WebPage* page)
         m_client.willDestroyPage(toRef(this), toRef(page), m_client.clientInfo);
 }
 
-void InjectedBundle::didRecieveMessage(const WebCore::String& message)
+void InjectedBundle::didReceiveMessage(const WebCore::String& message)
 {
-    if (m_client.didRecieveMessage)
-        m_client.didRecieveMessage(toRef(this), toRef(message.impl()), m_client.clientInfo);
+    if (m_client.didReceiveMessage)
+        m_client.didReceiveMessage(toRef(this), toRef(message.impl()), m_client.clientInfo);
 }
 
 } // namespace WebKit
index f61ba56..2d1c67e 100644 (file)
@@ -60,11 +60,13 @@ public:
     // API
     void initializeClient(WKBundleClient*);
     void postMessage(WebCore::StringImpl*);
+    void setShouldTrackVisitedLinks(bool);
+    void removeAllVisitedLinks();
 
     // Callback hooks
     void didCreatePage(WebPage*);
     void willDestroyPage(WebPage*);
-    void didRecieveMessage(const WebCore::String&);
+    void didReceiveMessage(const WebCore::String&);
 
 private:
     InjectedBundle(const WebCore::String&);
index c166239..c5d6046 100644 (file)
 #include "WebFrame.h"
 
 #include "WebPage.h"
+#include <JavaScriptCore/APICast.h>
+#include <JavaScriptCore/JSLock.h>
 #include <WebCore/AnimationController.h>
+#include <WebCore/CSSComputedStyleDeclaration.h>
 #include <WebCore/Frame.h>
 #include <WebCore/HTMLFrameOwnerElement.h>
+#include <WebCore/JSCSSStyleDeclaration.h>
+#include <WebCore/JSElement.h>
 #include <WebCore/PlatformString.h>
 
 #ifndef NDEBUG
 #include <wtf/RefCountedLeakCounter.h>
 #endif
 
+using namespace JSC;
 using namespace WebCore;
 
 namespace WebKit {
@@ -244,5 +250,28 @@ bool WebFrame::pauseAnimationOnElementWithId(const String& animationName, const
     return controller->pauseAnimationAtTime(coreNode->renderer(), animationName, time);
 }
 
+JSGlobalContextRef WebFrame::jsContext()
+{
+    // FIXME: Is there a way to get this and know that it's a JSGlobalContextRef?
+    // The const_cast here is a bit ugly.
+    return const_cast<JSGlobalContextRef>(toRef(m_coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec()));
+}
+
+JSValueRef WebFrame::computedStyleIncludingVisitedInfo(JSObjectRef elementJSObject)
+{
+    if (!m_coreFrame)
+        return 0;
+
+    JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(mainThreadNormalWorld());
+    ExecState* exec = globalObject->globalExec();
+
+    if (!toJS(elementJSObject)->inherits(&JSElement::s_info))
+        return JSValueMakeUndefined(toRef(exec));
+
+    RefPtr<CSSComputedStyleDeclaration> style = computedStyle(static_cast<JSElement*>(toJS(elementJSObject))->impl(), true);
+
+    JSLock lock(SilenceAssertionsOnly);
+    return toRef(exec, toJS(exec, globalObject, style.get()));
+}
 
 } // namespace WebKit
index fb1985f..3c035f9 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "ImmutableArray.h"
 #include "WebFrameLoaderClient.h"
+#include <JavaScriptCore/JSBase.h>
 #include <WebCore/FrameLoaderClient.h>
 #include <WebCore/FrameLoaderTypes.h>
 #include <WebCore/PolicyChecker.h>
@@ -68,6 +69,8 @@ public:
     WebCore::String name() const;
     WebCore::String url() const;
     PassRefPtr<ImmutableArray> childFrames();
+    JSValueRef computedStyleIncludingVisitedInfo(JSObjectRef element);
+    JSGlobalContextRef jsContext();
 
     unsigned numberOfActiveAnimations();
     bool pauseAnimationOnElementWithId(const WebCore::String& animationName, const WebCore::String& elementID, double time);
index 6c8fb63..fa5dbb2 100644 (file)
@@ -106,7 +106,7 @@ void WebProcess::forwardMessageToInjectedBundle(const String& message)
     if (!m_injectedBundle)
         return;
 
-    m_injectedBundle->didRecieveMessage(message);
+    m_injectedBundle->didReceiveMessage(message);
 }
 
 WebPage* WebProcess::webPage(uint64_t pageID) const
index 7fb7aa7..4cd7ab0 100644 (file)
@@ -1,3 +1,70 @@
+2010-07-25  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        WebKitTestRunner needs to support layoutTestController.keepWebHistory
+        https://bugs.webkit.org/show_bug.cgi?id=42323
+
+        Added keepWebHistory and computedStyleIncludingVisitedInfo.
+
+        Also fixed misspellings of the word "receive".
+
+        Also tweaked the names of some of the LayoutTestController members.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
+        Added support for a type named "object" that is passed and returns as
+        a JSValueRef.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
+        Added keepWebHistory and computedStyleIncludingVisitedInfo. Also
+        put setAcceptsEditing up nearer the top.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::_didReceiveMessage): Fixed mispellings of receive.
+        (WTR::InjectedBundle::initialize): Ditto.
+        (WTR::InjectedBundle::didReceiveMessage): Ditto.
+        (WTR::InjectedBundle::reset): Reset the state of visited links between
+        tests. Also eliminated the unused argument to the LayoutTestController
+        create function.
+        (WTR::InjectedBundle::setShouldTrackVisitedLinks): Added.
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h: Ditto.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::shouldBeginEditing): Call shouldAllowEditing
+        instead of acceptsEditing.
+        (WTR::InjectedBundlePage::shouldEndEditing): Ditto.
+        (WTR::InjectedBundlePage::shouldInsertNode): Ditto.
+        (WTR::InjectedBundlePage::shouldInsertText): Ditto.
+        (WTR::InjectedBundlePage::shouldDeleteRange): Ditto.
+        (WTR::InjectedBundlePage::shouldChangeSelectedRange): Ditto.
+        (WTR::InjectedBundlePage::shouldApplyStyle): Ditto.
+
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+        (WTR::LayoutTestController::create): Removed uneeded argument.
+        (WTR::LayoutTestController::LayoutTestController): Removed unneeded
+        argument. Updated for rename of m_acceptsEditing to m_shouldAllowEditing.
+        (WTR::LayoutTestController::numberOfActiveAnimations): Added some FIXMEs
+        about the fact that this works on the main frame.
+        (WTR::LayoutTestController::pauseAnimationAtTimeOnElementWithId): Ditto.
+        (WTR::LayoutTestController::keepWebHistory): Added.
+        (WTR::LayoutTestController::computedStyleIncludingVisitedInfo): Added.
+        (WTR::JSObjectSetProperty): Added. Helper to make the function below
+        cleaner.
+        (WTR::LayoutTestController::makeWindowObject): Changed to use the
+        overload of JSObjectSetProperty above.
+
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.h: Changes to
+        match above.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::initialize): Fixed mispellings of receive.
+        (WTR::TestController::_didReceiveMessageFromInjectedBundle): Ditto.
+        (WTR::TestController::didReceiveMessageFromInjectedBundle): Ditto.
+        * WebKitTestRunner/TestController.h: Ditto.
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): Ditto.
+        * WebKitTestRunner/TestInvocation.h: Ditto.
+
 2010-07-25  Alexey Proskuryakov  <ap@apple.com>
 
         Reviewed by Sam Weinig.
index d72d4fc..75d7ec7 100644 (file)
@@ -343,7 +343,9 @@ sub _includeHeaders
     my ($self, $headers, $idlType, $signature) = @_;
 
     return unless defined $idlType;
-    return if $idlType eq "boolean" or $$self{codeGenerator}->IsNonPointerType($idlType);
+    return if $idlType eq "boolean";
+    return if $idlType eq "object";
+    return if $$self{codeGenerator}->IsNonPointerType($idlType);
 
     $$headers{_className($idlType) . ".h"} = 1;
     $$headers{_implementationClassName($idlType) . ".h"} = 1;
@@ -385,6 +387,7 @@ sub _platformType
     return undef unless defined $idlType;
 
     return "bool" if $idlType eq "boolean";
+    return "JSValueRef" if $idlType eq "object";
     return "JSRetainPtr<JSStringRef>" if $$self{codeGenerator}->IsStringType($idlType);
     return "double" if $$self{codeGenerator}->IsNonPointerType($idlType);
     return _implementationClassName($idlType);
@@ -396,8 +399,9 @@ sub _platformTypeConstructor
 
     my $idlType = $signature->type;
 
-    return "JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, $argumentName, 0))" if $$self{codeGenerator}->IsStringType($idlType);
     return "JSValueToBoolean(context, $argumentName)" if $idlType eq "boolean";
+    return "$argumentName" if $idlType eq "object";
+    return "JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, $argumentName, 0))" if $$self{codeGenerator}->IsStringType($idlType);
     return "JSValueToNumber(context, $argumentName, 0)" if $$self{codeGenerator}->IsNonPointerType($idlType);
     return "to" . _implementationClassName($idlType) . "(context, $argumentName)";
 }
@@ -413,6 +417,7 @@ sub _platformTypeVariableDeclaration
         "bool" => 1,
         "double" => 1,
         "JSRetainPtr<JSStringRef>" => 1,
+        "JSValueRef" => 1,
     );
 
     my $nullValue = "0";
@@ -437,6 +442,7 @@ sub _returnExpression
 
     return "JSValueMakeUndefined(context)" if $returnIDLType eq "void";
     return "JSValueMakeBoolean(context, ${expression})" if $returnIDLType eq "boolean";
+    return "${expression}" if $returnIDLType eq "object";
     return "JSValueMakeNumber(context, ${expression})" if $$self{codeGenerator}->IsNonPointerType($returnIDLType);
     return "toJS(context, WTF::getPtr(${expression}))";
 }
index 1c72882..ea7b835 100644 (file)
@@ -37,6 +37,13 @@ module WTR {
         void dumpEditingCallbacks();
         void dumpStatusCallbacks();
 
+        // Special options.
+        void keepWebHistory();
+        void setAcceptsEditing(in boolean value);
+
+        // Special DOM functions.
+        object computedStyleIncludingVisitedInfo(in object element);
+
         // Repaint testing.
         void testRepaint();
         void repaintSweepHorizontally();
@@ -45,8 +52,6 @@ module WTR {
         // Animation testing.
         int numberOfActiveAnimations();
         boolean pauseAnimationAtTimeOnElementWithId(in DOMString animationName, in double time, in DOMString elementId);
-
-        void setAcceptsEditing(in boolean value);
     };
 
 }
index d3c66fd..443e24f 100644 (file)
@@ -57,9 +57,9 @@ void InjectedBundle::_willDestroyPage(WKBundleRef bundle, WKBundlePageRef page,
     static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->willDestroyPage(page);
 }
 
-void InjectedBundle::_didRecieveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo)
+void InjectedBundle::_didReceiveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo)
 {
-    static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didRecieveMessage(message);
+    static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didReceiveMessage(message);
 }
 
 void InjectedBundle::initialize(WKBundleRef bundle)
@@ -71,7 +71,7 @@ void InjectedBundle::initialize(WKBundleRef bundle)
         this,
         _didCreatePage,
         _willDestroyPage,
-        _didRecieveMessage
+        _didReceiveMessage
     };
     WKBundleSetClient(m_bundle, &client);
 
@@ -98,7 +98,7 @@ void InjectedBundle::willDestroyPage(WKBundlePageRef page)
     delete m_pages.take(page);
 }
 
-void InjectedBundle::didRecieveMessage(WKStringRef message)
+void InjectedBundle::didReceiveMessage(WKStringRef message)
 {
     CFStringRef cfMessage = WKStringCopyCFString(0, message);
     if (CFEqual(cfMessage, CFSTR("BeginTest"))) {
@@ -116,7 +116,14 @@ void InjectedBundle::didRecieveMessage(WKStringRef message)
 void InjectedBundle::reset()
 {
     m_outputStream.str("");
-    m_layoutTestController = LayoutTestController::create(std::string(""));
+    m_layoutTestController = LayoutTestController::create();
+    WKBundleSetShouldTrackVisitedLinks(m_bundle, false);
+    WKBundleRemoveAllVisitedLinks(m_bundle);
+}
+
+void InjectedBundle::setShouldTrackVisitedLinks()
+{
+    WKBundleSetShouldTrackVisitedLinks(m_bundle, true);
 }
 
 } // namespace WTR
index 1581ebc..9bda922 100644 (file)
@@ -52,17 +52,19 @@ public:
 
     std::ostringstream& os() { return m_outputStream; }
 
+    void setShouldTrackVisitedLinks();
+
 private:
     InjectedBundle();
     ~InjectedBundle();
 
     static void _didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo);
     static void _willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo);
-    static void _didRecieveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo);
+    static void _didReceiveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo);
 
     void didCreatePage(WKBundlePageRef page);
     void willDestroyPage(WKBundlePageRef page);
-    void didRecieveMessage(WKStringRef message);
+    void didReceiveMessage(WKStringRef message);
 
     void reset();
 
index c7417c0..3632fb9 100644 (file)
@@ -504,14 +504,14 @@ bool InjectedBundlePage::shouldBeginEditing(WKBundleRangeRef range)
 {
     if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
         InjectedBundle::shared().os() << "EDITING DELEGATE: shouldBeginEditingInDOMRange:" << range << "\n";
-    return InjectedBundle::shared().layoutTestController()->acceptsEditing();
+    return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
 }
 
 bool InjectedBundlePage::shouldEndEditing(WKBundleRangeRef range)
 {
     if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
         InjectedBundle::shared().os() << "EDITING DELEGATE: shouldEndEditingInDOMRange:" << range << "\n";
-    return InjectedBundle::shared().layoutTestController()->acceptsEditing();
+    return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
 }
 
 bool InjectedBundlePage::shouldInsertNode(WKBundleNodeRef node, WKBundleRangeRef rangeToReplace, WKInsertActionType action)
@@ -524,7 +524,7 @@ bool InjectedBundlePage::shouldInsertNode(WKBundleNodeRef node, WKBundleRangeRef
 
     if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
         InjectedBundle::shared().os() << "EDITING DELEGATE: shouldInsertNode:" << dumpPath(node) << " replacingDOMRange:" << rangeToReplace << " givenAction:" << insertactionstring[action] << "\n";
-    return InjectedBundle::shared().layoutTestController()->acceptsEditing();
+    return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
 }
 
 bool InjectedBundlePage::shouldInsertText(WKStringRef text, WKBundleRangeRef rangeToReplace, WKInsertActionType action)
@@ -537,14 +537,14 @@ bool InjectedBundlePage::shouldInsertText(WKStringRef text, WKBundleRangeRef ran
 
     if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
         InjectedBundle::shared().os() << "EDITING DELEGATE: shouldInsertText:" << text << " replacingDOMRange:" << rangeToReplace << " givenAction:" << insertactionstring[action] << "\n";
-    return InjectedBundle::shared().layoutTestController()->acceptsEditing();
+    return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
 }
 
 bool InjectedBundlePage::shouldDeleteRange(WKBundleRangeRef range)
 {
     if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
         InjectedBundle::shared().os() << "EDITING DELEGATE: shouldDeleteDOMRange:" << range << "\n";
-    return InjectedBundle::shared().layoutTestController()->acceptsEditing();
+    return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
 }
 
 bool InjectedBundlePage::shouldChangeSelectedRange(WKBundleRangeRef fromRange, WKBundleRangeRef toRange, WKAffinityType affinity, bool stillSelecting)
@@ -560,14 +560,14 @@ bool InjectedBundlePage::shouldChangeSelectedRange(WKBundleRangeRef fromRange, W
 
     if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
         InjectedBundle::shared().os() << "EDITING DELEGATE: shouldChangeSelectedDOMRange:" << fromRange << " toDOMRange:" << toRange << " affinity:" << affinitystring[affinity] << " stillSelecting:" << boolstring[stillSelecting] << "\n";
-    return InjectedBundle::shared().layoutTestController()->acceptsEditing();
+    return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
 }
 
 bool InjectedBundlePage::shouldApplyStyle(WKBundleCSSStyleDeclarationRef style, WKBundleRangeRef range)
 {
     if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
         InjectedBundle::shared().os() << "EDITING DELEGATE: shouldApplyStyle:" << style << " toElementsInDOMRange:" << range << "\n";
-    return InjectedBundle::shared().layoutTestController()->acceptsEditing();
+    return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
 }
 
 void InjectedBundlePage::didBeginEditing(WKStringRef notificationName)
index b08fae0..b5affec 100644 (file)
 
 namespace WTR {
 
-PassRefPtr<LayoutTestController> LayoutTestController::create(const std::string& testPathOrURL)
+PassRefPtr<LayoutTestController> LayoutTestController::create()
 {
-    return adoptRef(new LayoutTestController(testPathOrURL));
+    return adoptRef(new LayoutTestController);
 }
 
-LayoutTestController::LayoutTestController(const std::string& testPathOrURL)
+LayoutTestController::LayoutTestController()
     : m_whatToDump(RenderTree)
     , m_shouldDumpAllFrameScrollPositions(false)
-    , m_acceptsEditing(true)
+    , m_shouldAllowEditing(true)
     , m_dumpEditingCallbacks(false)
     , m_dumpStatusCallbacks(false)
     , m_waitToDump(false)
     , m_testRepaint(false)
     , m_testRepaintSweepHorizontally(false)
-    , m_testPathOrURL(testPathOrURL)
 {
 }
 
@@ -112,12 +111,17 @@ void LayoutTestController::notifyDone()
 
 unsigned LayoutTestController::numberOfActiveAnimations() const
 {
+    // FIXME: Is it OK this works only for the main frame?
+    // FIXME: If this is needed only for the main frame, then why is the function on WKBundleFrame instead of WKBundlePage?
     WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
     return WKBundleFrameGetNumberOfActiveAnimations(mainFrame);
 }
 
 bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId)
 {
+    // FIXME: Is it OK this works only for the main frame?
+    // FIXME: If this is needed only for the main frame, then why is the function on WKBundleFrame instead of WKBundlePage?
+
     RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, elementId));
     WKRetainPtr<WKStringRef> idWK(AdoptWK, WKStringCreateWithCFString(idCF.get()));
     RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, animationName));
@@ -127,12 +131,35 @@ bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef anima
     return WKBundleFramePauseAnimationOnElementWithId(mainFrame, nameWK.get(), idWK.get(), time);
 }
 
+void LayoutTestController::keepWebHistory()
+{
+    InjectedBundle::shared().setShouldTrackVisitedLinks();
+}
+
+JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSValueRef element)
+{
+    // FIXME: Is it OK this works only for the main frame?
+    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
+    if (!JSValueIsObject(context, element))
+        return JSValueMakeUndefined(context);
+    JSValueRef value = WKBundleFrameGetComputedStyleIncludingVisitedInfo(mainFrame, const_cast<JSObjectRef>(element));
+    if (!value)
+        return JSValueMakeUndefined(context);
+    return value;
+}
+
 // Object Creation
 
+static void JSObjectSetProperty(JSContextRef context, JSObjectRef object, const char* propertyName, JSWrappable* value, JSPropertyAttributes attributes, JSValueRef* exception)
+{
+    JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSStringCreateWithUTF8CString(propertyName));
+    JSObjectSetProperty(context, object, propertyNameString.get(), JSWrapper::wrap(context, value), attributes, exception);
+}
+
 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
-    JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), JSWrapper::wrap(context, this), kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
+    JSObjectSetProperty(context, windowObject, "layoutTestController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
 }
 
 } // namespace WTR
index dda65c4..8d52bb7 100644 (file)
@@ -36,7 +36,7 @@ namespace WTR {
 
 class LayoutTestController : public JSWrappable {
 public:
-    static PassRefPtr<LayoutTestController> create(const std::string& testPathOrURL);
+    static PassRefPtr<LayoutTestController> create();
     virtual ~LayoutTestController();
 
     // JSWrappable
@@ -55,6 +55,13 @@ public:
     void dumpEditingCallbacks() { m_dumpEditingCallbacks = true; }
     void dumpStatusCallbacks() { m_dumpStatusCallbacks = true; }
 
+    // Special options.
+    void keepWebHistory();
+    void setAcceptsEditing(bool value) { m_shouldAllowEditing = value; }
+
+    // Special DOM functions.
+    JSValueRef computedStyleIncludingVisitedInfo(JSValueRef);
+
     // Repaint testing.
     void testRepaint() { m_testRepaint = true; }
     void repaintSweepHorizontally() { m_testRepaintSweepHorizontally = true; }
@@ -64,9 +71,6 @@ public:
     unsigned numberOfActiveAnimations() const;
     bool pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId);
 
-    void setAcceptsEditing(bool value) { m_acceptsEditing = value; }
-    bool acceptsEditing() const { return m_acceptsEditing; }
-
     enum WhatToDump { RenderTree, MainFrameText, AllFramesText };
     WhatToDump whatToDump() const { return m_whatToDump; }
 
@@ -80,20 +84,20 @@ public:
     void waitToDumpWatchdogTimerFired();
     void invalidateWaitToDumpWatchdog();
 
+    bool shouldAllowEditing() const { return m_shouldAllowEditing; }
+
 private:
-    LayoutTestController(const std::string& testPathOrURL);
+    LayoutTestController();
 
     WhatToDump m_whatToDump;
     bool m_shouldDumpAllFrameScrollPositions;
-    bool m_acceptsEditing;
+    bool m_shouldAllowEditing;
     bool m_dumpEditingCallbacks;
     bool m_dumpStatusCallbacks;
     bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
     bool m_testRepaint;
     bool m_testRepaintSweepHorizontally;
 
-    std::string m_testPathOrURL;
-    
     RetainPtr<CFRunLoopTimerRef> m_waitToDumpWatchdog;
 };
 
index fec6b56..4f8cd6b 100644 (file)
@@ -82,7 +82,7 @@ void TestController::initialize(int argc, const char* argv[])
     WKContextInjectedBundleClient injectedBundlePathClient = {
         0,
         this,
-        _didRecieveMessageFromInjectedBundle
+        _didReceiveMessageFromInjectedBundle
     };
     WKContextSetInjectedBundleClient(m_context.get(), &injectedBundlePathClient);
 
@@ -126,14 +126,14 @@ bool TestController::run()
     return true;
 }
 
-void TestController::_didRecieveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo)
+void TestController::_didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo)
 {
-    static_cast<TestController*>(const_cast<void*>(clientInfo))->didRecieveMessageFromInjectedBundle(message);
+    static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveMessageFromInjectedBundle(message);
 }
 
-void TestController::didRecieveMessageFromInjectedBundle(WKStringRef message)
+void TestController::didReceiveMessageFromInjectedBundle(WKStringRef message)
 {
-    m_currentInvocation->didRecieveMessageFromInjectedBundle(message);
+    m_currentInvocation->didReceiveMessageFromInjectedBundle(message);
 }
 
 } // namespace WTR
index 7e829b6..bd073bf 100644 (file)
@@ -67,8 +67,8 @@ private:
     void initializeTestPluginPath();
 
     // WKContextInjectedBundleClient
-    static void _didRecieveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void*);
-    void didRecieveMessageFromInjectedBundle(WKStringRef message);
+    static void _didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void*);
+    void didReceiveMessageFromInjectedBundle(WKStringRef message);
 
     OwnPtr<TestInvocation> m_currentInvocation;
 
index 1434d50..b6e950f 100644 (file)
@@ -139,7 +139,7 @@ void TestInvocation::dump(const char* stringToDump)
     fflush(stderr);
 }
 
-void TestInvocation::didRecieveMessageFromInjectedBundle(WKStringRef message)
+void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef message)
 {
     RetainPtr<CFStringRef> cfMessage(AdoptCF, WKStringCopyCFString(0, message));
     
index b5fc041..e064a8f 100644 (file)
@@ -37,7 +37,7 @@ public:
     ~TestInvocation();
 
     void invoke();
-    void didRecieveMessageFromInjectedBundle(WKStringRef message);
+    void didReceiveMessageFromInjectedBundle(WKStringRef message);
 
 private:
     void dump(const char*);