[chromium] Need a way to test lost compositor context recovery
[WebKit-https.git] / Tools / DumpRenderTree / chromium / LayoutTestController.cpp
index 9f7e949..ad23aab 100644 (file)
 #include "WebElement.h"
 #include "WebFrame.h"
 #include "WebGeolocationClientMock.h"
+#include "WebIDBFactory.h"
 #include "WebInputElement.h"
 #include "WebKit.h"
 #include "WebNotificationPresenter.h"
+#include "WebPermissions.h"
 #include "WebScriptSource.h"
 #include "WebSecurityPolicy.h"
 #include "WebSettings.h"
@@ -75,13 +77,15 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     , m_deferMainResourceDataLoad(false)
     , m_showDebugLayerTree(false)
     , m_workQueue(this)
+    , m_shouldStayOnPageAfterHandlingBeforeUnload(false)
 {
 
     // Initialize the map that associates methods of this class with the names
-    // they will use when called by JavaScript.  The actual binding of those
+    // they will use when called by JavaScript. The actual binding of those
     // names to their methods will be done by calling bindToJavaScript() (defined
     // by CppBoundClass, the parent to LayoutTestController).
     bindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag);
+    bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult);
     bindMethod("addOriginAccessWhitelistEntry", &LayoutTestController::addOriginAccessWhitelistEntry);
     bindMethod("addUserScript", &LayoutTestController::addUserScript);
     bindMethod("addUserStyleSheet", &LayoutTestController::addUserStyleSheet);
@@ -105,14 +109,16 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("dumpStatusCallbacks", &LayoutTestController::dumpWindowStatusChanges);
     bindMethod("dumpTitleChanges", &LayoutTestController::dumpTitleChanges);
     bindMethod("elementDoesAutoCompleteForElementWithId", &LayoutTestController::elementDoesAutoCompleteForElementWithId);
-    bindMethod("ensureShadowRoot", &LayoutTestController::ensureShadowRoot);
     bindMethod("evaluateInWebInspector", &LayoutTestController::evaluateInWebInspector);
     bindMethod("evaluateScriptInIsolatedWorld", &LayoutTestController::evaluateScriptInIsolatedWorld);
+    bindMethod("setIsolatedWorldSecurityOrigin", &LayoutTestController::setIsolatedWorldSecurityOrigin);
     bindMethod("execCommand", &LayoutTestController::execCommand);
+    bindMethod("forceRedSelectionColors", &LayoutTestController::forceRedSelectionColors);
     bindMethod("grantDesktopNotificationPermission", &LayoutTestController::grantDesktopNotificationPermission);
     bindMethod("hasSpellingMarker", &LayoutTestController::hasSpellingMarker);
     bindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled);
     bindMethod("layerTreeAsText", &LayoutTestController::layerTreeAsText);
+    bindMethod("loseCompositorContext", &LayoutTestController::loseCompositorContext);
     bindMethod("markerTextForListItem", &LayoutTestController::markerTextForListItem);
     bindMethod("notifyDone", &LayoutTestController::notifyDone);
     bindMethod("numberOfActiveAnimations", &LayoutTestController::numberOfActiveAnimations);
@@ -132,7 +138,6 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("queueNonLoadingScript", &LayoutTestController::queueNonLoadingScript);
     bindMethod("queueReload", &LayoutTestController::queueReload);
     bindMethod("removeOriginAccessWhitelistEntry", &LayoutTestController::removeOriginAccessWhitelistEntry);
-    bindMethod("removeShadowRoot", &LayoutTestController::removeShadowRoot);
     bindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHorizontally);
     bindMethod("resetPageVisibility", &LayoutTestController::resetPageVisibility);
     bindMethod("resumeAnimations", &LayoutTestController::resumeAnimations);
@@ -152,14 +157,16 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("setDeferMainResourceDataLoad", &LayoutTestController::setDeferMainResourceDataLoad);
     bindMethod("setDomainRelaxationForbiddenForURLScheme", &LayoutTestController::setDomainRelaxationForbiddenForURLScheme);
     bindMethod("setEditingBehavior", &LayoutTestController::setEditingBehavior);
+    bindMethod("setAudioData", &LayoutTestController::setAudioData);
     bindMethod("setGeolocationPermission", &LayoutTestController::setGeolocationPermission);
     bindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEnabled);
     bindMethod("setJavaScriptCanAccessClipboard", &LayoutTestController::setJavaScriptCanAccessClipboard);
+    bindMethod("setJavaScriptProfilingEnabled", &LayoutTestController::setJavaScriptProfilingEnabled);
     bindMethod("setMinimumTimerInterval", &LayoutTestController::setMinimumTimerInterval);
     bindMethod("setMockDeviceOrientation", &LayoutTestController::setMockDeviceOrientation);
     bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError);
     bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition);
-    bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult);
+    bindMethod("setOverrideIndexedDBBackingStore", &LayoutTestController::setOverrideIndexedDBBackingStore);
     bindMethod("setPageVisibility", &LayoutTestController::setPageVisibility);
     bindMethod("setPluginsEnabled", &LayoutTestController::setPluginsEnabled);
     bindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingEnabled);
@@ -169,7 +176,6 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("setSmartInsertDeleteEnabled", &LayoutTestController::setSmartInsertDeleteEnabled);
     bindMethod("setStopProvisionalFrameLoads", &LayoutTestController::setStopProvisionalFrameLoads);
     bindMethod("setTabKeyCyclesThroughElements", &LayoutTestController::setTabKeyCyclesThroughElements);
-    bindMethod("setTimelineProfilingEnabled", &LayoutTestController::setTimelineProfilingEnabled);
     bindMethod("setUserStyleSheetEnabled", &LayoutTestController::setUserStyleSheetEnabled);
     bindMethod("setUserStyleSheetLocation", &LayoutTestController::setUserStyleSheetLocation);
     bindMethod("setValueForUser", &LayoutTestController::setValueForUser);
@@ -179,8 +185,6 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("setWindowIsKey", &LayoutTestController::setWindowIsKey);
     bindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled);
     bindMethod("setAsynchronousSpellCheckingEnabled", &LayoutTestController::setAsynchronousSpellCheckingEnabled);
-    bindMethod("shadowRoot", &LayoutTestController::shadowRoot);
-    bindMethod("shadowPseudoId", &LayoutTestController::shadowPseudoId);
     bindMethod("showWebInspector", &LayoutTestController::showWebInspector);
     bindMethod("simulateDesktopNotificationClick", &LayoutTestController::simulateDesktopNotificationClick);
     bindMethod("suspendAnimations", &LayoutTestController::suspendAnimations);
@@ -188,6 +192,10 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("waitForPolicyDelegate", &LayoutTestController::waitForPolicyDelegate);
     bindMethod("waitUntilDone", &LayoutTestController::waitUntilDone);
     bindMethod("windowCount", &LayoutTestController::windowCount);
+    bindMethod("setTextDirection", &LayoutTestController::setTextDirection);
+    bindMethod("setImagesAllowed", &LayoutTestController::setImagesAllowed);
+    bindMethod("setStorageAllowed", &LayoutTestController::setStorageAllowed);
+    bindMethod("setPluginsAllowed", &LayoutTestController::setPluginsAllowed);
 
     // The following are stubs.
     bindMethod("abortModal", &LayoutTestController::abortModal);
@@ -213,6 +221,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("deleteLocalStorageForOrigin", &LayoutTestController::deleteLocalStorageForOrigin);
     bindMethod("observeStorageTrackerNotifications", &LayoutTestController::observeStorageTrackerNotifications);
     bindMethod("syncLocalStorage", &LayoutTestController::syncLocalStorage);
+    bindMethod("setShouldStayOnPageAfterHandlingBeforeUnload", &LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload);
     
     // The fallback method is called when an unknown method is invoked.
     bindFallbackMethod(&LayoutTestController::fallbackMethod);
@@ -265,9 +274,8 @@ void LayoutTestController::WorkQueue::processWork()
 void LayoutTestController::WorkQueue::reset()
 {
     m_frozen = false;
-    while (!m_queue.isEmpty()) {
+    while (!m_queue.isEmpty())
         delete m_queue.takeFirst();
-    }
 }
 
 void LayoutTestController::WorkQueue::addWork(WorkItem* work)
@@ -394,12 +402,13 @@ void LayoutTestController::completeNotifyDone(bool isTimeout)
 
 class WorkItemBackForward : public LayoutTestController::WorkItem {
 public:
-    WorkItemBackForward(int distance) : m_distance(distance) {}
+    WorkItemBackForward(int distance) : m_distance(distance) { }
     bool run(TestShell* shell)
     {
         shell->goToOffset(m_distance);
         return true; // FIXME: Did it really start a navigation?
     }
+
 private:
     int m_distance;
 };
@@ -435,24 +444,26 @@ void LayoutTestController::queueReload(const CppArgumentList&, CppVariant* resul
 
 class WorkItemLoadingScript : public LayoutTestController::WorkItem {
 public:
-    WorkItemLoadingScript(const string& script) : m_script(script) {}
+    WorkItemLoadingScript(const string& script) : m_script(script) { }
     bool run(TestShell* shell)
     {
         shell->webView()->mainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(m_script)));
         return true; // FIXME: Did it really start a navigation?
     }
+
 private:
     string m_script;
 };
 
 class WorkItemNonLoadingScript : public LayoutTestController::WorkItem {
 public:
-    WorkItemNonLoadingScript(const string& script) : m_script(script) {}
+    WorkItemNonLoadingScript(const string& script) : m_script(script) { }
     bool run(TestShell* shell)
     {
         shell->webView()->mainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(m_script)));
         return false;
     }
+
 private:
     string m_script;
 };
@@ -475,12 +486,13 @@ class WorkItemLoad : public LayoutTestController::WorkItem {
 public:
     WorkItemLoad(const WebURL& url, const WebString& target)
         : m_url(url)
-        , m_target(target) {}
+        , m_target(target) { }
     bool run(TestShell* shell)
     {
         shell->webViewHost()->loadURLForFrame(m_url, m_target);
         return true; // FIXME: Did it really start a navigation?
     }
+
 private:
     WebURL m_url;
     WebString m_target;
@@ -490,7 +502,7 @@ void LayoutTestController::queueLoad(const CppArgumentList& arguments, CppVarian
 {
     if (arguments.size() > 0 && arguments[0].isString()) {
         // FIXME: Implement WebURL::resolve() and avoid GURL.
-        GURL currentURL = m_shell->webView()->mainFrame()->url();
+        GURL currentURL = m_shell->webView()->mainFrame()->document().url();
         GURL fullURL = currentURL.Resolve(arguments[0].toString());
 
         string target = "";
@@ -506,17 +518,18 @@ class WorkItemLoadHTMLString : public LayoutTestController::WorkItem  {
 public:
     WorkItemLoadHTMLString(const std::string& html, const WebURL& baseURL)
         : m_html(html)
-        , m_baseURL(baseURL) {}
+        , m_baseURL(baseURL) { }
     WorkItemLoadHTMLString(const std::string& html, const WebURL& baseURL, const WebURL& unreachableURL)
         : m_html(html)
         , m_baseURL(baseURL)
-        , m_unreachableURL(unreachableURL) {}
+        , m_unreachableURL(unreachableURL) { }
     bool run(TestShell* shell)
     {
         shell->webView()->mainFrame()->loadHTMLString(
             WebKit::WebData(m_html.data(), m_html.length()), m_baseURL, m_unreachableURL);
         return true;
     }
+
 private:
     std::string m_html;
     WebURL m_baseURL;
@@ -561,6 +574,7 @@ void LayoutTestController::reset()
         m_shell->webView()->removeAllUserContent();
     }
     m_dumpAsText = false;
+    m_dumpAsAudio = false;
     m_dumpEditingCallbacks = false;
     m_dumpFrameLoadCallbacks = false;
     m_dumpUserGestureInFrameLoadCallbacks = false;
@@ -600,6 +614,7 @@ void LayoutTestController::reset()
         m_closeRemainingWindows = true;
     m_workQueue.reset();
     m_taskList.revokeAll();
+    m_shouldStayOnPageAfterHandlingBeforeUnload = false;
 }
 
 void LayoutTestController::locationChangeDone()
@@ -659,73 +674,6 @@ void LayoutTestController::setAsynchronousSpellCheckingEnabled(const CppArgument
     result->setNull();
 }
 
-void LayoutTestController::shadowRoot(const CppArgumentList& arguments, CppVariant* result)
-{
-    if (arguments.size() != 1 || !arguments[0].isObject()) {
-        result->setNull();
-        return;
-    }
-
-    WebElement element;
-    if (!WebBindings::getElement(arguments[0].value.objectValue, &element)) {
-        result->setNull();
-        return;
-    }
-
-    NPObject* shadowRoot = WebBindings::makeNode(element.shadowRoot());
-    if (!shadowRoot) {
-        result->setNull();
-        return;
-    }
-
-    result->set(shadowRoot);
-    WebBindings::releaseObject(shadowRoot);
-}
-
-void LayoutTestController::ensureShadowRoot(const CppArgumentList& arguments, CppVariant* result)
-{
-    if (arguments.size() != 1 || !arguments[0].isObject()) {
-        result->setNull();
-        return;
-    }
-
-    WebElement element;
-    if (!WebBindings::getElement(arguments[0].value.objectValue, &element)) {
-        result->setNull();
-        return;
-    }
-
-    NPObject* shadowRoot = WebBindings::makeNode(element.ensureShadowRoot());
-    if (!shadowRoot) {
-        result->setNull();
-        return;
-    }
-
-    result->set(shadowRoot);
-    WebBindings::releaseObject(shadowRoot);
-}
-
-void LayoutTestController::removeShadowRoot(const CppArgumentList& arguments, CppVariant* result)
-{
-    if (arguments.size() != 1 || !arguments[0].isObject())
-        return;
-
-    WebElement element;
-    if (!WebBindings::getElement(arguments[0].value.objectValue, &element))
-        return;
-
-    element.removeShadowRoot();
-}
-
-void LayoutTestController::shadowPseudoId(const CppArgumentList& arguments, CppVariant* result)
-{
-    WebElement element;
-    if (!WebBindings::getElement(arguments[0].value.objectValue, &element))
-        result->setNull();
-    else
-        result->set(element.shadowPseudoId().utf8());
-}
-
 void LayoutTestController::showWebInspector(const CppArgumentList&, CppVariant* result)
 {
     m_shell->showDevTools();
@@ -813,6 +761,27 @@ void LayoutTestController::setPopupBlockingEnabled(const CppArgumentList& argume
     result->setNull();
 }
 
+void LayoutTestController::setImagesAllowed(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_shell->webPermissions()->setImagesAllowed(arguments[0].toBoolean());
+    result->setNull();
+}
+
+void LayoutTestController::setStorageAllowed(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_shell->webPermissions()->setStorageAllowed(arguments[0].toBoolean());
+    result->setNull();
+}
+
+void LayoutTestController::setPluginsAllowed(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_shell->webPermissions()->setPluginsAllowed(arguments[0].toBoolean());
+    result->setNull();
+}
+
 void LayoutTestController::setUseDashboardCompatibilityMode(const CppArgumentList&, CppVariant* result)
 {
     // We have no need to support Dashboard Compatibility Mode (mac-only)
@@ -926,7 +895,7 @@ void LayoutTestController::pathToLocalResource(const CppArgumentList& arguments,
     }
 #endif
 
-    // Some layout tests use file://// which we resolve as a UNC path.  Normalize
+    // Some layout tests use file://// which we resolve as a UNC path. Normalize
     // them to just file:///.
     string lowerUrl = url;
     transform(lowerUrl.begin(), lowerUrl.end(), lowerUrl.begin(), ::tolower);
@@ -1123,6 +1092,22 @@ void LayoutTestController::setIconDatabaseEnabled(const CppArgumentList&, CppVar
     result->setNull();
 }
 
+void LayoutTestController::setOverrideIndexedDBBackingStore(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+#if ENABLE(INDEXED_DATABASE)
+    if (arguments.size() < 1 || !arguments[0].isString())
+        return;
+    string name = arguments[0].toString();
+    if (name == "default")
+        WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::DefaultBackingStore);
+    else if (name == "sqlite")
+        WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::SQLiteBackingStore);
+    else if (name == "leveldb")
+        WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::LevelDBBackingStore);
+#endif
+}
+
 void LayoutTestController::callShouldCloseOnWebView(const CppArgumentList&, CppVariant* result)
 {
     result->set(m_shell->webView()->dispatchBeforeUnloadEvent());
@@ -1283,6 +1268,18 @@ void LayoutTestController::evaluateScriptInIsolatedWorld(const CppArgumentList&
     result->setNull();
 }
 
+void LayoutTestController::setIsolatedWorldSecurityOrigin(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+
+    if (arguments.size() != 2 || !arguments[0].isNumber() || !arguments[1].isString())
+        return;
+
+    m_shell->webView()->focusedFrame()->setIsolatedWorldSecurityOrigin(
+        arguments[0].toInt32(),
+        WebSecurityOrigin::createFromString(cppVariantToWebString(arguments[1])));
+}
+
 void LayoutTestController::setAllowUniversalAccessFromFileURLs(const CppArgumentList& arguments, CppVariant* result)
 {
     if (arguments.size() > 0 && arguments[0].isBool()) {
@@ -1294,10 +1291,9 @@ void LayoutTestController::setAllowUniversalAccessFromFileURLs(const CppArgument
 
 void LayoutTestController::setAllowDisplayOfInsecureContent(const CppArgumentList& arguments, CppVariant* result)
 {
-    if (arguments.size() > 0 && arguments[0].isBool()) {
-        m_shell->preferences()->allowDisplayOfInsecureContent = arguments[0].value.boolValue;
-        m_shell->applyPreferences();
-    }
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_shell->webPermissions()->setDisplayingInsecureContentAllowed(arguments[0].toBoolean());
+
     result->setNull();
 }
 
@@ -1312,10 +1308,9 @@ void LayoutTestController::setAllowFileAccessFromFileURLs(const CppArgumentList&
 
 void LayoutTestController::setAllowRunningOfInsecureContent(const CppArgumentList& arguments, CppVariant* result)
 {
-    if (arguments.size() > 0 && arguments[0].isBool()) {
-        m_shell->preferences()->allowRunningOfInsecureContent = arguments[0].value.boolValue;
-        m_shell->applyPreferences();
-    }
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_shell->webPermissions()->setRunningInsecureContentAllowed(arguments[0].value.boolValue);
+
     result->setNull();
 }
 
@@ -1432,6 +1427,12 @@ void LayoutTestController::overridePreference(const CppArgumentList& arguments,
         prefs->hyperlinkAuditingEnabled = cppVariantToBool(value);
     else if (key == "WebKitEnableCaretBrowsing")
         prefs->caretBrowsingEnabled = cppVariantToBool(value);
+    else if (key == "WebKitAllowDisplayingInsecureContent")
+        prefs->allowDisplayOfInsecureContent = cppVariantToBool(value);
+    else if (key == "WebKitAllowRunningInsecureContent")
+        prefs->allowRunningOfInsecureContent = cppVariantToBool(value);
+    else if (key == "WebKitHixie76WebSocketProtocolEnabled")
+        prefs->hixie76WebSocketProtocolEnabled = cppVariantToBool(value);
     else {
         string message("Invalid name for preference: ");
         message.append(key);
@@ -1595,12 +1596,12 @@ void LayoutTestController::logErrorToConsole(const std::string& text)
         WebString(), 0);
 }
 
-void LayoutTestController::setTimelineProfilingEnabled(const CppArgumentList& arguments, CppVariant* result)
+void LayoutTestController::setJavaScriptProfilingEnabled(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();
     if (arguments.size() < 1 || !arguments[0].isBool())
         return;
-    m_shell->drtDevToolsAgent()->setTimelineProfilingEnabled(arguments[0].toBoolean());
+    m_shell->drtDevToolsAgent()->setJavaScriptProfilingEnabled(arguments[0].toBoolean());
 }
 
 void LayoutTestController::evaluateInWebInspector(const CppArgumentList& arguments, CppVariant* result)
@@ -1611,6 +1612,12 @@ void LayoutTestController::evaluateInWebInspector(const CppArgumentList& argumen
     m_shell->drtDevToolsAgent()->evaluateInWebInspector(arguments[0].toInt32(), arguments[1].toString());
 }
 
+void LayoutTestController::forceRedSelectionColors(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+    m_shell->webView()->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000, 0xffc0c0c0);
+}
+
 void LayoutTestController::addUserScript(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();
@@ -1715,6 +1722,11 @@ void LayoutTestController::layerTreeAsText(const CppArgumentList& args, CppVaria
     result->set(m_shell->webView()->mainFrame()->layerTreeAsText(m_showDebugLayerTree).utf8());
 }
 
+void LayoutTestController::loseCompositorContext(const CppArgumentList&, CppVariant*)
+{
+    m_shell->webView()->loseCompositorContext();
+}
+
 void LayoutTestController::markerTextForListItem(const CppArgumentList& args, CppVariant* result)
 {
     WebElement element;
@@ -1803,6 +1815,14 @@ void LayoutTestController::syncLocalStorage(const CppArgumentList&, CppVariant*)
     // Not Implemented
 }
 
+void LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() == 1 && arguments[0].isBool())
+        m_shouldStayOnPageAfterHandlingBeforeUnload = arguments[0].toBoolean();
+
+    result->setNull();
+}
+
 void LayoutTestController::setPluginsEnabled(const CppArgumentList& arguments, CppVariant* result)
 {
     if (arguments.size() > 0 && arguments[0].isBool()) {
@@ -1825,5 +1845,45 @@ void LayoutTestController::setPageVisibility(const CppArgumentList& arguments, C
             m_shell->webView()->setVisibilityState(WebPageVisibilityStateVisible, false);
         else if (newVisibility == "hidden")
             m_shell->webView()->setVisibilityState(WebPageVisibilityStateHidden, false);
+        else if (newVisibility == "prerender")
+            m_shell->webView()->setVisibilityState(WebPageVisibilityStatePrerender, false);
     }
 }
+
+void LayoutTestController::setTextDirection(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+    if (arguments.size() != 1 || !arguments[0].isString())
+        return;
+
+    // Map a direction name to a WebTextDirection value.
+    std::string directionName = arguments[0].toString();
+    WebKit::WebTextDirection direction;
+    if (directionName == "auto")
+        direction = WebKit::WebTextDirectionDefault;
+    else if (directionName == "rtl")
+        direction = WebKit::WebTextDirectionRightToLeft;
+    else if (directionName == "ltr")
+        direction = WebKit::WebTextDirectionLeftToRight;
+    else
+        return;
+
+    m_shell->webView()->setTextDirection(direction);
+}
+
+void LayoutTestController::setAudioData(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+
+    if (arguments.size() < 1 || !arguments[0].isObject())
+        return;
+
+    // Check that passed-in object is, in fact, an ArrayBufferView.
+    NPObject* npobject = NPVARIANT_TO_OBJECT(arguments[0]);
+    if (!npobject)
+        return;
+    if (!WebBindings::getArrayBufferView(npobject, &m_audioData))
+        return;
+
+    setShouldDumpAsAudio(true);
+}