summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2010-05-21 16:53:46 +0100
committerKristian Monsen <kristianm@google.com>2010-05-25 10:24:15 +0100
commit6c2af9490927c3c5959b5cb07461b646f8b32f6c (patch)
treef7111b9b22befab472616c1d50ec94eb50f1ec8c /WebKitTools/DumpRenderTree
parenta149172322a9067c14e8b474a53e63649aa17cad (diff)
downloadexternal_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.zip
external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.gz
external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.bz2
Merge WebKit at r59636: Initial merge by git
Change-Id: I59b289c4e6b18425f06ce41cc9d34c522515de91
Diffstat (limited to 'WebKitTools/DumpRenderTree')
-rw-r--r--WebKitTools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp207
-rw-r--r--WebKitTools/DumpRenderTree/DumpRenderTree.gypi36
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp1
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h1
-rw-r--r--WebKitTools/DumpRenderTree/chromium/EventSender.cpp153
-rw-r--r--WebKitTools/DumpRenderTree/chromium/EventSender.h28
-rw-r--r--WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp102
-rw-r--r--WebKitTools/DumpRenderTree/chromium/LayoutTestController.h21
-rw-r--r--WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp119
-rw-r--r--WebKitTools/DumpRenderTree/chromium/NotificationPresenter.h70
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestShell.cpp4
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestShell.h6
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestWebWorker.h1
-rw-r--r--WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp36
-rw-r--r--WebKitTools/DumpRenderTree/chromium/WebViewHost.h22
-rw-r--r--WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp26
-rw-r--r--WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp17
-rw-r--r--WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm3
-rw-r--r--WebKitTools/DumpRenderTree/mac/EventSendingController.mm23
-rw-r--r--WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm11
-rw-r--r--WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp20
-rw-r--r--WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h2
-rw-r--r--WebKitTools/DumpRenderTree/qt/ImageDiff.cpp7
-rw-r--r--WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp56
-rw-r--r--WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h3
-rw-r--r--WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp11
-rw-r--r--WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h1
-rw-r--r--WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp15
-rw-r--r--WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp9
-rwxr-xr-xWebKitTools/DumpRenderTree/win/UIDelegate.cpp2
30 files changed, 697 insertions, 316 deletions
diff --git a/WebKitTools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp b/WebKitTools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp
deleted file mode 100644
index 7167bf2..0000000
--- a/WebKitTools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp
+++ /dev/null
@@ -1,207 +0,0 @@
-#
-# Copyright (C) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
- 'includes': [
- '../../../WebKit/chromium/features.gypi',
- ],
- 'variables': {
- 'webkit_top': '../../..',
- 'webkit_api_dir': '<(webkit_top)/WebKit/chromium',
- 'conditions': [
- # Location of the chromium src directory and target type is different
- # if webkit is built inside chromium or as standalone project.
- ['inside_chromium_build==0', {
- # DumpRenderTree is being built outside of the full chromium project.
- # e.g. via build-dumprendertree --chromium
- 'chromium_src_dir': '<(webkit_api_dir)',
- 'webkit_support_gyp': '<(webkit_api_dir)/webkit/support/webkit_support.gyp',
- },{
- # WebKit is checked out in src/chromium/third_party/WebKit
- 'chromium_src_dir': '<(webkit_top)/../..',
- 'webkit_support_gyp': '<(webkit_top)/../../webkit/webkit.gyp',
- }],
- ],
- },
- 'target_defaults': {
- 'target_conditions': [
- ['OS!="linux" and OS!="freebsd" and OS!="openbsd"', {
- 'sources/': [
- ['exclude', '(Gtk|Linux)\\.cpp$']
- ]
- }],
- ['OS!="win"', {
- 'sources/': [
- ['exclude', 'Win\\.cpp$'],
- ]
- }],
- ['OS!="mac"', {
- 'sources/': [
- # .mm is already excluded by common.gypi
- ['exclude', 'Mac\\.cpp$'],
- ]
- }],
- ],
- },
- 'targets': [
- {
- 'target_name': 'DumpRenderTree',
- 'type': 'executable',
- 'mac_bundle': 1,
- 'dependencies': [
- '<(webkit_api_dir)/WebKit.gyp:webkit',
- '<(webkit_top)/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf_config',
- '<(chromium_src_dir)/third_party/icu/icu.gyp:icuuc',
- '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
- '<(chromium_src_dir)/skia/skia.gyp:skia',
- '<(webkit_support_gyp):webkit_support',
- ],
- 'include_dirs': [
- '.',
- '<(webkit_api_dir)',
- '<(webkit_top)/JavaScriptCore',
- '<(chromium_src_dir)',
- ],
- 'defines': [
- # Technically not a unit test but require functions available only to
- # unit tests.
- 'UNIT_TEST',
- ],
- 'sources': [
- '../chromium/AccessibilityController.cpp',
- '../chromium/AccessibilityController.h',
- '../chromium/AccessibilityUIElement.cpp',
- '../chromium/AccessibilityUIElement.h',
- '../chromium/CppBoundClass.cpp',
- '../chromium/CppBoundClass.h',
- '../chromium/CppVariant.cpp',
- '../chromium/CppVariant.h',
- '../chromium/DumpRenderTree.cpp',
- '../chromium/EventSender.cpp',
- '../chromium/EventSender.h',
- '../chromium/LayoutTestController.cpp',
- '../chromium/LayoutTestController.h',
- '../chromium/MockSpellCheck.cpp',
- '../chromium/MockSpellCheck.h',
- '../chromium/PlainTextController.cpp',
- '../chromium/PlainTextController.h',
- '../chromium/TestNavigationController.cpp',
- '../chromium/TestNavigationController.h',
- '../chromium/TestShell.cpp',
- '../chromium/TestShell.h',
- '../chromium/TestShellGtk.cpp',
- '../chromium/TestShellMac.mm',
- '../chromium/TestShellWin.cpp',
- '../chromium/TextInputController.cpp',
- '../chromium/TextInputController.h',
- '../chromium/WebViewHost.cpp',
- '../chromium/WebViewHost.h',
- ],
- 'conditions': [
- ['OS=="mac"', {
- 'dependencies': ['LayoutTestHelper'],
- 'mac_bundle_resources': [
- '../qt/fonts/AHEM____.TTF',
- '../fonts/WebKitWeightWatcher100.ttf',
- '../fonts/WebKitWeightWatcher200.ttf',
- '../fonts/WebKitWeightWatcher300.ttf',
- '../fonts/WebKitWeightWatcher400.ttf',
- '../fonts/WebKitWeightWatcher500.ttf',
- '../fonts/WebKitWeightWatcher600.ttf',
- '../fonts/WebKitWeightWatcher700.ttf',
- '../fonts/WebKitWeightWatcher800.ttf',
- '../fonts/WebKitWeightWatcher900.ttf',
- ],
- 'actions': [
- {
- 'action_name': 'repack_locale',
- 'variables': {
- 'repack_path': '<(chromium_src_dir)/tools/data_pack/repack.py',
- 'pak_inputs': [
- '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak',
- '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_en-US.pak',
- '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.pak',
- ]},
- 'inputs': [
- '<(repack_path)',
- '<@(pak_inputs)',
- ],
- 'outputs': [
- '<(INTERMEDIATE_DIR)/repack/DumpRenderTree.pak',
- ],
- 'action': ['python', '<(repack_path)', '<@(_outputs)', '<@(pak_inputs)'],
- 'process_outputs_as_mac_bundle_resources': 1,
- },
- ], # actions
- }], # mac
- ], # conditions
- },
-
- {
- 'target_name': 'ImageDiff',
- 'type': 'executable',
- 'dependencies': [
- '<(webkit_api_dir)/WebKit.gyp:webkit',
- '<(webkit_top)/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf',
- '<(chromium_src_dir)/gfx/gfx.gyp:gfx',
- ],
- 'include_dirs': [
- '<(webkit_top)/JavaScriptCore',
- '<(chromium_src_dir)',
- ],
- 'sources': [
- '../chromium/ImageDiff.cpp',
- ],
- },
- ], # targets
-
- 'conditions': [
- ['OS=="mac"', {
- 'targets': [
- {
- 'target_name': 'LayoutTestHelper',
- 'type': 'executable',
- 'sources': ['../chromium/LayoutTestHelper.mm'],
- 'link_settings': {
- 'libraries': [
- '$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
- ],
- },
- },
- ],
- }],
- ], # conditions
-}
-
-# Local Variables:
-# tab-width:2
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/WebKitTools/DumpRenderTree/DumpRenderTree.gypi b/WebKitTools/DumpRenderTree/DumpRenderTree.gypi
new file mode 100644
index 0000000..693f02e
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/DumpRenderTree.gypi
@@ -0,0 +1,36 @@
+{
+ 'variables': {
+ 'drt_files': [
+ 'chromium/AccessibilityController.cpp',
+ 'chromium/AccessibilityController.h',
+ 'chromium/AccessibilityUIElement.cpp',
+ 'chromium/AccessibilityUIElement.h',
+ 'chromium/CppBoundClass.cpp',
+ 'chromium/CppBoundClass.h',
+ 'chromium/CppVariant.cpp',
+ 'chromium/CppVariant.h',
+ 'chromium/DumpRenderTree.cpp',
+ 'chromium/EventSender.cpp',
+ 'chromium/EventSender.h',
+ 'chromium/LayoutTestController.cpp',
+ 'chromium/LayoutTestController.h',
+ 'chromium/MockSpellCheck.cpp',
+ 'chromium/MockSpellCheck.h',
+ 'chromium/NotificationPresenter.h',
+ 'chromium/NotificationPresenter.cpp',
+ 'chromium/PlainTextController.cpp',
+ 'chromium/PlainTextController.h',
+ 'chromium/TestNavigationController.cpp',
+ 'chromium/TestNavigationController.h',
+ 'chromium/TestShell.cpp',
+ 'chromium/TestShell.h',
+ 'chromium/TestShellGtk.cpp',
+ 'chromium/TestShellMac.mm',
+ 'chromium/TestShellWin.cpp',
+ 'chromium/TextInputController.cpp',
+ 'chromium/TextInputController.h',
+ 'chromium/WebViewHost.cpp',
+ 'chromium/WebViewHost.h',
+ ],
+ }
+}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp
index 83f420f..60103a5 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp
@@ -971,6 +971,7 @@ static NPObject *pluginAllocate(NPP npp, NPClass *theClass)
newInstance->lastUrl = NULL;
newInstance->lastHeaders = NULL;
+ newInstance->testGetURLOnDestroy = FALSE;
newInstance->testDocumentOpenInDestroyStream = FALSE;
newInstance->testWindowOpen = FALSE;
newInstance->testKeyboardFocusForPlugins = FALSE;
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h b/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h
index 2ae4dbf..0020e56 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h
@@ -40,6 +40,7 @@ typedef struct {
NPObject* rememberedObject;
NPStream* stream;
NPBool testDocumentOpenInDestroyStream;
+ NPBool testGetURLOnDestroy;
NPBool testWindowOpen;
NPBool testKeyboardFocusForPlugins;
char* onStreamLoad;
diff --git a/WebKitTools/DumpRenderTree/chromium/EventSender.cpp b/WebKitTools/DumpRenderTree/chromium/EventSender.cpp
index c48aaf4..381112e 100644
--- a/WebKitTools/DumpRenderTree/chromium/EventSender.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/EventSender.cpp
@@ -50,6 +50,7 @@
#include "public/WebDragOperation.h"
#include "public/WebPoint.h"
#include "public/WebString.h"
+#include "public/WebTouchPoint.h"
#include "public/WebView.h"
#include "webkit/support/webkit_support.h"
#include <wtf/Deque.h>
@@ -65,7 +66,6 @@ using namespace base;
using namespace std;
using namespace WebKit;
-TestShell* EventSender::testShell = 0;
WebPoint EventSender::lastMousePos;
WebMouseEvent::Button EventSender::pressedButton = WebMouseEvent::ButtonNone;
WebMouseEvent::Button EventSender::lastButtonType = WebMouseEvent::ButtonNone;
@@ -94,6 +94,8 @@ static WebDragOperation currentDragEffect;
static WebDragOperationsMask currentDragEffectsAllowed;
static bool replayingSavedEvents = false;
static Deque<SavedEvent> mouseEventQueue;
+static int touchModifiers;
+static Vector<WebTouchPoint> touchPoints;
// Time and place of the last mouse up event.
static double lastClickTimeSec = 0;
@@ -161,7 +163,7 @@ static bool applyKeyModifier(const string& modifierName, WebInputEvent* event)
event->modifiers |= WebInputEvent::AltKey;
#if !OS(MAC_OS_X)
// On Windows all keys with Alt modifier will be marked as system key.
- // We keep the same behavior on Linux, see:
+ // We keep the same behavior on Linux and everywhere non-Mac, see:
// WebKit/chromium/src/gtk/WebInputEventFactory.cpp
// If we want to change this behavior on Linux, this piece of code must be
// kept in sync with the related code in above file.
@@ -246,13 +248,8 @@ enum KeyLocationCode {
EventSender::EventSender(TestShell* shell)
: m_methodFactory(this)
+ , m_shell(shell)
{
- // Set static testShell variable since we can't do it in an initializer list.
- // We also need to be careful not to assign testShell to new windows which are
- // temporary.
- if (!testShell)
- testShell = shell;
-
// Initialize the map that associates methods of this class with the names
// they will use when called by JavaScript. The actual binding of those
// names to their methods will be done by calling bindToJavaScript() (defined
@@ -274,6 +271,16 @@ EventSender::EventSender(TestShell* shell)
bindMethod("zoomPageOut", &EventSender::zoomPageOut);
bindMethod("scheduleAsynchronousClick", &EventSender::scheduleAsynchronousClick);
bindMethod("beginDragWithFiles", &EventSender::beginDragWithFiles);
+ bindMethod("addTouchPoint", &EventSender::addTouchPoint);
+ bindMethod("cancelTouchPoint", &EventSender::cancelTouchPoint);
+ bindMethod("clearTouchPoints", &EventSender::clearTouchPoints);
+ bindMethod("releaseTouchPoint", &EventSender::releaseTouchPoint);
+ bindMethod("updateTouchPoint", &EventSender::updateTouchPoint);
+ bindMethod("setTouchModifier", &EventSender::setTouchModifier);
+ bindMethod("touchCancel", &EventSender::touchCancel);
+ bindMethod("touchEnd", &EventSender::touchEnd);
+ bindMethod("touchMove", &EventSender::touchMove);
+ bindMethod("touchStart", &EventSender::touchStart);
// When set to true (the default value), we batch mouse move and mouse up
// events so we can simulate drag & drop.
@@ -315,16 +322,16 @@ void EventSender::reset()
clickCount = 0;
lastButtonType = WebMouseEvent::ButtonNone;
timeOffsetMs = 0;
+ touchModifiers = 0;
+ touchPoints.clear();
}
WebView* EventSender::webview()
{
- return testShell->webView();
+ return m_shell->webView();
}
-void EventSender::doDragDrop(const WebKit::WebPoint& eventPos,
- const WebDragData& dragData,
- WebDragOperationsMask mask)
+void EventSender::doDragDrop(const WebDragData& dragData, WebDragOperationsMask mask)
{
WebMouseEvent event;
initMouseEvent(WebInputEvent::MouseDown, pressedButton, lastMousePos, &event);
@@ -610,11 +617,11 @@ void EventSender::keyDown(const CppArgumentList& arguments, CppVariant* result)
// We just simulate the same behavior here.
string editCommand;
if (getEditCommand(eventDown, &editCommand))
- testShell->webViewHost()->setEditCommand(editCommand, "");
+ m_shell->webViewHost()->setEditCommand(editCommand, "");
webview()->handleInputEvent(eventDown);
- testShell->webViewHost()->clearEditCommand();
+ m_shell->webViewHost()->clearEditCommand();
if (generateChar) {
eventChar.type = WebInputEvent::Char;
@@ -787,6 +794,124 @@ void EventSender::beginDragWithFiles(const CppArgumentList& arguments, CppVarian
result->setNull();
}
+void EventSender::addTouchPoint(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+
+ WebTouchPoint touchPoint;
+ touchPoint.state = WebTouchPoint::StatePressed;
+ touchPoint.position = WebPoint(arguments[0].toInt32(), arguments[1].toInt32());
+ touchPoint.id = touchPoints.size();
+ touchPoints.append(touchPoint);
+}
+
+void EventSender::clearTouchPoints(const CppArgumentList&, CppVariant* result)
+{
+ result->setNull();
+ touchPoints.clear();
+}
+
+void EventSender::releaseTouchPoint(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+
+ const unsigned index = arguments[0].toInt32();
+ ASSERT(index < touchPoints.size());
+
+ WebTouchPoint* touchPoint = &touchPoints[index];
+ touchPoint->state = WebTouchPoint::StateReleased;
+}
+
+void EventSender::setTouchModifier(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+
+ int mask = 0;
+ const string keyName = arguments[0].toString();
+ if (keyName == "shift")
+ mask = WebInputEvent::ShiftKey;
+ else if (keyName == "alt")
+ mask = WebInputEvent::AltKey;
+ else if (keyName == "ctrl")
+ mask = WebInputEvent::ControlKey;
+ else if (keyName == "meta")
+ mask = WebInputEvent::MetaKey;
+
+ if (arguments[1].toBoolean())
+ touchModifiers |= mask;
+ else
+ touchModifiers &= ~mask;
+}
+
+void EventSender::updateTouchPoint(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+
+ const unsigned index = arguments[0].toInt32();
+ ASSERT(index < touchPoints.size());
+
+ WebPoint position(arguments[1].toInt32(), arguments[2].toInt32());
+ WebTouchPoint* touchPoint = &touchPoints[index];
+ touchPoint->state = WebTouchPoint::StateMoved;
+ touchPoint->position = position;
+}
+
+void EventSender::cancelTouchPoint(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+
+ const unsigned index = arguments[0].toInt32();
+ ASSERT(index < touchPoints.size());
+
+ WebTouchPoint* touchPoint = &touchPoints[index];
+ touchPoint->state = WebTouchPoint::StateCancelled;
+}
+
+void EventSender::sendCurrentTouchEvent(const WebInputEvent::Type type)
+{
+ ASSERT(static_cast<unsigned>(WebTouchEvent::touchPointsLengthCap) > touchPoints.size());
+ WebTouchEvent touchEvent;
+ touchEvent.type = type;
+ touchEvent.modifiers = touchModifiers;
+ touchEvent.touchPointsLength = touchPoints.size();
+ for (unsigned i = 0; i < touchPoints.size(); ++i)
+ touchEvent.touchPoints[i] = touchPoints[i];
+ webview()->handleInputEvent(touchEvent);
+
+ for (unsigned i = 0; i < touchPoints.size(); ++i) {
+ WebTouchPoint* touchPoint = &touchPoints[i];
+ if (touchPoint->state == WebTouchPoint::StateReleased) {
+ touchPoints.remove(i);
+ --i;
+ } else
+ touchPoint->state = WebTouchPoint::StateStationary;
+ }
+}
+
+void EventSender::touchEnd(const CppArgumentList&, CppVariant* result)
+{
+ result->setNull();
+ sendCurrentTouchEvent(WebInputEvent::TouchEnd);
+}
+
+void EventSender::touchMove(const CppArgumentList&, CppVariant* result)
+{
+ result->setNull();
+ sendCurrentTouchEvent(WebInputEvent::TouchMove);
+}
+
+void EventSender::touchStart(const CppArgumentList&, CppVariant* result)
+{
+ result->setNull();
+ sendCurrentTouchEvent(WebInputEvent::TouchStart);
+}
+
+void EventSender::touchCancel(const CppArgumentList&, CppVariant* result)
+{
+ result->setNull();
+ sendCurrentTouchEvent(WebInputEvent::TouchCancel);
+}
+
//
// Unimplemented stubs
//
diff --git a/WebKitTools/DumpRenderTree/chromium/EventSender.h b/WebKitTools/DumpRenderTree/chromium/EventSender.h
index 756b008..ac475a3 100644
--- a/WebKitTools/DumpRenderTree/chromium/EventSender.h
+++ b/WebKitTools/DumpRenderTree/chromium/EventSender.h
@@ -60,9 +60,7 @@ public:
void reset();
// Simulate drag&drop system call.
- static void doDragDrop(const WebKit::WebPoint&,
- const WebKit::WebDragData&,
- WebKit::WebDragOperationsMask);
+ void doDragDrop(const WebKit::WebDragData&, WebKit::WebDragOperationsMask);
// JS callback methods.
void mouseDown(const CppArgumentList&, CppVariant*);
@@ -80,6 +78,17 @@ public:
void beginDragWithFiles(const CppArgumentList&, CppVariant*);
CppVariant dragMode;
+ void addTouchPoint(const CppArgumentList&, CppVariant*);
+ void cancelTouchPoint(const CppArgumentList&, CppVariant*);
+ void clearTouchPoints(const CppArgumentList&, CppVariant*);
+ void releaseTouchPoint(const CppArgumentList&, CppVariant*);
+ void setTouchModifier(const CppArgumentList&, CppVariant*);
+ void touchCancel(const CppArgumentList&, CppVariant*);
+ void touchEnd(const CppArgumentList&, CppVariant*);
+ void touchMove(const CppArgumentList&, CppVariant*);
+ void touchStart(const CppArgumentList&, CppVariant*);
+ void updateTouchPoint(const CppArgumentList&, CppVariant*);
+
// Unimplemented stubs
void contextClick(const CppArgumentList&, CppVariant*);
void enableDOMUIEventLogging(const CppArgumentList&, CppVariant*);
@@ -100,17 +109,17 @@ public:
private:
// Returns the test shell's webview.
- static WebKit::WebView* webview();
+ WebKit::WebView* webview();
// Returns true if dragMode is true.
bool isDragMode() { return dragMode.isBool() && dragMode.toBoolean(); }
// Sometimes we queue up mouse move and mouse up events for drag drop
// handling purposes. These methods dispatch the event.
- static void doMouseMove(const WebKit::WebMouseEvent&);
- static void doMouseUp(const WebKit::WebMouseEvent&);
+ void doMouseMove(const WebKit::WebMouseEvent&);
+ void doMouseUp(const WebKit::WebMouseEvent&);
static void doLeapForward(int milliseconds);
- static void replaySavedEvents();
+ void replaySavedEvents();
// Helper to return the button type given a button code
static WebKit::WebMouseEvent::Button getButtonTypeFromButtonNumber(int);
@@ -125,10 +134,13 @@ private:
void updateClickCountForButton(WebKit::WebMouseEvent::Button);
+ // Compose a touch event from the current touch points and send it.
+ void sendCurrentTouchEvent(const WebKit::WebInputEvent::Type);
+
ScopedRunnableMethodFactory<EventSender> m_methodFactory;
// Non-owning pointer. The EventSender is owned by the TestShell.
- static TestShell* testShell;
+ TestShell* m_shell;
// Location of last mouseMoveTo event.
static WebKit::WebPoint lastMousePos;
diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
index 21b168c..4413ff2 100644
--- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
@@ -41,6 +41,7 @@
#include "public/WebFrame.h"
#include "public/WebInputElement.h"
#include "public/WebKit.h"
+#include "public/WebNotificationPresenter.h"
#include "public/WebScriptSource.h"
#include "public/WebSecurityPolicy.h"
#include "public/WebSettings.h"
@@ -48,11 +49,13 @@
#include "public/WebURL.h"
#include "public/WebView.h"
#include "webkit/support/webkit_support.h"
+#include <wtf/text/WTFString.h>
#if OS(WINDOWS)
#include <wtf/OwnArrayPtr.h>
#endif
+using namespace WebCore;
using namespace WebKit;
using namespace std;
@@ -90,10 +93,12 @@ LayoutTestController::LayoutTestController(TestShell* shell)
bindMethod("setCloseRemainingWindowsWhenComplete", &LayoutTestController::setCloseRemainingWindowsWhenComplete);
bindMethod("objCIdentityIsEqual", &LayoutTestController::objCIdentityIsEqual);
bindMethod("setAlwaysAcceptCookies", &LayoutTestController::setAlwaysAcceptCookies);
+ bindMethod("showWebInspector", &LayoutTestController::showWebInspector);
bindMethod("setWindowIsKey", &LayoutTestController::setWindowIsKey);
bindMethod("setTabKeyCyclesThroughElements", &LayoutTestController::setTabKeyCyclesThroughElements);
bindMethod("setUserStyleSheetLocation", &LayoutTestController::setUserStyleSheetLocation);
bindMethod("setUserStyleSheetEnabled", &LayoutTestController::setUserStyleSheetEnabled);
+ bindMethod("setAuthorAndUserStylesEnabled", &LayoutTestController::setAuthorAndUserStylesEnabled);
bindMethod("pathToLocalResource", &LayoutTestController::pathToLocalResource);
bindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag);
bindMethod("execCommand", &LayoutTestController::execCommand);
@@ -109,18 +114,23 @@ LayoutTestController::LayoutTestController(TestShell* shell)
bindMethod("disableImageLoading", &LayoutTestController::disableImageLoading);
bindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEnabled);
bindMethod("setCustomPolicyDelegate", &LayoutTestController::setCustomPolicyDelegate);
+ bindMethod("setScrollbarPolicy", &LayoutTestController::setScrollbarPolicy);
bindMethod("waitForPolicyDelegate", &LayoutTestController::waitForPolicyDelegate);
+ bindMethod("setWillSendRequestClearHeader", &LayoutTestController::setWillSendRequestClearHeader);
bindMethod("setWillSendRequestReturnsNullOnRedirect", &LayoutTestController::setWillSendRequestReturnsNullOnRedirect);
bindMethod("setWillSendRequestReturnsNull", &LayoutTestController::setWillSendRequestReturnsNull);
bindMethod("addOriginAccessWhitelistEntry", &LayoutTestController::addOriginAccessWhitelistEntry);
+ bindMethod("removeOriginAccessWhitelistEntry", &LayoutTestController::removeOriginAccessWhitelistEntry);
bindMethod("clearAllDatabases", &LayoutTestController::clearAllDatabases);
bindMethod("setDatabaseQuota", &LayoutTestController::setDatabaseQuota);
bindMethod("setPOSIXLocale", &LayoutTestController::setPOSIXLocale);
bindMethod("counterValueForElementById", &LayoutTestController::counterValueForElementById);
bindMethod("addUserScript", &LayoutTestController::addUserScript);
+ bindMethod("addUserStyleSheet", &LayoutTestController::addUserStyleSheet);
bindMethod("pageNumberForElementById", &LayoutTestController::pageNumberForElementById);
bindMethod("numberOfPages", &LayoutTestController::numberOfPages);
bindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect);
+ bindMethod("grantDesktopNotificationPermission", &LayoutTestController::grantDesktopNotificationPermission);
// The following are stubs.
bindMethod("dumpAsWebArchive", &LayoutTestController::dumpAsWebArchive);
@@ -135,6 +145,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
bindMethod("accessStoredWebScriptObject", &LayoutTestController::accessStoredWebScriptObject);
bindMethod("objCClassNameOf", &LayoutTestController::objCClassNameOf);
bindMethod("addDisallowedURL", &LayoutTestController::addDisallowedURL);
+ bindMethod("callShouldCloseOnWebView", &LayoutTestController::callShouldCloseOnWebView);
bindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebViews);
bindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrowsingEnabled);
bindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDashboardCompatibilityMode);
@@ -440,11 +451,11 @@ void LayoutTestController::reset()
if (m_shell) {
m_shell->webView()->setZoomLevel(false, 0);
m_shell->webView()->setTabKeyCyclesThroughElements(true);
-#if defined(OS_LINUX)
+#if !OS(DARWIN) && !OS(WINDOWS) // Actually, TOOLKIT_GTK
// (Constants copied because we can't depend on the header that defined
// them from this file.)
m_shell->webView()->setSelectionColors(0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232);
-#endif // defined(OS_LINUX)
+#endif
m_shell->webView()->removeAllUserContent();
}
m_dumpAsText = false;
@@ -468,7 +479,7 @@ void LayoutTestController::reset()
m_webHistoryItemCount.set(0);
webkit_support::SetAcceptAllCookies(false);
- WebSecurityPolicy::resetOriginAccessWhiteLists();
+ WebSecurityPolicy::resetOriginAccessWhitelists();
// Reset the default quota for each origin to 5MB
webkit_support::SetDatabaseQuota(5 * 1024 * 1024);
@@ -532,6 +543,12 @@ void LayoutTestController::setAlwaysAcceptCookies(const CppArgumentList& argumen
result->setNull();
}
+void LayoutTestController::showWebInspector(const CppArgumentList&, CppVariant* result)
+{
+ m_shell->showDevTools();
+ result->setNull();
+}
+
void LayoutTestController::setWindowIsKey(const CppArgumentList& arguments, CppVariant* result)
{
if (arguments.size() > 0 && arguments[0].isBool())
@@ -555,6 +572,13 @@ void LayoutTestController::setUserStyleSheetLocation(const CppArgumentList& argu
result->setNull();
}
+void LayoutTestController::setAuthorAndUserStylesEnabled(const CppArgumentList& arguments, CppVariant* result)
+{
+ if (arguments.size() > 0 && arguments[0].isBool())
+ m_shell->webView()->settings()->setAuthorAndUserStylesEnabled(arguments[0].value.boolValue);
+ result->setNull();
+}
+
void LayoutTestController::execCommand(const CppArgumentList& arguments, CppVariant* result)
{
result->setNull();
@@ -599,6 +623,13 @@ void LayoutTestController::setUseDashboardCompatibilityMode(const CppArgumentLis
result->setNull();
}
+void LayoutTestController::setScrollbarPolicy(const CppArgumentList&, CppVariant* result)
+{
+ // FIXME: implement.
+ // Currently only has a non-null implementation on QT.
+ result->setNull();
+}
+
void LayoutTestController::setCustomPolicyDelegate(const CppArgumentList& arguments, CppVariant* result)
{
if (arguments.size() > 0 && arguments[0].isBool()) {
@@ -618,6 +649,16 @@ void LayoutTestController::waitForPolicyDelegate(const CppArgumentList&, CppVari
result->setNull();
}
+void LayoutTestController::setWillSendRequestClearHeader(const CppArgumentList& arguments, CppVariant* result)
+{
+ if (arguments.size() > 0 && arguments[0].isString()) {
+ string header = arguments[0].toString();
+ if (!header.empty())
+ m_shell->webViewHost()->addClearHeader(String::fromUTF8(header.c_str()));
+ }
+ result->setNull();
+}
+
void LayoutTestController::setWillSendRequestReturnsNullOnRedirect(const CppArgumentList& arguments, CppVariant* result)
{
if (arguments.size() > 0 && arguments[0].isBool())
@@ -734,7 +775,7 @@ bool LayoutTestController::elementDoesAutoCompleteForElementWithId(const WebStri
if (element.isNull() || !element.hasTagName("input"))
return false;
- WebInputElement inputElement = element.toElement<WebInputElement>();
+ WebInputElement inputElement = element.to<WebInputElement>();
return inputElement.autoComplete();
}
@@ -800,6 +841,21 @@ void LayoutTestController::setIconDatabaseEnabled(const CppArgumentList&, CppVar
result->setNull();
}
+void LayoutTestController::callShouldCloseOnWebView(const CppArgumentList&, CppVariant* result)
+{
+ result->set(m_shell->webView()->dispatchBeforeUnloadEvent());
+}
+
+void LayoutTestController::grantDesktopNotificationPermission(const CppArgumentList& arguments, CppVariant* result)
+{
+ if (arguments.size() != 1 || !arguments[0].isString()) {
+ result->set(false);
+ return;
+ }
+ m_shell->notificationPresenter()->grantPermission(WebString::fromUTF8(arguments[0].toString()));
+ result->set(true);
+}
+
//
// Unimplemented stubs
//
@@ -1052,10 +1108,30 @@ void LayoutTestController::addOriginAccessWhitelistEntry(const CppArgumentList&
if (!url.isValid())
return;
- WebSecurityPolicy::whiteListAccessFromOrigin(url,
- WebString::fromUTF8(arguments[1].toString()),
- WebString::fromUTF8(arguments[2].toString()),
- arguments[3].toBoolean());
+ WebSecurityPolicy::addOriginAccessWhitelistEntry(
+ url,
+ WebString::fromUTF8(arguments[1].toString()),
+ WebString::fromUTF8(arguments[2].toString()),
+ arguments[3].toBoolean());
+}
+
+void LayoutTestController::removeOriginAccessWhitelistEntry(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+
+ if (arguments.size() != 4 || !arguments[0].isString() || !arguments[1].isString()
+ || !arguments[2].isString() || !arguments[3].isBool())
+ return;
+
+ WebKit::WebURL url(GURL(arguments[0].toString()));
+ if (!url.isValid())
+ return;
+
+ WebSecurityPolicy::removeOriginAccessWhitelistEntry(
+ url,
+ WebString::fromUTF8(arguments[1].toString()),
+ WebString::fromUTF8(arguments[2].toString()),
+ arguments[3].toBoolean());
}
void LayoutTestController::clearAllDatabases(const CppArgumentList& arguments, CppVariant* result)
@@ -1183,7 +1259,15 @@ void LayoutTestController::forceRedSelectionColors(const CppArgumentList& argume
void LayoutTestController::addUserScript(const CppArgumentList& arguments, CppVariant* result)
{
result->setNull();
- if (arguments.size() < 1 || !arguments[0].isString() || !arguments[1].isBool())
+ if (arguments.size() < 2 || !arguments[0].isString() || !arguments[1].isBool())
return;
m_shell->webView()->addUserScript(WebString::fromUTF8(arguments[0].toString()), arguments[1].toBoolean());
}
+
+void LayoutTestController::addUserStyleSheet(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+ if (arguments.size() < 1 || !arguments[0].isString())
+ return;
+ m_shell->webView()->addUserStyleSheet(WebString::fromUTF8(arguments[0].toString()));
+}
diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h
index ca8b014..e7a48e2 100644
--- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h
+++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h
@@ -127,6 +127,9 @@ public:
// Changes the cookie policy from the default to allow all cookies.
void setAlwaysAcceptCookies(const CppArgumentList&, CppVariant*);
+ // Shows DevTools window.
+ void showWebInspector(const CppArgumentList&, CppVariant*);
+
// Gives focus to the window.
void setWindowIsKey(const CppArgumentList&, CppVariant*);
@@ -139,11 +142,16 @@ public:
void setUserStyleSheetEnabled(const CppArgumentList&, CppVariant*);
void setUserStyleSheetLocation(const CppArgumentList&, CppVariant*);
+ // Passes this preference through to WebSettings.
+ void setAuthorAndUserStylesEnabled(const CppArgumentList&, CppVariant*);
+
// Puts Webkit in "dashboard compatibility mode", which is used in obscure
// Mac-only circumstances. It's not really necessary, and will most likely
// never be used by Chrome, but some layout tests depend on its presence.
void setUseDashboardCompatibilityMode(const CppArgumentList&, CppVariant*);
+ void setScrollbarPolicy(const CppArgumentList&, CppVariant*);
+
// Causes navigation actions just printout the intended navigation instead
// of taking you to the page. This is used for cases like mailto, where you
// don't actually want to open the mail program.
@@ -152,6 +160,9 @@ public:
// Delays completion of the test until the policy delegate runs.
void waitForPolicyDelegate(const CppArgumentList&, CppVariant*);
+ // Causes WillSendRequest to clear certain headers.
+ void setWillSendRequestClearHeader(const CppArgumentList&, CppVariant*);
+
// Causes WillSendRequest to block redirects.
void setWillSendRequestReturnsNullOnRedirect(const CppArgumentList&, CppVariant*);
@@ -195,6 +206,9 @@ public:
void dumpSelectionRect(const CppArgumentList&, CppVariant*);
+ // Grants permission for desktop notifications to an origin
+ void grantDesktopNotificationPermission(const CppArgumentList&, CppVariant*);
+
// The following are only stubs. TODO(pamg): Implement any of these that
// are needed to pass the layout tests.
void dumpAsWebArchive(const CppArgumentList&, CppVariant*);
@@ -210,6 +224,7 @@ public:
void accessStoredWebScriptObject(const CppArgumentList&, CppVariant*);
void objCClassNameOf(const CppArgumentList&, CppVariant*);
void addDisallowedURL(const CppArgumentList&, CppVariant*);
+ void callShouldCloseOnWebView(const CppArgumentList&, CppVariant*);
void setCallCloseOnWebViews(const CppArgumentList&, CppVariant*);
void setPrivateBrowsingEnabled(const CppArgumentList&, CppVariant*);
@@ -228,8 +243,9 @@ public:
// that case (as the Mac does).
void fallbackMethod(const CppArgumentList&, CppVariant*);
- // Allows layout tests to call SecurityOrigin::addOriginAccessWhitelistEntry().
+ // Allows layout tests to manage origins' whitelisting.
void addOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*);
+ void removeOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*);
// Clears all databases.
void clearAllDatabases(const CppArgumentList&, CppVariant*);
@@ -259,8 +275,9 @@ public:
// Forces the selection colors for testing under Linux.
void forceRedSelectionColors(const CppArgumentList&, CppVariant*);
- // Adds a user script to be injected into new documents.
+ // Adds a user script or user style sheet to be injected into new documents.
void addUserScript(const CppArgumentList&, CppVariant*);
+ void addUserStyleSheet(const CppArgumentList&, CppVariant*);
public:
// The following methods are not exposed to JavaScript.
diff --git a/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp b/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp
new file mode 100644
index 0000000..86903be
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NotificationPresenter.h"
+
+#include "googleurl/src/gurl.h"
+#include "public/WebNotification.h"
+#include "public/WebNotificationPermissionCallback.h"
+#include "public/WebSecurityOrigin.h"
+#include "public/WebString.h"
+#include "public/WebURL.h"
+#include <wtf/text/CString.h>
+
+using namespace WebCore;
+using namespace WebKit;
+
+void NotificationPresenter::grantPermission(const WebString& origin)
+{
+ // Make sure it's in the form of an origin.
+ GURL url(origin);
+ m_allowedOrigins.add(String(url.GetOrigin().spec().c_str()));
+}
+
+// The output from all these methods matches what DumpRenderTree produces.
+bool NotificationPresenter::show(const WebNotification& notification)
+{
+ if (!notification.replaceId().isEmpty()) {
+ String replaceId(notification.replaceId().data(), notification.replaceId().length());
+ if (m_replacements.find(replaceId) != m_replacements.end())
+ printf("REPLACING NOTIFICATION %s\n",
+ m_replacements.find(replaceId)->second.utf8().data());
+
+ WebString identifier = notification.isHTML() ?
+ notification.url().spec().utf16() : notification.title();
+ m_replacements.set(replaceId, String(identifier.data(), identifier.length()));
+ }
+
+ if (notification.isHTML()) {
+ printf("DESKTOP NOTIFICATION: contents at %s\n",
+ notification.url().spec().data());
+ } else {
+ printf("DESKTOP NOTIFICATION:%s icon %s, title %s, text %s\n",
+ notification.dir() == "rtl" ? "(RTL)" : "",
+ notification.iconURL().isEmpty() ? "" :
+ notification.iconURL().spec().data(),
+ notification.title().isEmpty() ? "" :
+ notification.title().utf8().data(),
+ notification.body().isEmpty() ? "" :
+ notification.body().utf8().data());
+ }
+
+ WebNotification eventTarget(notification);
+ eventTarget.dispatchDisplayEvent();
+ return true;
+}
+
+void NotificationPresenter::cancel(const WebNotification& notification)
+{
+ WebString identifier;
+ if (notification.isHTML())
+ identifier = notification.url().spec().utf16();
+ else
+ identifier = notification.title();
+
+ printf("DESKTOP NOTIFICATION CLOSED: %s\n", identifier.utf8().data());
+ WebNotification eventTarget(notification);
+ eventTarget.dispatchCloseEvent(false);
+}
+
+void NotificationPresenter::objectDestroyed(const WebKit::WebNotification& notification)
+{
+ // Nothing to do. Not storing the objects.
+}
+
+WebNotificationPresenter::Permission NotificationPresenter::checkPermission(const WebURL& url)
+{
+ // Check with the layout test controller
+ String origin = String(static_cast<GURL>(url).GetOrigin().spec().c_str());
+ bool allowed = m_allowedOrigins.find(origin) != m_allowedOrigins.end();
+ return allowed ? WebNotificationPresenter::PermissionAllowed
+ : WebNotificationPresenter::PermissionDenied;
+}
+
+void NotificationPresenter::requestPermission(
+ const WebSecurityOrigin& origin,
+ WebNotificationPermissionCallback* callback)
+{
+ printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %s\n",
+ origin.toString().utf8().data());
+ callback->permissionRequestComplete();
+}
diff --git a/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.h b/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.h
new file mode 100644
index 0000000..f30862f
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NotificationPresenter_h
+#define NotificationPresenter_h
+
+#include "public/WebNotificationPresenter.h"
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+class TestShell;
+
+// A class that implements WebNotificationPresenter for DRT.
+class NotificationPresenter : public WebKit::WebNotificationPresenter {
+public:
+ explicit NotificationPresenter(TestShell* shell) : m_shell(shell) {}
+
+ // Called by the LayoutTestController to simulate a user granting permission.
+ void grantPermission(const WebKit::WebString& origin);
+
+ // WebKit::WebNotificationPresenter interface
+ virtual bool show(const WebKit::WebNotification&);
+ virtual void cancel(const WebKit::WebNotification&);
+ virtual void objectDestroyed(const WebKit::WebNotification&);
+ virtual Permission checkPermission(const WebKit::WebURL&);
+ virtual void requestPermission(const WebKit::WebSecurityOrigin&, WebKit::WebNotificationPermissionCallback*);
+
+ void reset() { m_allowedOrigins.clear(); }
+
+private:
+ // Non-owned pointer. The NotificationPresenter is owned by the test shell.
+ TestShell* m_shell;
+
+ // Set of allowed origins.
+ HashSet<WebCore::String> m_allowedOrigins;
+
+ // Map of active replacement IDs to the titles of those notifications
+ HashMap<WebCore::String, WebCore::String> m_replacements;
+};
+
+#endif // NotificationPresenter_h
diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp
index e4229fe..24a895a 100644
--- a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp
@@ -85,6 +85,7 @@ TestShell::TestShell()
m_eventSender.set(new EventSender(this));
m_plainTextController.set(new PlainTextController());
m_textInputController.set(new TextInputController(this));
+ m_notificationPresenter.set(new NotificationPresenter(this));
m_webViewHost = createWebView();
m_webView = m_webViewHost->webView();
@@ -131,6 +132,7 @@ void TestShell::resetWebSettings(WebView& webView)
settings->setSerifFontFamily(serif);
settings->setStandardFontFamily(serif);
settings->setFixedFontFamily(WebString::fromUTF8("Courier"));
+ settings->setSansSerifFontFamily(WebString::fromUTF8("Helvetica"));
settings->setDefaultTextEncodingName(WebString::fromUTF8("ISO-8859-1"));
settings->setDefaultFontSize(16);
@@ -175,6 +177,7 @@ void TestShell::resetWebSettings(WebView& webView)
void TestShell::runFileTest(const TestParams& params)
{
+ ASSERT(params.testUrl.isValid());
m_testIsPreparing = true;
m_params = params;
string testUrl = m_params.testUrl.spec();
@@ -212,6 +215,7 @@ void TestShell::resetTestController()
m_layoutTestController->reset();
m_eventSender->reset();
m_webViewHost->reset();
+ m_notificationPresenter->reset();
}
void TestShell::loadURL(const WebURL& url)
diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.h b/WebKitTools/DumpRenderTree/chromium/TestShell.h
index c6a5b2e..283cbd4 100644
--- a/WebKitTools/DumpRenderTree/chromium/TestShell.h
+++ b/WebKitTools/DumpRenderTree/chromium/TestShell.h
@@ -31,6 +31,7 @@
#include "AccessibilityController.h"
#include "EventSender.h"
#include "LayoutTestController.h"
+#include "NotificationPresenter.h"
#include "PlainTextController.h"
#include "TextInputController.h"
#include "WebViewHost.h"
@@ -43,6 +44,7 @@
namespace WebKit {
class WebFrame;
+class WebNotificationPresenter;
class WebPreferences;
class WebView;
class WebURL;
@@ -74,7 +76,9 @@ public:
// Returns the host for the main WebView.
WebViewHost* webViewHost() const { return m_webViewHost; }
LayoutTestController* layoutTestController() const { return m_layoutTestController.get(); }
+ EventSender* eventSender() const { return m_eventSender.get(); }
AccessibilityController* accessibilityController() const { return m_accessibilityController.get(); }
+ NotificationPresenter* notificationPresenter() const { return m_notificationPresenter.get(); }
void bindJSObjectsToWindow(WebKit::WebFrame*);
void runFileTest(const TestParams&);
@@ -115,6 +119,7 @@ public:
void closeRemainingWindows();
int windowCount();
static void resizeWindowForTest(WebViewHost*, const WebKit::WebURL&);
+ void showDevTools() {} // FIXME: imeplement this.
static const int virtualWindowBorder = 3;
@@ -135,6 +140,7 @@ private:
OwnPtr<LayoutTestController*> m_layoutTestController;
OwnPtr<PlainTextController*> m_plainTextController;
OwnPtr<TextInputController*> m_textInputController;
+ OwnPtr<NotificationPresenter*> m_notificationPresenter;
TestParams m_params;
// List of all windows in this process.
diff --git a/WebKitTools/DumpRenderTree/chromium/TestWebWorker.h b/WebKitTools/DumpRenderTree/chromium/TestWebWorker.h
index f28cc20..9470804 100644
--- a/WebKitTools/DumpRenderTree/chromium/TestWebWorker.h
+++ b/WebKitTools/DumpRenderTree/chromium/TestWebWorker.h
@@ -80,6 +80,7 @@ public:
virtual WebKit::WebWorker* createWorker(WebKit::WebWorkerClient*) { return 0; }
virtual WebKit::WebNotificationPresenter* notificationPresenter() { return 0; }
virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(WebKit::WebApplicationCacheHostClient*) { return 0; }
+ virtual bool allowDatabase(WebKit::WebFrame*, const WebKit::WebString&, const WebKit::WebString&, unsigned long) { return true; }
private:
~TestWebWorker() {}
diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp
index 6ea1de1..4761b1a 100644
--- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp
@@ -52,10 +52,12 @@
#include "public/WebURLRequest.h"
#include "public/WebURLResponse.h"
#include "public/WebView.h"
+#include "public/WebWindowFeatures.h"
#include "skia/ext/platform_canvas.h"
#include "webkit/support/webkit_support.h"
#include <wtf/Assertions.h>
+using namespace WebCore;
using namespace WebKit;
using namespace skia;
using namespace std;
@@ -250,14 +252,19 @@ static string textAffinityDescription(WebTextAffinity affinity)
// WebViewClient -------------------------------------------------------------
-WebView* WebViewHost::createView(WebFrame*)
+WebView* WebViewHost::createView(WebFrame* creator)
+{
+ return createView(creator, WebWindowFeatures());
+}
+
+WebView* WebViewHost::createView(WebFrame*, const WebWindowFeatures&)
{
if (!layoutTestController()->canOpenWindows())
return 0;
return m_shell->createWebView()->webView();
}
-WebWidget* WebViewHost::createPopupMenu(bool)
+WebWidget* WebViewHost::createPopupMenu(WebPopupType)
{
return 0;
}
@@ -267,9 +274,9 @@ WebWidget* WebViewHost::createPopupMenu(const WebPopupMenuInfo&)
return 0;
}
-WebStorageNamespace* WebViewHost::createSessionStorageNamespace()
+WebStorageNamespace* WebViewHost::createSessionStorageNamespace(unsigned quota)
{
- return WebKit::WebStorageNamespace::createSessionStorageNamespace();
+ return WebKit::WebStorageNamespace::createSessionStorageNamespace(quota);
}
void WebViewHost::didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine)
@@ -481,7 +488,7 @@ void WebViewHost::setStatusText(const WebString& text)
printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", text.utf8().data());
}
-void WebViewHost::startDragging(const WebPoint& mouseCoords, const WebDragData& data, WebDragOperationsMask mask)
+void WebViewHost::startDragging(const WebDragData& data, WebDragOperationsMask mask, const WebImage&, const WebPoint&)
{
WebDragData mutableDragData = data;
if (layoutTestController()->shouldAddFileToPasteboard()) {
@@ -491,7 +498,7 @@ void WebViewHost::startDragging(const WebPoint& mouseCoords, const WebDragData&
// When running a test, we need to fake a drag drop operation otherwise
// Windows waits for real mouse events to know when the drag is over.
- EventSender::doDragDrop(mouseCoords, mutableDragData, mask);
+ m_shell->eventSender()->doDragDrop(mutableDragData, mask);
}
void WebViewHost::navigateBackForwardSoon(int offset)
@@ -515,6 +522,11 @@ void WebViewHost::focusAccessibilityObject(const WebAccessibilityObject& object)
m_shell->accessibilityController()->setFocusedElement(object);
}
+WebNotificationPresenter* WebViewHost::notificationPresenter()
+{
+ return m_shell->notificationPresenter();
+}
+
// WebWidgetClient -----------------------------------------------------------
void WebViewHost::didInvalidateRect(const WebRect& rect)
@@ -629,6 +641,11 @@ WebMediaPlayer* WebViewHost::createMediaPlayer(WebFrame* frame, WebMediaPlayerCl
return webkit_support::CreateMediaPlayer(frame, client);
}
+WebApplicationCacheHost* WebViewHost::createApplicationCacheHost(WebFrame* frame, WebApplicationCacheHostClient* client)
+{
+ return webkit_support::CreateApplicationCacheHost(frame, client);
+}
+
bool WebViewHost::allowPlugins(WebFrame* frame, bool enabledPerSettings)
{
return enabledPerSettings;
@@ -906,6 +923,10 @@ void WebViewHost::willSendRequest(WebFrame*, unsigned identifier, WebURLRequest&
return;
}
+ HashSet<String>::const_iterator end = m_clearHeaders.end();
+ for (HashSet<String>::const_iterator header = m_clearHeaders.begin(); header != end; ++header)
+ request.clearHTTPHeaderField(WebString(header->characters(), header->length()));
+
// Set the new substituted URL.
request.setURL(webkit_support::RewriteLayoutTestsURL(request.url().spec()));
}
@@ -1115,7 +1136,7 @@ void WebViewHost::updateAddressBar(WebView* webView)
if (!dataSource)
return;
- setAddressBarURL(dataSource->request().firstPartyForCookies());
+ setAddressBarURL(dataSource->request().url());
}
void WebViewHost::locationChangeDone(WebFrame* frame)
@@ -1168,6 +1189,7 @@ void WebViewHost::updateURL(WebFrame* frame)
entry->setContentState(historyItem);
navigationController()->didNavigateToEntry(entry.release());
+ updateAddressBar(frame->view());
m_lastPageIdUpdated = max(m_lastPageIdUpdated, m_pageId);
}
diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h
index c5bed7a..5227b28 100644
--- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h
+++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h
@@ -37,15 +37,18 @@
#include "public/WebFrameClient.h"
#include "public/WebViewClient.h"
#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
class LayoutTestController;
class TestShell;
namespace WebKit {
class WebFrame;
class WebURL;
-struct WebURLError;
struct WebRect;
+struct WebURLError;
+struct WebWindowFeatures;
}
namespace skia {
class PlatformCanvas;
@@ -79,14 +82,18 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
void loadURLForFrame(const WebKit::WebURL&, const WebKit::WebString& frameName);
TestNavigationController* navigationController() { return m_navigationController.get(); }
+ void addClearHeader(const WebCore::String& header) { m_clearHeaders.add(header); }
+ const HashSet<WebCore::String>& clearHeaders() const { return m_clearHeaders; }
+
// NavigationHost
virtual bool navigate(const TestNavigationEntry&, bool reload);
// WebKit::WebViewClient
virtual WebKit::WebView* createView(WebKit::WebFrame*);
- virtual WebKit::WebWidget* createPopupMenu(bool activatable);
+ virtual WebKit::WebView* createView(WebKit::WebFrame*, const WebKit::WebWindowFeatures&);
+ virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType);
virtual WebKit::WebWidget* createPopupMenu(const WebKit::WebPopupMenuInfo&);
- virtual WebKit::WebStorageNamespace* createSessionStorageNamespace();
+ virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(unsigned quota);
virtual void didAddMessageToConsole(const WebKit::WebConsoleMessage&, const WebKit::WebString& sourceName, unsigned sourceLine);
virtual void didStartLoading();
virtual void didStopLoading();
@@ -112,11 +119,12 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame*, const WebKit::WebString&);
virtual void showContextMenu(WebKit::WebFrame*, const WebKit::WebContextMenuData&);
virtual void setStatusText(const WebKit::WebString&);
- virtual void startDragging(const WebKit::WebPoint&, const WebKit::WebDragData&, WebKit::WebDragOperationsMask);
+ virtual void startDragging(const WebKit::WebDragData&, WebKit::WebDragOperationsMask, const WebKit::WebImage&, const WebKit::WebPoint&);
virtual void navigateBackForwardSoon(int offset);
virtual int historyBackListCount();
virtual int historyForwardListCount();
virtual void focusAccessibilityObject(const WebKit::WebAccessibilityObject&);
+ virtual WebKit::WebNotificationPresenter* notificationPresenter();
// WebKit::WebWidgetClient
virtual void didInvalidateRect(const WebKit::WebRect&);
@@ -137,7 +145,8 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
virtual WebKit::WebPlugin* createPlugin(WebKit::WebFrame*, const WebKit::WebPluginParams&);
virtual WebKit::WebWorker* createWorker(WebKit::WebFrame*, WebKit::WebWorkerClient*);
virtual WebKit::WebMediaPlayer* createMediaPlayer(WebKit::WebFrame*, WebKit::WebMediaPlayerClient*);
- virtual bool allowPlugins(WebKit::WebFrame*, bool enabledPerSettings);
+ virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(WebKit::WebFrame*, WebKit::WebApplicationCacheHostClient*);
+ virtual bool allowPlugins(WebKit::WebFrame*, bool enabledPerSettings);
virtual bool allowImages(WebKit::WebFrame*, bool enabledPerSettings);
virtual void loadURLExternally(WebKit::WebFrame*, const WebKit::WebURLRequest&, WebKit::WebNavigationPolicy);
virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
@@ -248,6 +257,9 @@ private:
// true if we want to enable selection of trailing whitespaces
bool m_selectTrailingWhitespaceEnabled;
+ // Set of headers to clear in willSendRequest.
+ HashSet<WebCore::String> m_clearHeaders;
+
// true if we should block any redirects
bool m_blocksRedirects;
diff --git a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
index fabada3..3735d0a 100644
--- a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "AccessibilityUIElement.h"
+#include "GRefPtr.h"
#include <JavaScriptCore/JSStringRef.h>
#include <wtf/Assertions.h>
@@ -128,10 +129,22 @@ unsigned AccessibilityUIElement::indexOfChild(AccessibilityUIElement* element)
return 0;
}
+gchar* attributeSetToString(AtkAttributeSet* attributeSet)
+{
+ GString* str = g_string_new(0);
+ for (GSList* attributes = attributeSet; attributes; attributes = attributes->next) {
+ AtkAttribute* attribute = static_cast<AtkAttribute*>(attributes->data);
+ g_string_append(str, g_strconcat(attribute->name, ":", attribute->value, NULL));
+ if (attributes->next)
+ g_string_append(str, ", ");
+ }
+
+ return g_string_free(str, FALSE);
+}
+
JSStringRef AccessibilityUIElement::allAttributes()
{
- // FIXME: implement
- return JSStringCreateWithCharacters(0, 0);
+ return JSStringCreateWithUTF8CString(attributeSetToString(atk_object_get_attributes(ATK_OBJECT(m_element))));
}
JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements()
@@ -364,8 +377,13 @@ bool AccessibilityUIElement::isRequired() const
bool AccessibilityUIElement::isSelected() const
{
- // FIXME: implement
- return false;
+ if (!ATK_IS_OBJECT(m_element))
+ return false;
+
+ GRefPtr<AtkStateSet> stateSet = adoptGRef(atk_object_ref_state_set(ATK_OBJECT(m_element)));
+ gboolean isSelected = atk_state_set_contains_state(stateSet.get(), ATK_STATE_SELECTED);
+
+ return isSelected;
}
int AccessibilityUIElement::hierarchicalLevel() const
diff --git a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
index 0f3ca38..273bcdf 100644
--- a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
@@ -843,6 +843,19 @@ static WebKitWebView* webInspectorInspectWebView(WebKitWebInspector*, gpointer d
return WEBKIT_WEB_VIEW(webView);
}
+static void webViewLoadStatusNotified(WebKitWebView* view, gpointer user_data)
+{
+ WebKitLoadStatus loadStatus = webkit_web_view_get_load_status(view);
+
+ if (gLayoutTestController->dumpFrameLoadCallbacks()) {
+ if (loadStatus == WEBKIT_LOAD_PROVISIONAL) {
+ char* frameName = getFrameNameSuitableForTestResult(view, mainFrame);
+ printf("%s - didStartProvisionalLoadForFrame\n", frameName);
+ g_free(frameName);
+ }
+ }
+}
+
static WebKitWebView* createWebView()
{
WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new());
@@ -871,6 +884,10 @@ static WebKitWebView* createWebView()
"signal::onload-event", webViewOnloadEvent, 0,
NULL);
+ g_signal_connect(view,
+ "notify::load-status", G_CALLBACK(webViewLoadStatusNotified),
+ NULL);
+
WebKitWebInspector* inspector = webkit_web_view_get_inspector(view);
g_object_connect(G_OBJECT(inspector),
"signal::inspect-web-view", webInspectorInspectWebView, 0,
diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
index 25b9f4f..6572a8e 100644
--- a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
+++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
@@ -397,6 +397,9 @@ static void resetDefaultsToConsistentValues()
ThemeScrollBarArrowStyle style;
GetThemeScrollBarArrowStyle(&style); // Force HIToolbox to read from CFPreferences
#endif
+
+ [defaults setBool:NO forKey:@"AppleScrollAnimationEnabled"];
+
if (initialValue)
CFPreferencesSetValue(CFSTR("AppleScrollBarVariant"), initialValue.get(), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
diff --git a/WebKitTools/DumpRenderTree/mac/EventSendingController.mm b/WebKitTools/DumpRenderTree/mac/EventSendingController.mm
index 8c5cebf..b5b6f82 100644
--- a/WebKitTools/DumpRenderTree/mac/EventSendingController.mm
+++ b/WebKitTools/DumpRenderTree/mac/EventSendingController.mm
@@ -122,7 +122,7 @@ BOOL replayingSavedEvents;
{
if (aSelector == @selector(beginDragWithFiles:)
|| aSelector == @selector(clearKillRing)
- || aSelector == @selector(contextClick)
+ || aSelector == @selector(contextClick:)
|| aSelector == @selector(enableDOMUIEventLogging:)
|| aSelector == @selector(fireKeyboardEventsToElement:)
|| aSelector == @selector(keyDown:withModifiers:withLocation:)
@@ -152,6 +152,8 @@ BOOL replayingSavedEvents;
{
if (aSelector == @selector(beginDragWithFiles:))
return @"beginDragWithFiles";
+ if (aSelector == @selector(contextClick:))
+ return @"contextClick";
if (aSelector == @selector(enableDOMUIEventLogging:))
return @"enableDOMUIEventLogging";
if (aSelector == @selector(fireKeyboardEventsToElement:))
@@ -492,7 +494,7 @@ static int buildModifierFlags(const WebScriptObject* modifiers)
[self mouseScrollByX:x andY:y continuously:NO];
}
-- (void)contextClick
+- (void)contextClick:(BOOL)shouldPrintMenuItems
{
[[[mainFrame frameView] documentView] layout];
[self updateClickCountForButton:RightMouseButton];
@@ -508,8 +510,21 @@ static int buildModifierFlags(const WebScriptObject* modifiers)
pressure:0.0];
NSView *subView = [[mainFrame webView] hitTest:[event locationInWindow]];
- if (subView)
- [subView menuForEvent:event];
+ if (subView) {
+ NSMenu* menu = [subView menuForEvent:event];
+ if (shouldPrintMenuItems) {
+ printf("ContextMenuItems: ");
+ for (int i = 0; i < [menu numberOfItems]; ++i) {
+ NSMenuItem* menuItem = [menu itemAtIndex:i];
+ if (!strcmp("Inspect Element", [[menuItem title] UTF8String]))
+ continue;
+ if (i > 0)
+ printf(", ");
+ fputs([menuItem isSeparatorItem] ? "<separator>" : [[menuItem title] UTF8String], stdout);
+ }
+ printf("\n");
+ }
+ }
}
- (void)scheduleAsynchronousClick
diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
index 29a5812..44aea81 100644
--- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
@@ -66,6 +66,10 @@
#import <wtf/HashMap.h>
#import <wtf/RetainPtr.h>
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+#include <Foundation/NSPrivateDecls.h>
+#endif
+
@interface CommandValidationTarget : NSObject <NSValidatedUserInterfaceItem>
{
SEL _action;
@@ -758,7 +762,12 @@ void LayoutTestController::setWebViewEditable(bool editable)
#ifndef BUILDING_ON_TIGER
static NSString *SynchronousLoaderRunLoopMode = @"DumpRenderTreeSynchronousLoaderRunLoopMode";
-@interface SynchronousLoader : NSObject
+#if defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD) || !defined(__COCOA_FORMAL_PROTOCOLS_2__)
+@protocol NSURLConnectionDelegate <NSObject>
+@end
+#endif
+
+@interface SynchronousLoader : NSObject <NSURLConnectionDelegate>
{
NSString *m_username;
NSString *m_password;
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
index 9d2a065..f9caca6 100644
--- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
@@ -80,10 +80,6 @@
#include <qdebug.h>
-extern void qt_dump_set_accepts_editing(bool b);
-extern void qt_dump_frame_loader(bool b);
-extern void qt_dump_resource_load_callbacks(bool b);
-
namespace WebCore {
NetworkAccessManager::NetworkAccessManager(QObject* parent)
@@ -192,6 +188,7 @@ void WebPage::resetSettings()
settings()->resetAttribute(QWebSettings::LocalContentCanAccessRemoteUrls);
settings()->resetAttribute(QWebSettings::PluginsEnabled);
settings()->resetAttribute(QWebSettings::JavaScriptCanAccessClipboard);
+ settings()->resetAttribute(QWebSettings::AutoLoadImages);
m_drt->layoutTestController()->setCaretBrowsingEnabled(false);
m_drt->layoutTestController()->setFrameFlatteningEnabled(false);
@@ -343,14 +340,11 @@ DumpRenderTree::DumpRenderTree()
, m_stdin(0)
, m_enableTextOutput(false)
, m_singleFileMode(false)
+ , m_persistentStoragePath(QString(getenv("DUMPRENDERTREE_TEMP")))
{
DumpRenderTreeSupportQt::overwritePluginDirectories();
- char* dumpRenderTreeTemp = getenv("DUMPRENDERTREE_TEMP");
- if (dumpRenderTreeTemp)
- QWebSettings::enablePersistentStorage(QString(dumpRenderTreeTemp));
- else
- QWebSettings::enablePersistentStorage();
+ QWebSettings::enablePersistentStorage(m_persistentStoragePath);
// create our primary testing page/view.
m_mainView = new QWebView(0);
@@ -480,6 +474,7 @@ static bool shouldEnableDeveloperExtras(const QUrl& url)
void DumpRenderTree::open(const QUrl& url)
{
+ DumpRenderTreeSupportQt::dumpResourceLoadCallbacksPath(QFileInfo(url.toString()).path());
resetToConsistentStateBeforeTesting();
if (shouldEnableDeveloperExtras(m_page->mainFrame()->url())) {
@@ -512,7 +507,7 @@ void DumpRenderTree::open(const QUrl& url)
initializeFonts();
#endif
- qt_dump_frame_loader(url.toString().contains("loading/"));
+ DumpRenderTreeSupportQt::dumpFrameLoader(url.toString().contains("loading/"));
setTextOutputEnabled(true);
m_page->mainFrame()->load(url);
}
@@ -733,8 +728,8 @@ static const char *methodNameStringForFailedTest(LayoutTestController *controlle
void DumpRenderTree::dump()
{
// Prevent any further frame load or resource load callbacks from appearing after we dump the result.
- qt_dump_frame_loader(false);
- qt_dump_resource_load_callbacks(false);
+ DumpRenderTreeSupportQt::dumpFrameLoader(false);
+ DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(false);
QWebFrame *mainFrame = m_page->mainFrame();
@@ -751,6 +746,7 @@ void DumpRenderTree::dump()
resultString = mainFrame->renderTreeDump();
if (!resultString.isEmpty()) {
+ fprintf(stdout, "Content-Type: text/plain\n");
fprintf(stdout, "%s", resultString.toUtf8().constData());
if (m_controller->shouldDumpBackForwardList())
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h
index 8309492..e6449b7 100644
--- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h
+++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h
@@ -86,6 +86,7 @@ public:
LayoutTestController *layoutTestController() const { return m_controller; }
EventSender *eventSender() const { return m_eventSender; }
TextInputController *textInputController() const { return m_textInputController; }
+ QString persistentStoragePath() const { return m_persistentStoragePath; }
QWebPage *createWindow();
int windowCount() const;
@@ -141,6 +142,7 @@ private:
QList<QObject*> windows;
bool m_enableTextOutput;
bool m_singleFileMode;
+ QString m_persistentStoragePath;
};
class NetworkAccessManager : public QNetworkAccessManager {
diff --git a/WebKitTools/DumpRenderTree/qt/ImageDiff.cpp b/WebKitTools/DumpRenderTree/qt/ImageDiff.cpp
index 704ca13..8ee68db 100644
--- a/WebKitTools/DumpRenderTree/qt/ImageDiff.cpp
+++ b/WebKitTools/DumpRenderTree/qt/ImageDiff.cpp
@@ -17,13 +17,14 @@
Boston, MA 02110-1301, USA.
*/
+#include <QtCore/qmath.h>
+
#include <QApplication>
#include <QBuffer>
#include <QByteArray>
#include <QImage>
#include <QStringList>
-#include <math.h>
#include <stdio.h>
int main(int argc, char* argv[])
@@ -102,7 +103,7 @@ int main(int argc, char* argv[])
qreal green = (qGreen(pixel) - qGreen(basePixel)) / static_cast<float>(qMax(255 - qGreen(basePixel), qGreen(basePixel)));
qreal blue = (qBlue(pixel) - qBlue(basePixel)) / static_cast<float>(qMax(255 - qBlue(basePixel), qBlue(basePixel)));
qreal alpha = (qAlpha(pixel) - qAlpha(basePixel)) / static_cast<float>(qMax(255 - qAlpha(basePixel), qAlpha(basePixel)));
- qreal distance = sqrt(red * red + green * green + blue * blue + alpha * alpha) / 2.0f;
+ qreal distance = qSqrt(red * red + green * green + blue * blue + alpha * alpha) / 2.0f;
int gray = distance * qreal(255);
diffImage.setPixel(x, y, qRgb(gray, gray, gray));
if (distance >= 1 / qreal(255)) {
@@ -118,7 +119,7 @@ int main(int argc, char* argv[])
if (difference <= tolerance) {
difference = 0;
} else {
- difference = round(difference * 100) / 100;
+ difference = qRound(difference * 100) / 100;
difference = qMax(difference, qreal(0.01));
}
diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
index 3f92b8a..1fadd61 100644
--- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
@@ -37,22 +37,13 @@
#include <QLocale>
#include <qwebsettings.h>
-extern void qt_dump_editing_callbacks(bool b);
-extern void qt_dump_frame_loader(bool b);
-extern void qt_dump_resource_load_callbacks(bool b);
-extern void qt_set_will_send_request_returns_null_on_redirect(bool b);
-extern void qt_set_will_send_request_returns_null(bool b);
-extern void qt_set_will_send_request_clear_headers(const QStringList& headers);
-
-extern void qt_dump_notification(bool b);
-
LayoutTestController::LayoutTestController(WebCore::DumpRenderTree* drt)
: QObject()
, m_drt(drt)
{
qRegisterMetaType<QWebElement>("QWebElement");
reset();
- qt_dump_notification(true);
+ DumpRenderTreeSupportQt::dumpNotification(true);
}
void LayoutTestController::reset()
@@ -73,12 +64,13 @@ void LayoutTestController::reset()
m_handleErrorPages = false;
m_webHistory = 0;
m_globalFlag = false;
- qt_dump_editing_callbacks(false);
- qt_dump_frame_loader(false);
- qt_dump_resource_load_callbacks(false);
- qt_set_will_send_request_returns_null_on_redirect(false);
- qt_set_will_send_request_returns_null(false);
- qt_set_will_send_request_clear_headers(QStringList());
+ DumpRenderTreeSupportQt::dumpEditingCallbacks(false);
+ DumpRenderTreeSupportQt::dumpFrameLoader(false);
+ DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(false);
+ DumpRenderTreeSupportQt::setWillSendRequestReturnsNullOnRedirect(false);
+ DumpRenderTreeSupportQt::setWillSendRequestReturnsNull(false);
+ DumpRenderTreeSupportQt::setWillSendRequestClearHeaders(QStringList());
+ setIconDatabaseEnabled(false);
emit hidePage();
}
@@ -217,32 +209,32 @@ QString LayoutTestController::pathToLocalResource(const QString& url)
void LayoutTestController::dumpEditingCallbacks()
{
qDebug() << ">>>dumpEditingCallbacks";
- qt_dump_editing_callbacks(true);
+ DumpRenderTreeSupportQt::dumpEditingCallbacks(true);
}
void LayoutTestController::dumpFrameLoadCallbacks()
{
- qt_dump_frame_loader(true);
+ DumpRenderTreeSupportQt::dumpFrameLoader(true);
}
void LayoutTestController::dumpResourceLoadCallbacks()
{
- qt_dump_resource_load_callbacks(true);
+ DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(true);
}
void LayoutTestController::setWillSendRequestReturnsNullOnRedirect(bool enabled)
{
- qt_set_will_send_request_returns_null_on_redirect(enabled);
+ DumpRenderTreeSupportQt::setWillSendRequestReturnsNullOnRedirect(enabled);
}
void LayoutTestController::setWillSendRequestReturnsNull(bool enabled)
{
- qt_set_will_send_request_returns_null(enabled);
+ DumpRenderTreeSupportQt::setWillSendRequestReturnsNull(enabled);
}
void LayoutTestController::setWillSendRequestClearHeader(const QStringList& headers)
{
- qt_set_will_send_request_clear_headers(headers);
+ DumpRenderTreeSupportQt::setWillSendRequestClearHeaders(headers);
}
void LayoutTestController::queueBackNavigation(int howFarBackward)
@@ -465,8 +457,7 @@ unsigned LayoutTestController::numberOfActiveAnimations() const
void LayoutTestController::disableImageLoading()
{
- // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27896
- // Also need to make sure image loading is re-enabled for each new test.
+ m_drt->webPage()->settings()->setAttribute(QWebSettings::AutoLoadImages, false);
}
void LayoutTestController::dispatchPendingLoadRequests()
@@ -624,11 +615,28 @@ QString LayoutTestController::markerTextForListItem(const QWebElement& listItem)
return DumpRenderTreeSupportQt::markerTextForListItem(listItem);
}
+QVariantMap LayoutTestController::computedStyleIncludingVisitedInfo(const QWebElement& element) const
+{
+ return DumpRenderTreeSupportQt::computedStyleIncludingVisitedInfo(element);
+}
+
+bool LayoutTestController::elementDoesAutoCompleteForElementWithId(const QString& elementId)
+{
+ return DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(m_drt->webPage()->mainFrame(), elementId);
+}
+
void LayoutTestController::authenticateSession(const QString&, const QString&, const QString&)
{
// FIXME: If there is a concept per-session (per-process) credential storage, the credentials should be added to it for later use.
}
+void LayoutTestController::setIconDatabaseEnabled(bool enable)
+{
+ if (enable && !m_drt->persistentStoragePath().isEmpty())
+ QWebSettings::setIconDatabasePath(m_drt->persistentStoragePath());
+ else
+ QWebSettings::setIconDatabasePath(QString());
+}
const unsigned LayoutTestController::maxViewWidth = 800;
const unsigned LayoutTestController::maxViewHeight = 600;
diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
index 44b80b7..1359a6f 100644
--- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
+++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
@@ -157,6 +157,7 @@ public slots:
bool pauseAnimationAtTimeOnElementWithId(const QString& animationName, double time, const QString& elementId);
bool pauseTransitionAtTimeOnElementWithId(const QString& propertyName, double time, const QString& elementId);
bool sampleSVGAnimationForElementAtTime(const QString& animationId, double time, const QString& elementId);
+ bool elementDoesAutoCompleteForElementWithId(const QString& elementId);
unsigned numberOfActiveAnimations() const;
@@ -168,6 +169,7 @@ public slots:
void setDatabaseQuota(int size);
void clearAllDatabases();
+ void setIconDatabaseEnabled(bool enable);
void waitForPolicyDelegate();
void overridePreference(const QString& name, const QVariant& value);
@@ -186,6 +188,7 @@ public slots:
void setScrollbarPolicy(const QString& orientation, const QString& policy);
QString markerTextForListItem(const QWebElement& listItem);
+ QVariantMap computedStyleIncludingVisitedInfo(const QWebElement& element) const;
// Simulate a request an embedding application could make, populating per-session credential storage.
void authenticateSession(const QString& url, const QString& username, const QString& password);
diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
index e96adae..dfa4de0 100644
--- a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
+++ b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
@@ -140,6 +140,17 @@ wstring urlSuitableForTestResult(const wstring& url)
return PathFindFileNameW(url.c_str());
}
+string toUTF8(BSTR bstr)
+{
+ int result = WideCharToMultiByte(CP_UTF8, 0, bstr, SysStringLen(bstr) + 1, 0, 0, 0, 0);
+ Vector<char> utf8Vector(result);
+ result = WideCharToMultiByte(CP_UTF8, 0, bstr, SysStringLen(bstr) + 1, utf8Vector.data(), result, 0, 0);
+ if (!result)
+ return string();
+
+ return string(utf8Vector.data(), utf8Vector.size() - 1);
+}
+
static LRESULT CALLBACK DumpRenderTreeWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h
index 499c57b..eb5d312 100644
--- a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h
+++ b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h
@@ -49,6 +49,7 @@ extern HWND webViewWindow;
#include <wtf/Vector.h>
std::wstring urlSuitableForTestResult(const std::wstring& url);
+std::string toUTF8(BSTR);
IWebView* createWebViewAndOffscreenWindow(HWND* webViewWindow = 0);
Vector<HWND>& openWindows();
typedef HashMap<HWND, COMPtr<IWebView> > WindowToWebViewMap;
diff --git a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp
index cf4d221..9b9e3c1 100644
--- a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp
+++ b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp
@@ -48,17 +48,6 @@ using std::string;
static FrameLoadDelegate* g_delegateWaitingOnTimer;
-string BSTRtoString(BSTR bstr)
-{
- int result = WideCharToMultiByte(CP_UTF8, 0, bstr, SysStringLen(bstr) + 1, 0, 0, 0, 0);
- Vector<char> utf8Vector(result);
- result = WideCharToMultiByte(CP_UTF8, 0, bstr, SysStringLen(bstr) + 1, utf8Vector.data(), result, 0, 0);
- if (!result)
- return string();
-
- return string(utf8Vector.data(), utf8Vector.size() - 1);
-}
-
string descriptionSuitableForTestResult(IWebFrame* webFrame)
{
COMPtr<IWebView> webView;
@@ -70,11 +59,11 @@ string descriptionSuitableForTestResult(IWebFrame* webFrame)
return string();
BSTR frameNameBSTR;
- if (FAILED(webFrame->name(&frameNameBSTR)) || BSTRtoString(frameNameBSTR).empty() )
+ if (FAILED(webFrame->name(&frameNameBSTR)) || toUTF8(frameNameBSTR).empty())
return (webFrame == mainFrame) ? "main frame" : string();
string frameName = (webFrame == mainFrame) ? "main frame" : "frame";
- frameName += " \"" + BSTRtoString(frameNameBSTR) + "\"";
+ frameName += " \"" + toUTF8(frameNameBSTR) + "\"";
SysFreeString(frameNameBSTR);
return frameName;
diff --git a/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp b/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp
index 89873b6..321d9cf 100644
--- a/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp
+++ b/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp
@@ -106,7 +106,9 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
pluginLog(instance, "src: %s", argv[i]);
} else if (_stricmp(argn[i], "testdocumentopenindestroystream") == 0)
obj->testDocumentOpenInDestroyStream = TRUE;
- else if (_stricmp(argn[i], "testwindowopen") == 0)
+ else if (_stricmp(argn[i], "testGetURLOnDestroy") == 0)
+ obj->testGetURLOnDestroy = TRUE;
+ else if (_stricmp(argn[i], "testwindowopen") == 0)
obj->testWindowOpen = TRUE;
else if (_stricmp(argn[i], "onSetWindow") == 0 && !obj->onSetWindow)
obj->onSetWindow = strdup(argv[i]);
@@ -122,6 +124,9 @@ NPError NPP_Destroy(NPP instance, NPSavedData **save)
{
PluginObject *obj = (PluginObject*)instance->pdata;
if (obj) {
+ if (obj->testGetURLOnDestroy)
+ browser->geturlnotify(obj->npp, "about:blank", "", "");
+
if (obj->onStreamLoad)
free(obj->onStreamLoad);
@@ -137,7 +142,7 @@ NPError NPP_Destroy(NPP instance, NPSavedData **save)
}
if (obj->logDestroy)
- printf("PLUGIN: NPP_Destroy\n");
+ pluginLog(instance, "NPP_Destroy\n");
if (obj->onSetWindow)
free(obj->onSetWindow);
diff --git a/WebKitTools/DumpRenderTree/win/UIDelegate.cpp b/WebKitTools/DumpRenderTree/win/UIDelegate.cpp
index 16724d7..6637068 100755
--- a/WebKitTools/DumpRenderTree/win/UIDelegate.cpp
+++ b/WebKitTools/DumpRenderTree/win/UIDelegate.cpp
@@ -625,7 +625,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::webViewDidInvalidate(
HRESULT STDMETHODCALLTYPE UIDelegate::setStatusText(IWebView*, BSTR text)
{
if (gLayoutTestController->dumpStatusCallbacks())
- printf("UI DELEGATE STATUS CALLBACK: setStatusText:%S\n", text ? text : L"");
+ printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", text ? toUTF8(text).c_str() : "");
return S_OK;
}