summaryrefslogtreecommitdiffstats
path: root/Tools/DumpRenderTree/LayoutTestController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/DumpRenderTree/LayoutTestController.cpp')
-rw-r--r--Tools/DumpRenderTree/LayoutTestController.cpp53
1 files changed, 51 insertions, 2 deletions
diff --git a/Tools/DumpRenderTree/LayoutTestController.cpp b/Tools/DumpRenderTree/LayoutTestController.cpp
index 16a3149..1133a88 100644
--- a/Tools/DumpRenderTree/LayoutTestController.cpp
+++ b/Tools/DumpRenderTree/LayoutTestController.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2010 Joone Hur <joone@kldp.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -335,6 +335,31 @@ static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef fun
return JSValueMakeUndefined(context);
}
+static JSValueRef addURLToRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ if (argumentCount < 2)
+ return JSValueMakeUndefined(context);
+
+ JSRetainPtr<JSStringRef> origin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+ ASSERT(!*exception);
+
+ JSRetainPtr<JSStringRef> destination(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+ ASSERT(!*exception);
+
+ size_t maxLength = JSStringGetMaximumUTF8CStringSize(origin.get());
+ char* originBuffer = new char[maxLength + 1];
+ JSStringGetUTF8CString(origin.get(), originBuffer, maxLength + 1);
+
+ maxLength = JSStringGetMaximumUTF8CStringSize(destination.get());
+ char* destinationBuffer = new char[maxLength + 1];
+ JSStringGetUTF8CString(destination.get(), destinationBuffer, maxLength + 1);
+
+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+ controller->addURLToRedirect(originBuffer, destinationBuffer);
+
+ return JSValueMakeUndefined(context);
+}
+
static JSValueRef callShouldCloseOnWebViewCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
// Has mac & windows implementation
@@ -833,8 +858,16 @@ static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef
baseURL.adopt(JSStringCreateWithUTF8CString(""));
LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
- controller->queueLoadHTMLString(content.get(), baseURL.get());
+ if (argumentCount >= 3) {
+ JSRetainPtr<JSStringRef> unreachableURL;
+ unreachableURL.adopt(JSValueToStringCopy(context, arguments[2], exception));
+ ASSERT(!*exception);
+ controller->queueLoadAlternateHTMLString(content.get(), baseURL.get(), unreachableURL.get());
+ return JSValueMakeUndefined(context);
+ }
+
+ controller->queueLoadHTMLString(content.get(), baseURL.get());
return JSValueMakeUndefined(context);
}
@@ -1930,6 +1963,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
static JSStaticFunction staticFunctions[] = {
{ "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { "addURLToRedirect", addURLToRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -2077,6 +2111,11 @@ void LayoutTestController::queueLoadHTMLString(JSStringRef content, JSStringRef
WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL));
}
+void LayoutTestController::queueLoadAlternateHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL)
+{
+ WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, unreachableURL));
+}
+
void LayoutTestController::queueBackNavigation(int howFarBack)
{
WorkQueue::shared()->queue(new BackItem(howFarBack));
@@ -2140,5 +2179,15 @@ void LayoutTestController::setPOSIXLocale(JSStringRef locale)
setlocale(LC_ALL, localeBuf);
}
+void LayoutTestController::addURLToRedirect(std::string origin, std::string destination)
+{
+ m_URLsToRedirect[origin] = destination;
+}
+
+const std::string& LayoutTestController::redirectionDestinationForURL(std::string origin)
+{
+ return m_URLsToRedirect[origin];
+}
+
const unsigned LayoutTestController::maxViewWidth = 800;
const unsigned LayoutTestController::maxViewHeight = 600;