From 1482978d1e764e0c31c2df8890913d6801a8e065 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Wed, 11 Sep 2019 12:41:53 +0300 Subject: Import QtWebKit commit 68b093f76fd3ee458de9d1bbf54e1d5a648a71bd Change-Id: I62abae1d1e60d2cb65514d01fa89ad44308a6ba4 Reviewed-by: Konstantin Tokarev --- Source/PlatformQt.cmake | 9 +++++++++ Source/WebKit/CMakeLists.txt | 5 +++++ Source/WebKit/PlatformQt.cmake | 5 +++++ Source/cmake/OptionsQt.cmake | 31 +++++++++++++++++++++++++++++++ Tools/qmake/projects/run_cmake.pro | 5 +++++ 5 files changed, 55 insertions(+) diff --git a/Source/PlatformQt.cmake b/Source/PlatformQt.cmake index 61648331b..2d58228dc 100644 --- a/Source/PlatformQt.cmake +++ b/Source/PlatformQt.cmake @@ -54,6 +54,15 @@ if (USE_MINIMAL_DEBUG_INFO_MSVC AND MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug") endif () endif () +if (FORCE_DEBUG_INFO) + if (COMPILER_IS_GCC_OR_CLANG) + if (NOT APPLE) + target_compile_options(WebKit PRIVATE -fdebug-types-section) + target_compile_options(WebKit2 PRIVATE -fdebug-types-section) + endif () + endif () +endif () + # GTest if (TARGET gtest) diff --git a/Source/WebKit/CMakeLists.txt b/Source/WebKit/CMakeLists.txt index 04117d563..c845856da 100644 --- a/Source/WebKit/CMakeLists.txt +++ b/Source/WebKit/CMakeLists.txt @@ -64,6 +64,11 @@ if (${PORT} STREQUAL "Qt") install(FILES $ DESTINATION "${BIN_INSTALL_DIR}" OPTIONAL) endif () + if (SEPARATE_DEBUG_INFO) + QTWEBKIT_SEPARATE_DEBUG_INFO(WebKit WebKit_DEBUG_INFO) + install(FILES ${WebKit_DEBUG_INFO} DESTINATION "${LIB_INSTALL_DIR}" OPTIONAL) + endif () + if (NOT MSVC) ADD_PREFIX_HEADER(WebKit "${WEBKIT_DIR}/qt/WebKitPrefix.h") endif () diff --git a/Source/WebKit/PlatformQt.cmake b/Source/WebKit/PlatformQt.cmake index 2bd6342be..fe1c59b27 100644 --- a/Source/WebKit/PlatformQt.cmake +++ b/Source/WebKit/PlatformQt.cmake @@ -858,6 +858,11 @@ if (MSVC AND NOT QT_STATIC_BUILD) install(FILES $ DESTINATION "${BIN_INSTALL_DIR}" OPTIONAL) endif () +if (SEPARATE_DEBUG_INFO) + QTWEBKIT_SEPARATE_DEBUG_INFO(WebKitWidgets WebKitWidgets_DEBUG_INFO) + install(FILES ${WebKitWidgets_DEBUG_INFO} DESTINATION "${LIB_INSTALL_DIR}" OPTIONAL) +endif () + if (NOT MSVC AND WIN32) ADD_PREFIX_HEADER(WebKitWidgets "qt/WebKitWidgetsPrefix.h") endif () diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake index 7e1e55340..bdcc58a48 100644 --- a/Source/cmake/OptionsQt.cmake +++ b/Source/cmake/OptionsQt.cmake @@ -147,6 +147,24 @@ macro(QTWEBKIT_GENERATE_MOC_FILES_H _target) endforeach () endmacro() +macro(QTWEBKIT_SEPARATE_DEBUG_INFO _target _target_debug) + if (UNIX AND NOT APPLE) + if (NOT CMAKE_OBJCOPY) + message(WARNING "CMAKE_OBJCOPY is not defined - debug information will not be split") + else () + set(_target_file "$") + set(${_target_debug} "${_target_file}.debug") + add_custom_command(TARGET ${_target} POST_BUILD + COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${_target_file} ${${_target_debug}} + COMMAND ${CMAKE_OBJCOPY} --strip-debug ${_target_file} + COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${${_target_debug}} ${_target_file} + VERBATIM + ) + unset(_target_file) + endif () + endif () +endmacro() + set(CMAKE_MACOSX_RPATH ON) add_definitions(-DBUILDING_QT__=1) @@ -698,6 +716,19 @@ if (WIN32 AND COMPILER_IS_GCC_OR_CLANG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-keep-inline-dllexport") endif () +# See also FORCE_DEBUG_INFO in Source/PlatformQt.cmake +if (FORCE_DEBUG_INFO) + if (COMPILER_IS_GCC_OR_CLANG) + # Enable debug info in Release builds + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -g") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g") + endif () + if (USE_LD_GOLD) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index") + endif () +endif () + if (APPLE) SET_AND_EXPOSE_TO_BUILD(HAVE_QOS_CLASSES 1) endif () diff --git a/Tools/qmake/projects/run_cmake.pro b/Tools/qmake/projects/run_cmake.pro index 5cdd40a77..345e43a01 100644 --- a/Tools/qmake/projects/run_cmake.pro +++ b/Tools/qmake/projects/run_cmake.pro @@ -63,6 +63,11 @@ build_pass|!debug_and_release { CMAKE_CONFIG += USE_MINIMAL_DEBUG_INFO_MSVC=ON } + !macos { + force_debug_info: CMAKE_CONFIG += FORCE_DEBUG_INFO=ON + qtConfig(separate_debug_info): CMAKE_CONFIG += SEPARATE_DEBUG_INFO=ON + } + macos { # Reuse the cached sdk version value from mac/sdk.prf if available # otherwise query for it. -- cgit v1.2.3 From 47e125f8c3ff6fb508a8f055d45b15365d5e9d83 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Fri, 13 Sep 2019 05:20:54 +0300 Subject: Import QtWebKit commit e17807a27e2edf0610f0b34eb42f15da2f6af77d Change-Id: I0b1943e9f1b2e46509825348d1acd64e13d96e5b Reviewed-by: Konstantin Tokarev --- .qmake.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.qmake.conf b/.qmake.conf index 44b1ec1f4..e24564d22 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -3,3 +3,5 @@ QMAKEPATH += $$PWD/Tools/qmake ROOT_WEBKIT_DIR = $$PWD ROOT_BUILD_DIR = $$shadowed($$PWD) + +MODULE_VERSION = 5.13.1 -- cgit v1.2.3 From 3403d64c98fdeb6345d794ec0821929bf7cf1ec0 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Wed, 18 Sep 2019 05:06:25 +0300 Subject: Import QtWebKit commit b9c5fd65c91fb38ac81276e470093dd6683a4ade Change-Id: I4d323f3577d6e897cee5f08b4811bbe1f7553e8d Reviewed-by: Konstantin Tokarev --- Source/cmake/OptionsQt.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake index bdcc58a48..f980569bc 100644 --- a/Source/cmake/OptionsQt.cmake +++ b/Source/cmake/OptionsQt.cmake @@ -29,6 +29,15 @@ if (QT_CONAN_DIR) set(CMAKE_MODULE_PATH ${_BACKUP_CMAKE_MODULE_PATH}) unset(_BACKUP_CMAKE_MODULE_PATH) + # Because we've reset CMAKE_MODULE_PATH, FindZLIB from Conan is not used, which causes error with MinGW + if (NOT QT_BUNDLED_ZLIB) + if (NOT CONAN_ZLIB_ROOT) + message(FATAL_ERROR "CONAN_ZLIB_ROOT is not set") + endif () + set(ZLIB_ROOT ${CONAN_ZLIB_ROOT}) + message(STATUS "ZLIB_ROOT: ${ZLIB_ROOT}") + endif () + install(CODE " set(_conan_imports_dest \${CMAKE_INSTALL_PREFIX}) if (DEFINED ENV{DESTDIR}) -- cgit v1.2.3 From b47f584d07aec2d78ea4a5a5ccf2c761f44f5585 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Tue, 1 Oct 2019 20:15:25 +0300 Subject: Import QtWebKit commit 45c329ee23a9b898fe8e6f0b0ccef8680aab3098 Change-Id: Iebca31394d29eed00a48980825fdd70d93f04d86 Reviewed-by: Konstantin Tokarev --- Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp | 2 +- Source/cmake/OptionsQt.cmake | 2 +- Source/cmake/WebKitMacros.cmake | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index 6bf343087..72db3ebaf 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -1600,7 +1600,7 @@ void GraphicsContext::set3DTransform(const TransformationMatrix& transform) void GraphicsContext::setURLForRect(const URL& url, const IntRect& rect) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) && !defined(QT_NO_PDF) if (paintingDisabled()) return; diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake index f980569bc..ec6081de0 100644 --- a/Source/cmake/OptionsQt.cmake +++ b/Source/cmake/OptionsQt.cmake @@ -20,7 +20,7 @@ if (QT_CONAN_DIR) include("${QT_CONAN_DIR}/conanbuildinfo.cmake") # Remove this workaround when libxslt package is fixed - string(REPLACE "include/libxslt" "include" replace_CONAN_INCLUDE_DIRS ${CONAN_INCLUDE_DIRS}) + string(REPLACE "include/libxslt" "include" replace_CONAN_INCLUDE_DIRS "${CONAN_INCLUDE_DIRS}") set(CONAN_INCLUDE_DIRS ${replace_CONAN_INCLUDE_DIRS}) # Remove this workaround when libxml2 package is fixed diff --git a/Source/cmake/WebKitMacros.cmake b/Source/cmake/WebKitMacros.cmake index d58c73eb4..8d57af7af 100644 --- a/Source/cmake/WebKitMacros.cmake +++ b/Source/cmake/WebKitMacros.cmake @@ -288,10 +288,10 @@ macro(WEBKIT_FRAMEWORK _target) if (APPLE AND NOT PORT STREQUAL "GTK" AND NOT ${${_target}_LIBRARY_TYPE} MATCHES STATIC) set_target_properties(${_target} PROPERTIES FRAMEWORK TRUE) if (${_target}_PUBLIC_HEADERS) - set_target_properties(${_target} PROPERTIES PUBLIC_HEADER "${${_target}_PUBLIC_HEADERS}}") + set_target_properties(${_target} PROPERTIES PUBLIC_HEADER "${${_target}_PUBLIC_HEADERS}") if (${_target}_PRIVATE_HEADERS) foreach (CURRENT_PRIVATE_HEADER ${${_target}_PRIVATE_HEADERS}) - set_property(SOURCE ${CURRENT_PRIVATE_HEADER} PROPERTY MACOSX_PACKAGE_LOCATION ${${_target}_PRIVATE_HEADERS_LOCATION} ) + set_property(SOURCE ${CURRENT_PRIVATE_HEADER} PROPERTY MACOSX_PACKAGE_LOCATION ${${_target}_PRIVATE_HEADERS_LOCATION}) endforeach () endif () endif () -- cgit v1.2.3 From 3395426ab651a631aca8ee6b0a694a71df19100f Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Thu, 3 Oct 2019 22:48:16 +0300 Subject: Import QtWebKit commit 49b749171e786df3adcd7a755df428c1846acd69 Change-Id: I4c82d8030969d941bb78b1cc4e77c0a66db8da2c Reviewed-by: Konstantin Tokarev --- CMakeLists.txt | 5 + Source/WebKit/PlatformQt.cmake | 4 - Source/WebKit/qt/tests/CMakeLists.txt | 66 - Source/WebKit/qt/tests/MIMESniffing/TestData.h | 984 ------ Source/WebKit/qt/tests/MIMESniffing/resources.qrc | 23 - .../MIMESniffing/resources/application_atom+xml | 17 - .../tests/MIMESniffing/resources/application_ogg | Bin 382185 -> 0 bytes .../tests/MIMESniffing/resources/application_pdf | Bin 218882 -> 0 bytes .../MIMESniffing/resources/application_postscript | 137 - .../MIMESniffing/resources/application_rdf+xml | 50 - .../MIMESniffing/resources/application_rss+xml | 45 - .../MIMESniffing/resources/application_x-gzip | Bin 268 -> 0 bytes .../resources/application_x-rar-compressed | Bin 1478 -> 0 bytes .../tests/MIMESniffing/resources/application_zip | Bin 411 -> 0 bytes .../qt/tests/MIMESniffing/resources/audio_x-wave | Bin 184320 -> 0 bytes .../qt/tests/MIMESniffing/resources/image_bmp | Bin 46182 -> 0 bytes .../qt/tests/MIMESniffing/resources/image_gif | Bin 245 -> 0 bytes .../qt/tests/MIMESniffing/resources/image_jpeg | Bin 10874 -> 0 bytes .../qt/tests/MIMESniffing/resources/image_png | Bin 850 -> 0 bytes .../resources/image_vnd.microsoft.icon | Bin 9662 -> 0 bytes .../qt/tests/MIMESniffing/resources/image_webp | Bin 10474 -> 0 bytes .../qt/tests/MIMESniffing/resources/text_html | 3 - .../qt/tests/MIMESniffing/resources/text_xml | 19 - .../qt/tests/MIMESniffing/resources/video_webm | Bin 388027 -> 0 bytes .../qt/tests/MIMESniffing/tst_MIMESniffing.cpp | 72 - .../qt/tests/benchmarks/loading/tst_loading.cpp | 95 - .../qt/tests/benchmarks/painting/tst_painting.cpp | 127 - .../qt/tests/benchmarks/webgl/10000_triangles.html | 59 - .../WebKit/qt/tests/benchmarks/webgl/tst_webgl.cpp | 130 - .../WebKit/qt/tests/benchmarks/webgl/tst_webgl.qrc | 5 - Source/WebKit/qt/tests/hybridPixmap/test.html | 99 - .../qt/tests/hybridPixmap/tst_hybridPixmap.cpp | 52 - .../qt/tests/hybridPixmap/tst_hybridPixmap.qrc | 5 - Source/WebKit/qt/tests/hybridPixmap/widget.cpp | 126 - Source/WebKit/qt/tests/hybridPixmap/widget.h | 74 - Source/WebKit/qt/tests/hybridPixmap/widget.ui | 95 - .../qt/tests/keyeddecoderqt/tst_keyeddecoderqt.cpp | 197 -- .../qt/tests/keyedencoderqt/tst_keyedencoderqt.cpp | 157 - .../tests/qgraphicswebview/resources/greendiv.html | 8 - .../qgraphicswebview/resources/input_types.html | 8 - .../qgraphicswebview/resources/pointing_right.html | 45 - .../qgraphicswebview/resources/pointing_up.html | 46 - .../resources/scrolltest_page.html | 6 - .../qgraphicswebview/tst_qgraphicswebview.cpp | 728 ---- .../qgraphicswebview/tst_qgraphicswebview.qrc | 9 - .../qt/tests/qobjectbridge/tst_qobjectbridge.cpp | 2271 ------------- .../qt/tests/qwebelement/resources/image.png | Bin 14743 -> 0 bytes .../qt/tests/qwebelement/resources/style.css | 1 - .../qt/tests/qwebelement/resources/style2.css | 1 - .../qt/tests/qwebelement/tst_qwebelement.cpp | 1080 ------ .../qt/tests/qwebelement/tst_qwebelement.qrc | 7 - .../WebKit/qt/tests/qwebframe/resources/image.png | Bin 14743 -> 0 bytes .../WebKit/qt/tests/qwebframe/resources/style.css | 1 - .../WebKit/qt/tests/qwebframe/resources/test1.html | 1 - .../WebKit/qt/tests/qwebframe/resources/test2.html | 1 - .../qt/tests/qwebframe/resources/testiframe.html | 53 - .../qt/tests/qwebframe/resources/testiframe2.html | 20 - Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp | 1599 --------- Source/WebKit/qt/tests/qwebframe/tst_qwebframe.qrc | 10 - .../qt/tests/qwebhistory/resources/page1.html | 1 - .../qt/tests/qwebhistory/resources/page2.html | 1 - .../qt/tests/qwebhistory/resources/page3.html | 1 - .../qt/tests/qwebhistory/resources/page4.html | 1 - .../qt/tests/qwebhistory/resources/page5.html | 1 - .../qt/tests/qwebhistory/resources/page6.html | 1 - .../qt/tests/qwebhistory/tst_qwebhistory.cpp | 528 --- .../qt/tests/qwebhistory/tst_qwebhistory.qrc | 11 - .../tst_qwebhistoryinterface.cpp | 92 - .../qt/tests/qwebinspector/tst_qwebinspector.cpp | 75 - .../qt/tests/qwebpage/resources/content.html | 6 - .../qt/tests/qwebpage/resources/frame_a.html | 2 - .../qt/tests/qwebpage/resources/frame_c.html | 1 - .../qt/tests/qwebpage/resources/framedindex.html | 6 - .../WebKit/qt/tests/qwebpage/resources/iframe.html | 6 - .../qt/tests/qwebpage/resources/iframe2.html | 7 - .../qt/tests/qwebpage/resources/iframe3.html | 5 - .../WebKit/qt/tests/qwebpage/resources/index.html | 6 - .../WebKit/qt/tests/qwebpage/resources/script.html | 3 - Source/WebKit/qt/tests/qwebpage/resources/user.css | 3 - Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 3501 ------------------- Source/WebKit/qt/tests/qwebpage/tst_qwebpage.qrc | 15 - .../qwebplugindatabase/tst_qwebplugindatabase.cpp | 437 --- .../tests/qwebsecurityorigin/resources/test.html | 53 - .../qwebsecurityorigin/tst_qwebsecurityorigin.cpp | 191 -- .../qwebsecurityorigin/tst_qwebsecurityorigin.qrc | 6 - .../qt/tests/qwebview/resources/frame_a.html | 2 - .../WebKit/qt/tests/qwebview/resources/index.html | 4 - .../qt/tests/qwebview/resources/input_types.html | 9 - .../tests/qwebview/resources/scrolltest_page.html | 6 - Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp | 546 --- Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc | 9 - Source/WebKit/qt/tests/resources/image2.png | Bin 14743 -> 0 bytes Source/WebKit/qt/tests/util.h | 81 - .../qt/tests/inspectorserver/inspectorserver.pro | 4 + .../UIProcess/API/qt/tests/publicapi/publicapi.pro | 3 + .../API/qt/tests/qmltests/DesktopBehavior.pro | 18 + .../UIProcess/API/qt/tests/qmltests/WebView.pro | 19 + .../UIProcess/API/qt/tests/qmltests/qmltests.pro | 3 + .../API/qt/tests/qquickwebview/qquickwebview.pro | 4 + .../API/qt/tests/qrawwebview/qrawwebview.pro | 3 + Source/WebKit2/UIProcess/API/qt/tests/tests.pri | 20 + Tools/qt/manifest.txt | 2 + tests/CMakeLists.txt | 1 + tests/tests.pro | 2 + tests/webkitwidgets/CMakeLists.txt | 66 + tests/webkitwidgets/MIMESniffing/TestData.h | 984 ++++++ tests/webkitwidgets/MIMESniffing/resources.qrc | 23 + .../MIMESniffing/resources/application_atom+xml | 17 + .../MIMESniffing/resources/application_ogg | Bin 0 -> 382185 bytes .../MIMESniffing/resources/application_pdf | Bin 0 -> 218882 bytes .../MIMESniffing/resources/application_postscript | 137 + .../MIMESniffing/resources/application_rdf+xml | 50 + .../MIMESniffing/resources/application_rss+xml | 45 + .../MIMESniffing/resources/application_x-gzip | Bin 0 -> 268 bytes .../resources/application_x-rar-compressed | Bin 0 -> 1478 bytes .../MIMESniffing/resources/application_zip | Bin 0 -> 411 bytes .../MIMESniffing/resources/audio_x-wave | Bin 0 -> 184320 bytes .../webkitwidgets/MIMESniffing/resources/image_bmp | Bin 0 -> 46182 bytes .../webkitwidgets/MIMESniffing/resources/image_gif | Bin 0 -> 245 bytes .../MIMESniffing/resources/image_jpeg | Bin 0 -> 10874 bytes .../webkitwidgets/MIMESniffing/resources/image_png | Bin 0 -> 850 bytes .../resources/image_vnd.microsoft.icon | Bin 0 -> 9662 bytes .../MIMESniffing/resources/image_webp | Bin 0 -> 10474 bytes .../webkitwidgets/MIMESniffing/resources/text_html | 3 + .../webkitwidgets/MIMESniffing/resources/text_xml | 19 + .../MIMESniffing/resources/video_webm | Bin 0 -> 388027 bytes .../MIMESniffing/tst_MIMESniffing.cpp | 72 + tests/webkitwidgets/benchmarks/loading/loading.pro | 2 + .../benchmarks/loading/tst_loading.cpp | 95 + .../webkitwidgets/benchmarks/painting/painting.pro | 2 + .../benchmarks/painting/tst_painting.cpp | 127 + .../benchmarks/webgl/10000_triangles.html | 59 + tests/webkitwidgets/benchmarks/webgl/tst_webgl.cpp | 130 + tests/webkitwidgets/benchmarks/webgl/tst_webgl.qrc | 5 + tests/webkitwidgets/benchmarks/webgl/webgl.pro | 3 + tests/webkitwidgets/cmake/cmake.pro | 5 + tests/webkitwidgets/hybridPixmap/hybridPixmap.pro | 10 + tests/webkitwidgets/hybridPixmap/test.html | 99 + .../hybridPixmap/tst_hybridPixmap.cpp | 52 + .../hybridPixmap/tst_hybridPixmap.qrc | 5 + tests/webkitwidgets/hybridPixmap/widget.cpp | 126 + tests/webkitwidgets/hybridPixmap/widget.h | 74 + tests/webkitwidgets/hybridPixmap/widget.ui | 95 + .../keyeddecoderqt/tst_keyeddecoderqt.cpp | 197 ++ .../keyedencoderqt/tst_keyedencoderqt.cpp | 157 + .../qgraphicswebview/qgraphicswebview.pro | 6 + .../qgraphicswebview/resources/greendiv.html | 8 + .../qgraphicswebview/resources/input_types.html | 8 + .../qgraphicswebview/resources/pointing_right.html | 45 + .../qgraphicswebview/resources/pointing_up.html | 46 + .../resources/scrolltest_page.html | 6 + .../qgraphicswebview/tst_qgraphicswebview.cpp | 730 ++++ .../qgraphicswebview/tst_qgraphicswebview.qrc | 9 + .../webkitwidgets/qobjectbridge/qobjectbridge.pro | 3 + .../qobjectbridge/tst_qobjectbridge.cpp | 2271 +++++++++++++ tests/webkitwidgets/qwebelement/qwebelement.pro | 2 + .../webkitwidgets/qwebelement/resources/image.png | Bin 0 -> 14743 bytes .../webkitwidgets/qwebelement/resources/style.css | 1 + .../webkitwidgets/qwebelement/resources/style2.css | 1 + .../webkitwidgets/qwebelement/tst_qwebelement.cpp | 1080 ++++++ .../webkitwidgets/qwebelement/tst_qwebelement.qrc | 7 + tests/webkitwidgets/qwebframe/qwebframe.pro | 3 + tests/webkitwidgets/qwebframe/resources/image.png | Bin 0 -> 14743 bytes tests/webkitwidgets/qwebframe/resources/style.css | 1 + tests/webkitwidgets/qwebframe/resources/test1.html | 1 + tests/webkitwidgets/qwebframe/resources/test2.html | 1 + .../qwebframe/resources/testiframe.html | 53 + .../qwebframe/resources/testiframe2.html | 20 + tests/webkitwidgets/qwebframe/tst_qwebframe.cpp | 1601 +++++++++ tests/webkitwidgets/qwebframe/tst_qwebframe.qrc | 10 + tests/webkitwidgets/qwebhistory/qwebhistory.pro | 2 + .../webkitwidgets/qwebhistory/resources/page1.html | 1 + .../webkitwidgets/qwebhistory/resources/page2.html | 1 + .../webkitwidgets/qwebhistory/resources/page3.html | 1 + .../webkitwidgets/qwebhistory/resources/page4.html | 1 + .../webkitwidgets/qwebhistory/resources/page5.html | 1 + .../webkitwidgets/qwebhistory/resources/page6.html | 1 + .../webkitwidgets/qwebhistory/tst_qwebhistory.cpp | 528 +++ .../webkitwidgets/qwebhistory/tst_qwebhistory.qrc | 11 + .../qwebhistoryinterface/qwebhistoryinterface.pro | 2 + .../tst_qwebhistoryinterface.cpp | 92 + .../webkitwidgets/qwebinspector/qwebinspector.pro | 2 + .../qwebinspector/tst_qwebinspector.cpp | 75 + tests/webkitwidgets/qwebpage/qwebpage.pro | 3 + .../webkitwidgets/qwebpage/resources/content.html | 6 + .../webkitwidgets/qwebpage/resources/frame_a.html | 2 + .../webkitwidgets/qwebpage/resources/frame_c.html | 1 + .../qwebpage/resources/framedindex.html | 6 + tests/webkitwidgets/qwebpage/resources/iframe.html | 6 + .../webkitwidgets/qwebpage/resources/iframe2.html | 7 + .../webkitwidgets/qwebpage/resources/iframe3.html | 5 + tests/webkitwidgets/qwebpage/resources/index.html | 6 + tests/webkitwidgets/qwebpage/resources/script.html | 3 + tests/webkitwidgets/qwebpage/resources/user.css | 3 + tests/webkitwidgets/qwebpage/tst_qwebpage.cpp | 3518 ++++++++++++++++++++ tests/webkitwidgets/qwebpage/tst_qwebpage.qrc | 15 + .../qwebplugindatabase/qwebplugindatabase.pro | 2 + .../qwebplugindatabase/tst_qwebplugindatabase.cpp | 437 +++ .../qwebsecurityorigin/qwebsecurityorigin.pro | 2 + .../qwebsecurityorigin/resources/test.html | 53 + .../qwebsecurityorigin/tst_qwebsecurityorigin.cpp | 191 ++ .../qwebsecurityorigin/tst_qwebsecurityorigin.qrc | 6 + tests/webkitwidgets/qwebview/qwebview.pro | 2 + .../webkitwidgets/qwebview/resources/frame_a.html | 2 + tests/webkitwidgets/qwebview/resources/index.html | 4 + .../qwebview/resources/input_types.html | 9 + .../qwebview/resources/scrolltest_page.html | 6 + tests/webkitwidgets/qwebview/tst_qwebview.cpp | 548 +++ tests/webkitwidgets/qwebview/tst_qwebview.qrc | 9 + tests/webkitwidgets/resources/image2.png | Bin 0 -> 14743 bytes tests/webkitwidgets/tests.pri | 22 + tests/webkitwidgets/util.h | 79 + tests/webkitwidgets/webkitwidgets.pro | 16 + 213 files changed, 14343 insertions(+), 14153 deletions(-) delete mode 100644 Source/WebKit/qt/tests/CMakeLists.txt delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/TestData.h delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources.qrc delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/application_atom+xml delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/application_ogg delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/application_pdf delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/application_postscript delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/application_rdf+xml delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/application_rss+xml delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/application_x-gzip delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/application_x-rar-compressed delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/application_zip delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/audio_x-wave delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/image_bmp delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/image_gif delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/image_jpeg delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/image_png delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/image_vnd.microsoft.icon delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/image_webp delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/text_html delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/text_xml delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/resources/video_webm delete mode 100644 Source/WebKit/qt/tests/MIMESniffing/tst_MIMESniffing.cpp delete mode 100644 Source/WebKit/qt/tests/benchmarks/loading/tst_loading.cpp delete mode 100644 Source/WebKit/qt/tests/benchmarks/painting/tst_painting.cpp delete mode 100644 Source/WebKit/qt/tests/benchmarks/webgl/10000_triangles.html delete mode 100644 Source/WebKit/qt/tests/benchmarks/webgl/tst_webgl.cpp delete mode 100644 Source/WebKit/qt/tests/benchmarks/webgl/tst_webgl.qrc delete mode 100644 Source/WebKit/qt/tests/hybridPixmap/test.html delete mode 100644 Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.cpp delete mode 100644 Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.qrc delete mode 100644 Source/WebKit/qt/tests/hybridPixmap/widget.cpp delete mode 100644 Source/WebKit/qt/tests/hybridPixmap/widget.h delete mode 100644 Source/WebKit/qt/tests/hybridPixmap/widget.ui delete mode 100644 Source/WebKit/qt/tests/keyeddecoderqt/tst_keyeddecoderqt.cpp delete mode 100644 Source/WebKit/qt/tests/keyedencoderqt/tst_keyedencoderqt.cpp delete mode 100644 Source/WebKit/qt/tests/qgraphicswebview/resources/greendiv.html delete mode 100644 Source/WebKit/qt/tests/qgraphicswebview/resources/input_types.html delete mode 100644 Source/WebKit/qt/tests/qgraphicswebview/resources/pointing_right.html delete mode 100644 Source/WebKit/qt/tests/qgraphicswebview/resources/pointing_up.html delete mode 100644 Source/WebKit/qt/tests/qgraphicswebview/resources/scrolltest_page.html delete mode 100644 Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp delete mode 100644 Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc delete mode 100644 Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp delete mode 100644 Source/WebKit/qt/tests/qwebelement/resources/image.png delete mode 100644 Source/WebKit/qt/tests/qwebelement/resources/style.css delete mode 100644 Source/WebKit/qt/tests/qwebelement/resources/style2.css delete mode 100644 Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp delete mode 100644 Source/WebKit/qt/tests/qwebelement/tst_qwebelement.qrc delete mode 100644 Source/WebKit/qt/tests/qwebframe/resources/image.png delete mode 100644 Source/WebKit/qt/tests/qwebframe/resources/style.css delete mode 100644 Source/WebKit/qt/tests/qwebframe/resources/test1.html delete mode 100644 Source/WebKit/qt/tests/qwebframe/resources/test2.html delete mode 100644 Source/WebKit/qt/tests/qwebframe/resources/testiframe.html delete mode 100644 Source/WebKit/qt/tests/qwebframe/resources/testiframe2.html delete mode 100644 Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp delete mode 100644 Source/WebKit/qt/tests/qwebframe/tst_qwebframe.qrc delete mode 100644 Source/WebKit/qt/tests/qwebhistory/resources/page1.html delete mode 100644 Source/WebKit/qt/tests/qwebhistory/resources/page2.html delete mode 100644 Source/WebKit/qt/tests/qwebhistory/resources/page3.html delete mode 100644 Source/WebKit/qt/tests/qwebhistory/resources/page4.html delete mode 100644 Source/WebKit/qt/tests/qwebhistory/resources/page5.html delete mode 100644 Source/WebKit/qt/tests/qwebhistory/resources/page6.html delete mode 100644 Source/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp delete mode 100644 Source/WebKit/qt/tests/qwebhistory/tst_qwebhistory.qrc delete mode 100644 Source/WebKit/qt/tests/qwebhistoryinterface/tst_qwebhistoryinterface.cpp delete mode 100644 Source/WebKit/qt/tests/qwebinspector/tst_qwebinspector.cpp delete mode 100644 Source/WebKit/qt/tests/qwebpage/resources/content.html delete mode 100644 Source/WebKit/qt/tests/qwebpage/resources/frame_a.html delete mode 100644 Source/WebKit/qt/tests/qwebpage/resources/frame_c.html delete mode 100644 Source/WebKit/qt/tests/qwebpage/resources/framedindex.html delete mode 100644 Source/WebKit/qt/tests/qwebpage/resources/iframe.html delete mode 100644 Source/WebKit/qt/tests/qwebpage/resources/iframe2.html delete mode 100644 Source/WebKit/qt/tests/qwebpage/resources/iframe3.html delete mode 100644 Source/WebKit/qt/tests/qwebpage/resources/index.html delete mode 100644 Source/WebKit/qt/tests/qwebpage/resources/script.html delete mode 100644 Source/WebKit/qt/tests/qwebpage/resources/user.css delete mode 100644 Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp delete mode 100644 Source/WebKit/qt/tests/qwebpage/tst_qwebpage.qrc delete mode 100644 Source/WebKit/qt/tests/qwebplugindatabase/tst_qwebplugindatabase.cpp delete mode 100644 Source/WebKit/qt/tests/qwebsecurityorigin/resources/test.html delete mode 100644 Source/WebKit/qt/tests/qwebsecurityorigin/tst_qwebsecurityorigin.cpp delete mode 100644 Source/WebKit/qt/tests/qwebsecurityorigin/tst_qwebsecurityorigin.qrc delete mode 100644 Source/WebKit/qt/tests/qwebview/resources/frame_a.html delete mode 100644 Source/WebKit/qt/tests/qwebview/resources/index.html delete mode 100644 Source/WebKit/qt/tests/qwebview/resources/input_types.html delete mode 100644 Source/WebKit/qt/tests/qwebview/resources/scrolltest_page.html delete mode 100644 Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp delete mode 100644 Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc delete mode 100644 Source/WebKit/qt/tests/resources/image2.png delete mode 100644 Source/WebKit/qt/tests/util.h create mode 100644 Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro create mode 100644 Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro create mode 100644 Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro create mode 100644 Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro create mode 100644 Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro create mode 100644 Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro create mode 100644 Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro create mode 100644 Source/WebKit2/UIProcess/API/qt/tests/tests.pri create mode 100644 tests/CMakeLists.txt create mode 100644 tests/tests.pro create mode 100644 tests/webkitwidgets/CMakeLists.txt create mode 100644 tests/webkitwidgets/MIMESniffing/TestData.h create mode 100644 tests/webkitwidgets/MIMESniffing/resources.qrc create mode 100644 tests/webkitwidgets/MIMESniffing/resources/application_atom+xml create mode 100644 tests/webkitwidgets/MIMESniffing/resources/application_ogg create mode 100644 tests/webkitwidgets/MIMESniffing/resources/application_pdf create mode 100644 tests/webkitwidgets/MIMESniffing/resources/application_postscript create mode 100644 tests/webkitwidgets/MIMESniffing/resources/application_rdf+xml create mode 100644 tests/webkitwidgets/MIMESniffing/resources/application_rss+xml create mode 100644 tests/webkitwidgets/MIMESniffing/resources/application_x-gzip create mode 100644 tests/webkitwidgets/MIMESniffing/resources/application_x-rar-compressed create mode 100644 tests/webkitwidgets/MIMESniffing/resources/application_zip create mode 100644 tests/webkitwidgets/MIMESniffing/resources/audio_x-wave create mode 100644 tests/webkitwidgets/MIMESniffing/resources/image_bmp create mode 100644 tests/webkitwidgets/MIMESniffing/resources/image_gif create mode 100644 tests/webkitwidgets/MIMESniffing/resources/image_jpeg create mode 100644 tests/webkitwidgets/MIMESniffing/resources/image_png create mode 100644 tests/webkitwidgets/MIMESniffing/resources/image_vnd.microsoft.icon create mode 100644 tests/webkitwidgets/MIMESniffing/resources/image_webp create mode 100644 tests/webkitwidgets/MIMESniffing/resources/text_html create mode 100644 tests/webkitwidgets/MIMESniffing/resources/text_xml create mode 100644 tests/webkitwidgets/MIMESniffing/resources/video_webm create mode 100644 tests/webkitwidgets/MIMESniffing/tst_MIMESniffing.cpp create mode 100644 tests/webkitwidgets/benchmarks/loading/loading.pro create mode 100644 tests/webkitwidgets/benchmarks/loading/tst_loading.cpp create mode 100644 tests/webkitwidgets/benchmarks/painting/painting.pro create mode 100644 tests/webkitwidgets/benchmarks/painting/tst_painting.cpp create mode 100644 tests/webkitwidgets/benchmarks/webgl/10000_triangles.html create mode 100644 tests/webkitwidgets/benchmarks/webgl/tst_webgl.cpp create mode 100644 tests/webkitwidgets/benchmarks/webgl/tst_webgl.qrc create mode 100644 tests/webkitwidgets/benchmarks/webgl/webgl.pro create mode 100644 tests/webkitwidgets/cmake/cmake.pro create mode 100644 tests/webkitwidgets/hybridPixmap/hybridPixmap.pro create mode 100644 tests/webkitwidgets/hybridPixmap/test.html create mode 100644 tests/webkitwidgets/hybridPixmap/tst_hybridPixmap.cpp create mode 100644 tests/webkitwidgets/hybridPixmap/tst_hybridPixmap.qrc create mode 100644 tests/webkitwidgets/hybridPixmap/widget.cpp create mode 100644 tests/webkitwidgets/hybridPixmap/widget.h create mode 100644 tests/webkitwidgets/hybridPixmap/widget.ui create mode 100644 tests/webkitwidgets/keyeddecoderqt/tst_keyeddecoderqt.cpp create mode 100644 tests/webkitwidgets/keyedencoderqt/tst_keyedencoderqt.cpp create mode 100644 tests/webkitwidgets/qgraphicswebview/qgraphicswebview.pro create mode 100644 tests/webkitwidgets/qgraphicswebview/resources/greendiv.html create mode 100644 tests/webkitwidgets/qgraphicswebview/resources/input_types.html create mode 100644 tests/webkitwidgets/qgraphicswebview/resources/pointing_right.html create mode 100644 tests/webkitwidgets/qgraphicswebview/resources/pointing_up.html create mode 100644 tests/webkitwidgets/qgraphicswebview/resources/scrolltest_page.html create mode 100644 tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.cpp create mode 100644 tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.qrc create mode 100644 tests/webkitwidgets/qobjectbridge/qobjectbridge.pro create mode 100644 tests/webkitwidgets/qobjectbridge/tst_qobjectbridge.cpp create mode 100644 tests/webkitwidgets/qwebelement/qwebelement.pro create mode 100644 tests/webkitwidgets/qwebelement/resources/image.png create mode 100644 tests/webkitwidgets/qwebelement/resources/style.css create mode 100644 tests/webkitwidgets/qwebelement/resources/style2.css create mode 100644 tests/webkitwidgets/qwebelement/tst_qwebelement.cpp create mode 100644 tests/webkitwidgets/qwebelement/tst_qwebelement.qrc create mode 100644 tests/webkitwidgets/qwebframe/qwebframe.pro create mode 100644 tests/webkitwidgets/qwebframe/resources/image.png create mode 100644 tests/webkitwidgets/qwebframe/resources/style.css create mode 100644 tests/webkitwidgets/qwebframe/resources/test1.html create mode 100644 tests/webkitwidgets/qwebframe/resources/test2.html create mode 100644 tests/webkitwidgets/qwebframe/resources/testiframe.html create mode 100644 tests/webkitwidgets/qwebframe/resources/testiframe2.html create mode 100644 tests/webkitwidgets/qwebframe/tst_qwebframe.cpp create mode 100644 tests/webkitwidgets/qwebframe/tst_qwebframe.qrc create mode 100644 tests/webkitwidgets/qwebhistory/qwebhistory.pro create mode 100644 tests/webkitwidgets/qwebhistory/resources/page1.html create mode 100644 tests/webkitwidgets/qwebhistory/resources/page2.html create mode 100644 tests/webkitwidgets/qwebhistory/resources/page3.html create mode 100644 tests/webkitwidgets/qwebhistory/resources/page4.html create mode 100644 tests/webkitwidgets/qwebhistory/resources/page5.html create mode 100644 tests/webkitwidgets/qwebhistory/resources/page6.html create mode 100644 tests/webkitwidgets/qwebhistory/tst_qwebhistory.cpp create mode 100644 tests/webkitwidgets/qwebhistory/tst_qwebhistory.qrc create mode 100644 tests/webkitwidgets/qwebhistoryinterface/qwebhistoryinterface.pro create mode 100644 tests/webkitwidgets/qwebhistoryinterface/tst_qwebhistoryinterface.cpp create mode 100644 tests/webkitwidgets/qwebinspector/qwebinspector.pro create mode 100644 tests/webkitwidgets/qwebinspector/tst_qwebinspector.cpp create mode 100644 tests/webkitwidgets/qwebpage/qwebpage.pro create mode 100644 tests/webkitwidgets/qwebpage/resources/content.html create mode 100644 tests/webkitwidgets/qwebpage/resources/frame_a.html create mode 100644 tests/webkitwidgets/qwebpage/resources/frame_c.html create mode 100644 tests/webkitwidgets/qwebpage/resources/framedindex.html create mode 100644 tests/webkitwidgets/qwebpage/resources/iframe.html create mode 100644 tests/webkitwidgets/qwebpage/resources/iframe2.html create mode 100644 tests/webkitwidgets/qwebpage/resources/iframe3.html create mode 100644 tests/webkitwidgets/qwebpage/resources/index.html create mode 100644 tests/webkitwidgets/qwebpage/resources/script.html create mode 100644 tests/webkitwidgets/qwebpage/resources/user.css create mode 100644 tests/webkitwidgets/qwebpage/tst_qwebpage.cpp create mode 100644 tests/webkitwidgets/qwebpage/tst_qwebpage.qrc create mode 100644 tests/webkitwidgets/qwebplugindatabase/qwebplugindatabase.pro create mode 100644 tests/webkitwidgets/qwebplugindatabase/tst_qwebplugindatabase.cpp create mode 100644 tests/webkitwidgets/qwebsecurityorigin/qwebsecurityorigin.pro create mode 100644 tests/webkitwidgets/qwebsecurityorigin/resources/test.html create mode 100644 tests/webkitwidgets/qwebsecurityorigin/tst_qwebsecurityorigin.cpp create mode 100644 tests/webkitwidgets/qwebsecurityorigin/tst_qwebsecurityorigin.qrc create mode 100644 tests/webkitwidgets/qwebview/qwebview.pro create mode 100644 tests/webkitwidgets/qwebview/resources/frame_a.html create mode 100644 tests/webkitwidgets/qwebview/resources/index.html create mode 100644 tests/webkitwidgets/qwebview/resources/input_types.html create mode 100644 tests/webkitwidgets/qwebview/resources/scrolltest_page.html create mode 100644 tests/webkitwidgets/qwebview/tst_qwebview.cpp create mode 100644 tests/webkitwidgets/qwebview/tst_qwebview.qrc create mode 100644 tests/webkitwidgets/resources/image2.png create mode 100644 tests/webkitwidgets/tests.pri create mode 100644 tests/webkitwidgets/util.h create mode 100644 tests/webkitwidgets/webkitwidgets.pro diff --git a/CMakeLists.txt b/CMakeLists.txt index fb92a7a5c..31a2ea1fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,11 @@ include(WebKitCommon) # ----------------------------------------------------------------------------- if (ENABLE_API_TESTS) enable_testing() + + # Qt API tests are at top level because of Coin requirements + if (${PORT} STREQUAL "Qt") + add_subdirectory(tests) + endif () endif () # ----------------------------------------------------------------------------- diff --git a/Source/WebKit/PlatformQt.cmake b/Source/WebKit/PlatformQt.cmake index fe1c59b27..9aed9906e 100644 --- a/Source/WebKit/PlatformQt.cmake +++ b/Source/WebKit/PlatformQt.cmake @@ -909,7 +909,3 @@ endif () if (ENABLE_WEBKIT2) add_subdirectory(qt/declarative) endif () - -if (ENABLE_API_TESTS) - add_subdirectory(qt/tests) -endif () diff --git a/Source/WebKit/qt/tests/CMakeLists.txt b/Source/WebKit/qt/tests/CMakeLists.txt deleted file mode 100644 index 42d636573..000000000 --- a/Source/WebKit/qt/tests/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -remove_definitions(-DQT_ASCII_CAST_WARNINGS) - -include_directories( - "${CMAKE_SOURCE_DIR}/Source" - "${FORWARDING_HEADERS_DIR}" - "${WEBKIT_DIR}/qt/Api" - "${WEBKIT_DIR}/qt/WidgetApi" -) - -include_directories(SYSTEM - ${ICU_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5Test_INCLUDE_DIRS} -) - -add_definitions(-DTESTS_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/") - -if (ENABLE_TEST_SUPPORT) - add_definitions(-DHAVE_QTTESTSUPPORT) -endif () - -set(QtWK1ApiTests_LIBRARIES - ${Qt5Gui_LIBRARIES} - ${Qt5Network_LIBRARIES} - ${Qt5Test_LIBRARIES} - ${Qt5Widgets_LIBRARIES} - WebKitWidgets -) - -# Inspired by EFL WK2 tests -set(QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY - ${CMAKE_BINARY_DIR}/tests -) - -set(QtWK1ApiTests - hybridPixmap - qgraphicswebview - qobjectbridge - qwebelement - qwebframe - qwebhistory - qwebhistoryinterface - qwebinspector - qwebpage - qwebsecurityorigin - qwebview -) - -set(tst_hybridPixmap_SOURCES hybridPixmap/widget.cpp) -qt5_wrap_ui(tst_hybridPixmap_SOURCES hybridPixmap/widget.ui) - -foreach (testName ${QtWK1ApiTests}) - list(APPEND tst_${testName}_SOURCES ${testName}/tst_${testName}.cpp) - if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${testName}/tst_${testName}.qrc") - qt5_add_resources(tst_${testName}_SOURCES ${testName}/tst_${testName}.qrc) - endif () - - add_executable(tst_${testName} ${tst_${testName}_SOURCES}) - target_include_directories(tst_${testName} PRIVATE ${testName}) - target_link_libraries(tst_${testName} ${QtWK1ApiTests_LIBRARIES}) - set_target_properties(tst_${testName} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY} AUTOMOC ON) - - add_test(${testName} "${QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY}/tst_${testName}") - set_tests_properties(${testName} PROPERTIES TIMEOUT 60) -endforeach () diff --git a/Source/WebKit/qt/tests/MIMESniffing/TestData.h b/Source/WebKit/qt/tests/MIMESniffing/TestData.h deleted file mode 100644 index c04bd6b89..000000000 --- a/Source/WebKit/qt/tests/MIMESniffing/TestData.h +++ /dev/null @@ -1,984 +0,0 @@ -/* - Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TestData_h -#define TestData_h - -typedef struct _TestData { - const char* file; - const char* advertisedType; - bool isImage; - const char* sniffedType; -} TestData; - -static const TestData testList[] = { - {":/application_atom+xml", "text/plain", false, "text/plain"}, - {":/application_atom+xml", "text/plain", true, "text/plain"}, - {":/application_atom+xml", "unknown/unknown", false, "text/xml"}, - {":/application_atom+xml", "unknown/unknown", true, "text/xml"}, - {":/application_atom+xml", "application/unknown", false, "text/xml"}, - {":/application_atom+xml", "application/unknown", true, "text/xml"}, - {":/application_atom+xml", "*/*", false, "text/xml"}, - {":/application_atom+xml", "*/*", true, "text/xml"}, - {":/application_atom+xml", "text/xml", false, 0}, - {":/application_atom+xml", "text/xml", true, 0}, - {":/application_atom+xml", "application/xml", false, 0}, - {":/application_atom+xml", "application/xml", true, 0}, - {":/application_atom+xml", "text/html", false, "application/atom+xml"}, - {":/application_atom+xml", "text/html", true, 0}, - {":/application_atom+xml", "text/xml", false, 0}, - {":/application_atom+xml", "text/xml", true, 0}, - {":/application_atom+xml", "application/pdf", false, 0}, - {":/application_atom+xml", "application/pdf", true, 0}, - {":/application_atom+xml", "application/postscript", false, 0}, - {":/application_atom+xml", "application/postscript", true, 0}, - {":/application_atom+xml", "application/ogg", false, 0}, - {":/application_atom+xml", "application/ogg", true, 0}, - {":/application_atom+xml", "video/webm", false, 0}, - {":/application_atom+xml", "video/webm", true, 0}, - {":/application_atom+xml", "application/x-rar-compressed", false, 0}, - {":/application_atom+xml", "application/x-rar-compressed", true, 0}, - {":/application_atom+xml", "application/zip", false, 0}, - {":/application_atom+xml", "application/zip", true, 0}, - {":/application_atom+xml", "application/x-gzip", false, 0}, - {":/application_atom+xml", "application/x-gzip", true, 0}, - {":/application_atom+xml", "audio/x-wave", false, 0}, - {":/application_atom+xml", "audio/x-wave", true, 0}, - {":/application_atom+xml", "image/webp", false, 0}, - {":/application_atom+xml", "image/webp", true, 0}, - {":/application_atom+xml", "image/gif", false, 0}, - {":/application_atom+xml", "image/gif", true, 0}, - {":/application_atom+xml", "image/png", false, 0}, - {":/application_atom+xml", "image/png", true, 0}, - {":/application_atom+xml", "image/jpeg", false, 0}, - {":/application_atom+xml", "image/jpeg", true, 0}, - {":/application_atom+xml", "image/bmp", false, 0}, - {":/application_atom+xml", "image/bmp", true, 0}, - {":/application_atom+xml", "image/vnd.microsoft.icon", false, 0}, - {":/application_atom+xml", "image/vnd.microsoft.icon", true, 0}, - {":/application_atom+xml", "application/rdf+xml", false, 0}, - {":/application_atom+xml", "application/rdf+xml", true, 0}, - {":/application_atom+xml", "application/rss+xml", false, 0}, - {":/application_atom+xml", "application/rss+xml", true, 0}, - {":/application_atom+xml", "application/atom+xml", false, 0}, - {":/application_atom+xml", "application/atom+xml", true, 0}, - {":/application_ogg", "text/plain", false, "application/ogg"}, - {":/application_ogg", "text/plain", true, "application/ogg"}, - {":/application_ogg", "unknown/unknown", false, "application/ogg"}, - {":/application_ogg", "unknown/unknown", true, "application/ogg"}, - {":/application_ogg", "application/unknown", false, "application/ogg"}, - {":/application_ogg", "application/unknown", true, "application/ogg"}, - {":/application_ogg", "*/*", false, "application/ogg"}, - {":/application_ogg", "*/*", true, "application/ogg"}, - {":/application_ogg", "text/xml", false, 0}, - {":/application_ogg", "text/xml", true, 0}, - {":/application_ogg", "application/xml", false, 0}, - {":/application_ogg", "application/xml", true, 0}, - {":/application_ogg", "text/html", false, 0}, - {":/application_ogg", "text/html", true, 0}, - {":/application_ogg", "text/xml", false, 0}, - {":/application_ogg", "text/xml", true, 0}, - {":/application_ogg", "application/pdf", false, 0}, - {":/application_ogg", "application/pdf", true, 0}, - {":/application_ogg", "application/postscript", false, 0}, - {":/application_ogg", "application/postscript", true, 0}, - {":/application_ogg", "application/ogg", false, 0}, - {":/application_ogg", "application/ogg", true, 0}, - {":/application_ogg", "video/webm", false, 0}, - {":/application_ogg", "video/webm", true, 0}, - {":/application_ogg", "application/x-rar-compressed", false, 0}, - {":/application_ogg", "application/x-rar-compressed", true, 0}, - {":/application_ogg", "application/zip", false, 0}, - {":/application_ogg", "application/zip", true, 0}, - {":/application_ogg", "application/x-gzip", false, 0}, - {":/application_ogg", "application/x-gzip", true, 0}, - {":/application_ogg", "audio/x-wave", false, 0}, - {":/application_ogg", "audio/x-wave", true, 0}, - {":/application_ogg", "image/webp", false, 0}, - {":/application_ogg", "image/webp", true, 0}, - {":/application_ogg", "image/gif", false, 0}, - {":/application_ogg", "image/gif", true, 0}, - {":/application_ogg", "image/png", false, 0}, - {":/application_ogg", "image/png", true, 0}, - {":/application_ogg", "image/jpeg", false, 0}, - {":/application_ogg", "image/jpeg", true, 0}, - {":/application_ogg", "image/bmp", false, 0}, - {":/application_ogg", "image/bmp", true, 0}, - {":/application_ogg", "image/vnd.microsoft.icon", false, 0}, - {":/application_ogg", "image/vnd.microsoft.icon", true, 0}, - {":/application_ogg", "application/rdf+xml", false, 0}, - {":/application_ogg", "application/rdf+xml", true, 0}, - {":/application_ogg", "application/rss+xml", false, 0}, - {":/application_ogg", "application/rss+xml", true, 0}, - {":/application_ogg", "application/atom+xml", false, 0}, - {":/application_ogg", "application/atom+xml", true, 0}, - {":/application_pdf", "text/plain", false, "application/octet-stream"}, - {":/application_pdf", "text/plain", true, "application/octet-stream"}, - {":/application_pdf", "unknown/unknown", false, "application/pdf"}, - {":/application_pdf", "unknown/unknown", true, "application/pdf"}, - {":/application_pdf", "application/unknown", false, "application/pdf"}, - {":/application_pdf", "application/unknown", true, "application/pdf"}, - {":/application_pdf", "*/*", false, "application/pdf"}, - {":/application_pdf", "*/*", true, "application/pdf"}, - {":/application_pdf", "text/xml", false, 0}, - {":/application_pdf", "text/xml", true, 0}, - {":/application_pdf", "application/xml", false, 0}, - {":/application_pdf", "application/xml", true, 0}, - {":/application_pdf", "text/html", false, 0}, - {":/application_pdf", "text/html", true, 0}, - {":/application_pdf", "text/xml", false, 0}, - {":/application_pdf", "text/xml", true, 0}, - {":/application_pdf", "application/pdf", false, 0}, - {":/application_pdf", "application/pdf", true, 0}, - {":/application_pdf", "application/postscript", false, 0}, - {":/application_pdf", "application/postscript", true, 0}, - {":/application_pdf", "application/ogg", false, 0}, - {":/application_pdf", "application/ogg", true, 0}, - {":/application_pdf", "video/webm", false, 0}, - {":/application_pdf", "video/webm", true, 0}, - {":/application_pdf", "application/x-rar-compressed", false, 0}, - {":/application_pdf", "application/x-rar-compressed", true, 0}, - {":/application_pdf", "application/zip", false, 0}, - {":/application_pdf", "application/zip", true, 0}, - {":/application_pdf", "application/x-gzip", false, 0}, - {":/application_pdf", "application/x-gzip", true, 0}, - {":/application_pdf", "audio/x-wave", false, 0}, - {":/application_pdf", "audio/x-wave", true, 0}, - {":/application_pdf", "image/webp", false, 0}, - {":/application_pdf", "image/webp", true, 0}, - {":/application_pdf", "image/gif", false, 0}, - {":/application_pdf", "image/gif", true, 0}, - {":/application_pdf", "image/png", false, 0}, - {":/application_pdf", "image/png", true, 0}, - {":/application_pdf", "image/jpeg", false, 0}, - {":/application_pdf", "image/jpeg", true, 0}, - {":/application_pdf", "image/bmp", false, 0}, - {":/application_pdf", "image/bmp", true, 0}, - {":/application_pdf", "image/vnd.microsoft.icon", false, 0}, - {":/application_pdf", "image/vnd.microsoft.icon", true, 0}, - {":/application_pdf", "application/rdf+xml", false, 0}, - {":/application_pdf", "application/rdf+xml", true, 0}, - {":/application_pdf", "application/rss+xml", false, 0}, - {":/application_pdf", "application/rss+xml", true, 0}, - {":/application_pdf", "application/atom+xml", false, 0}, - {":/application_pdf", "application/atom+xml", true, 0}, - {":/application_postscript", "text/plain", false, "text/plain"}, - {":/application_postscript", "text/plain", true, "text/plain"}, - {":/application_postscript", "unknown/unknown", false, "application/postscript"}, - {":/application_postscript", "unknown/unknown", true, "application/postscript"}, - {":/application_postscript", "application/unknown", false, "application/postscript"}, - {":/application_postscript", "application/unknown", true, "application/postscript"}, - {":/application_postscript", "*/*", false, "application/postscript"}, - {":/application_postscript", "*/*", true, "application/postscript"}, - {":/application_postscript", "text/xml", false, 0}, - {":/application_postscript", "text/xml", true, 0}, - {":/application_postscript", "application/xml", false, 0}, - {":/application_postscript", "application/xml", true, 0}, - {":/application_postscript", "text/html", false, 0}, - {":/application_postscript", "text/html", true, 0}, - {":/application_postscript", "text/xml", false, 0}, - {":/application_postscript", "text/xml", true, 0}, - {":/application_postscript", "application/pdf", false, 0}, - {":/application_postscript", "application/pdf", true, 0}, - {":/application_postscript", "application/postscript", false, 0}, - {":/application_postscript", "application/postscript", true, 0}, - {":/application_postscript", "application/ogg", false, 0}, - {":/application_postscript", "application/ogg", true, 0}, - {":/application_postscript", "video/webm", false, 0}, - {":/application_postscript", "video/webm", true, 0}, - {":/application_postscript", "application/x-rar-compressed", false, 0}, - {":/application_postscript", "application/x-rar-compressed", true, 0}, - {":/application_postscript", "application/zip", false, 0}, - {":/application_postscript", "application/zip", true, 0}, - {":/application_postscript", "application/x-gzip", false, 0}, - {":/application_postscript", "application/x-gzip", true, 0}, - {":/application_postscript", "audio/x-wave", false, 0}, - {":/application_postscript", "audio/x-wave", true, 0}, - {":/application_postscript", "image/webp", false, 0}, - {":/application_postscript", "image/webp", true, 0}, - {":/application_postscript", "image/gif", false, 0}, - {":/application_postscript", "image/gif", true, 0}, - {":/application_postscript", "image/png", false, 0}, - {":/application_postscript", "image/png", true, 0}, - {":/application_postscript", "image/jpeg", false, 0}, - {":/application_postscript", "image/jpeg", true, 0}, - {":/application_postscript", "image/bmp", false, 0}, - {":/application_postscript", "image/bmp", true, 0}, - {":/application_postscript", "image/vnd.microsoft.icon", false, 0}, - {":/application_postscript", "image/vnd.microsoft.icon", true, 0}, - {":/application_postscript", "application/rdf+xml", false, 0}, - {":/application_postscript", "application/rdf+xml", true, 0}, - {":/application_postscript", "application/rss+xml", false, 0}, - {":/application_postscript", "application/rss+xml", true, 0}, - {":/application_postscript", "application/atom+xml", false, 0}, - {":/application_postscript", "application/atom+xml", true, 0}, - {":/application_rdf+xml", "text/plain", false, "text/plain"}, - {":/application_rdf+xml", "text/plain", true, "text/plain"}, - {":/application_rdf+xml", "unknown/unknown", false, "text/xml"}, - {":/application_rdf+xml", "unknown/unknown", true, "text/xml"}, - {":/application_rdf+xml", "application/unknown", false, "text/xml"}, - {":/application_rdf+xml", "application/unknown", true, "text/xml"}, - {":/application_rdf+xml", "*/*", false, "text/xml"}, - {":/application_rdf+xml", "*/*", true, "text/xml"}, - {":/application_rdf+xml", "text/xml", false, 0}, - {":/application_rdf+xml", "text/xml", true, 0}, - {":/application_rdf+xml", "application/xml", false, 0}, - {":/application_rdf+xml", "application/xml", true, 0}, - {":/application_rdf+xml", "text/html", false, "application/rdf+xml"}, - {":/application_rdf+xml", "text/html", true, 0}, - {":/application_rdf+xml", "text/xml", false, 0}, - {":/application_rdf+xml", "text/xml", true, 0}, - {":/application_rdf+xml", "application/pdf", false, 0}, - {":/application_rdf+xml", "application/pdf", true, 0}, - {":/application_rdf+xml", "application/postscript", false, 0}, - {":/application_rdf+xml", "application/postscript", true, 0}, - {":/application_rdf+xml", "application/ogg", false, 0}, - {":/application_rdf+xml", "application/ogg", true, 0}, - {":/application_rdf+xml", "video/webm", false, 0}, - {":/application_rdf+xml", "video/webm", true, 0}, - {":/application_rdf+xml", "application/x-rar-compressed", false, 0}, - {":/application_rdf+xml", "application/x-rar-compressed", true, 0}, - {":/application_rdf+xml", "application/zip", false, 0}, - {":/application_rdf+xml", "application/zip", true, 0}, - {":/application_rdf+xml", "application/x-gzip", false, 0}, - {":/application_rdf+xml", "application/x-gzip", true, 0}, - {":/application_rdf+xml", "audio/x-wave", false, 0}, - {":/application_rdf+xml", "audio/x-wave", true, 0}, - {":/application_rdf+xml", "image/webp", false, 0}, - {":/application_rdf+xml", "image/webp", true, 0}, - {":/application_rdf+xml", "image/gif", false, 0}, - {":/application_rdf+xml", "image/gif", true, 0}, - {":/application_rdf+xml", "image/png", false, 0}, - {":/application_rdf+xml", "image/png", true, 0}, - {":/application_rdf+xml", "image/jpeg", false, 0}, - {":/application_rdf+xml", "image/jpeg", true, 0}, - {":/application_rdf+xml", "image/bmp", false, 0}, - {":/application_rdf+xml", "image/bmp", true, 0}, - {":/application_rdf+xml", "image/vnd.microsoft.icon", false, 0}, - {":/application_rdf+xml", "image/vnd.microsoft.icon", true, 0}, - {":/application_rdf+xml", "application/rdf+xml", false, 0}, - {":/application_rdf+xml", "application/rdf+xml", true, 0}, - {":/application_rdf+xml", "application/rss+xml", false, 0}, - {":/application_rdf+xml", "application/rss+xml", true, 0}, - {":/application_rdf+xml", "application/atom+xml", false, 0}, - {":/application_rdf+xml", "application/atom+xml", true, 0}, - {":/application_rss+xml", "text/plain", false, "text/plain"}, - {":/application_rss+xml", "text/plain", true, "text/plain"}, - {":/application_rss+xml", "unknown/unknown", false, "text/xml"}, - {":/application_rss+xml", "unknown/unknown", true, "text/xml"}, - {":/application_rss+xml", "application/unknown", false, "text/xml"}, - {":/application_rss+xml", "application/unknown", true, "text/xml"}, - {":/application_rss+xml", "*/*", false, "text/xml"}, - {":/application_rss+xml", "*/*", true, "text/xml"}, - {":/application_rss+xml", "text/xml", false, 0}, - {":/application_rss+xml", "text/xml", true, 0}, - {":/application_rss+xml", "application/xml", false, 0}, - {":/application_rss+xml", "application/xml", true, 0}, - {":/application_rss+xml", "text/html", false, "application/rss+xml"}, - {":/application_rss+xml", "text/html", true, 0}, - {":/application_rss+xml", "text/xml", false, 0}, - {":/application_rss+xml", "text/xml", true, 0}, - {":/application_rss+xml", "application/pdf", false, 0}, - {":/application_rss+xml", "application/pdf", true, 0}, - {":/application_rss+xml", "application/postscript", false, 0}, - {":/application_rss+xml", "application/postscript", true, 0}, - {":/application_rss+xml", "application/ogg", false, 0}, - {":/application_rss+xml", "application/ogg", true, 0}, - {":/application_rss+xml", "video/webm", false, 0}, - {":/application_rss+xml", "video/webm", true, 0}, - {":/application_rss+xml", "application/x-rar-compressed", false, 0}, - {":/application_rss+xml", "application/x-rar-compressed", true, 0}, - {":/application_rss+xml", "application/zip", false, 0}, - {":/application_rss+xml", "application/zip", true, 0}, - {":/application_rss+xml", "application/x-gzip", false, 0}, - {":/application_rss+xml", "application/x-gzip", true, 0}, - {":/application_rss+xml", "audio/x-wave", false, 0}, - {":/application_rss+xml", "audio/x-wave", true, 0}, - {":/application_rss+xml", "image/webp", false, 0}, - {":/application_rss+xml", "image/webp", true, 0}, - {":/application_rss+xml", "image/gif", false, 0}, - {":/application_rss+xml", "image/gif", true, 0}, - {":/application_rss+xml", "image/png", false, 0}, - {":/application_rss+xml", "image/png", true, 0}, - {":/application_rss+xml", "image/jpeg", false, 0}, - {":/application_rss+xml", "image/jpeg", true, 0}, - {":/application_rss+xml", "image/bmp", false, 0}, - {":/application_rss+xml", "image/bmp", true, 0}, - {":/application_rss+xml", "image/vnd.microsoft.icon", false, 0}, - {":/application_rss+xml", "image/vnd.microsoft.icon", true, 0}, - {":/application_rss+xml", "application/rdf+xml", false, 0}, - {":/application_rss+xml", "application/rdf+xml", true, 0}, - {":/application_rss+xml", "application/rss+xml", false, 0}, - {":/application_rss+xml", "application/rss+xml", true, 0}, - {":/application_rss+xml", "application/atom+xml", false, 0}, - {":/application_rss+xml", "application/atom+xml", true, 0}, - {":/application_x-gzip", "text/plain", false, "application/x-gzip"}, - {":/application_x-gzip", "text/plain", true, "application/x-gzip"}, - {":/application_x-gzip", "unknown/unknown", false, "application/x-gzip"}, - {":/application_x-gzip", "unknown/unknown", true, "application/x-gzip"}, - {":/application_x-gzip", "application/unknown", false, "application/x-gzip"}, - {":/application_x-gzip", "application/unknown", true, "application/x-gzip"}, - {":/application_x-gzip", "*/*", false, "application/x-gzip"}, - {":/application_x-gzip", "*/*", true, "application/x-gzip"}, - {":/application_x-gzip", "text/xml", false, 0}, - {":/application_x-gzip", "text/xml", true, 0}, - {":/application_x-gzip", "application/xml", false, 0}, - {":/application_x-gzip", "application/xml", true, 0}, - {":/application_x-gzip", "text/html", false, 0}, - {":/application_x-gzip", "text/html", true, 0}, - {":/application_x-gzip", "text/xml", false, 0}, - {":/application_x-gzip", "text/xml", true, 0}, - {":/application_x-gzip", "application/pdf", false, 0}, - {":/application_x-gzip", "application/pdf", true, 0}, - {":/application_x-gzip", "application/postscript", false, 0}, - {":/application_x-gzip", "application/postscript", true, 0}, - {":/application_x-gzip", "application/ogg", false, 0}, - {":/application_x-gzip", "application/ogg", true, 0}, - {":/application_x-gzip", "video/webm", false, 0}, - {":/application_x-gzip", "video/webm", true, 0}, - {":/application_x-gzip", "application/x-rar-compressed", false, 0}, - {":/application_x-gzip", "application/x-rar-compressed", true, 0}, - {":/application_x-gzip", "application/zip", false, 0}, - {":/application_x-gzip", "application/zip", true, 0}, - {":/application_x-gzip", "application/x-gzip", false, 0}, - {":/application_x-gzip", "application/x-gzip", true, 0}, - {":/application_x-gzip", "audio/x-wave", false, 0}, - {":/application_x-gzip", "audio/x-wave", true, 0}, - {":/application_x-gzip", "image/webp", false, 0}, - {":/application_x-gzip", "image/webp", true, 0}, - {":/application_x-gzip", "image/gif", false, 0}, - {":/application_x-gzip", "image/gif", true, 0}, - {":/application_x-gzip", "image/png", false, 0}, - {":/application_x-gzip", "image/png", true, 0}, - {":/application_x-gzip", "image/jpeg", false, 0}, - {":/application_x-gzip", "image/jpeg", true, 0}, - {":/application_x-gzip", "image/bmp", false, 0}, - {":/application_x-gzip", "image/bmp", true, 0}, - {":/application_x-gzip", "image/vnd.microsoft.icon", false, 0}, - {":/application_x-gzip", "image/vnd.microsoft.icon", true, 0}, - {":/application_x-gzip", "application/rdf+xml", false, 0}, - {":/application_x-gzip", "application/rdf+xml", true, 0}, - {":/application_x-gzip", "application/rss+xml", false, 0}, - {":/application_x-gzip", "application/rss+xml", true, 0}, - {":/application_x-gzip", "application/atom+xml", false, 0}, - {":/application_x-gzip", "application/atom+xml", true, 0}, - {":/application_x-rar-compressed", "text/plain", false, "application/x-rar-compressed"}, - {":/application_x-rar-compressed", "text/plain", true, "application/x-rar-compressed"}, - {":/application_x-rar-compressed", "unknown/unknown", false, "application/x-rar-compressed"}, - {":/application_x-rar-compressed", "unknown/unknown", true, "application/x-rar-compressed"}, - {":/application_x-rar-compressed", "application/unknown", false, "application/x-rar-compressed"}, - {":/application_x-rar-compressed", "application/unknown", true, "application/x-rar-compressed"}, - {":/application_x-rar-compressed", "*/*", false, "application/x-rar-compressed"}, - {":/application_x-rar-compressed", "*/*", true, "application/x-rar-compressed"}, - {":/application_x-rar-compressed", "text/xml", false, 0}, - {":/application_x-rar-compressed", "text/xml", true, 0}, - {":/application_x-rar-compressed", "application/xml", false, 0}, - {":/application_x-rar-compressed", "application/xml", true, 0}, - {":/application_x-rar-compressed", "text/html", false, 0}, - {":/application_x-rar-compressed", "text/html", true, 0}, - {":/application_x-rar-compressed", "text/xml", false, 0}, - {":/application_x-rar-compressed", "text/xml", true, 0}, - {":/application_x-rar-compressed", "application/pdf", false, 0}, - {":/application_x-rar-compressed", "application/pdf", true, 0}, - {":/application_x-rar-compressed", "application/postscript", false, 0}, - {":/application_x-rar-compressed", "application/postscript", true, 0}, - {":/application_x-rar-compressed", "application/ogg", false, 0}, - {":/application_x-rar-compressed", "application/ogg", true, 0}, - {":/application_x-rar-compressed", "video/webm", false, 0}, - {":/application_x-rar-compressed", "video/webm", true, 0}, - {":/application_x-rar-compressed", "application/x-rar-compressed", false, 0}, - {":/application_x-rar-compressed", "application/x-rar-compressed", true, 0}, - {":/application_x-rar-compressed", "application/zip", false, 0}, - {":/application_x-rar-compressed", "application/zip", true, 0}, - {":/application_x-rar-compressed", "application/x-gzip", false, 0}, - {":/application_x-rar-compressed", "application/x-gzip", true, 0}, - {":/application_x-rar-compressed", "audio/x-wave", false, 0}, - {":/application_x-rar-compressed", "audio/x-wave", true, 0}, - {":/application_x-rar-compressed", "image/webp", false, 0}, - {":/application_x-rar-compressed", "image/webp", true, 0}, - {":/application_x-rar-compressed", "image/gif", false, 0}, - {":/application_x-rar-compressed", "image/gif", true, 0}, - {":/application_x-rar-compressed", "image/png", false, 0}, - {":/application_x-rar-compressed", "image/png", true, 0}, - {":/application_x-rar-compressed", "image/jpeg", false, 0}, - {":/application_x-rar-compressed", "image/jpeg", true, 0}, - {":/application_x-rar-compressed", "image/bmp", false, 0}, - {":/application_x-rar-compressed", "image/bmp", true, 0}, - {":/application_x-rar-compressed", "image/vnd.microsoft.icon", false, 0}, - {":/application_x-rar-compressed", "image/vnd.microsoft.icon", true, 0}, - {":/application_x-rar-compressed", "application/rdf+xml", false, 0}, - {":/application_x-rar-compressed", "application/rdf+xml", true, 0}, - {":/application_x-rar-compressed", "application/rss+xml", false, 0}, - {":/application_x-rar-compressed", "application/rss+xml", true, 0}, - {":/application_x-rar-compressed", "application/atom+xml", false, 0}, - {":/application_x-rar-compressed", "application/atom+xml", true, 0}, - {":/application_zip", "text/plain", false, "application/zip"}, - {":/application_zip", "text/plain", true, "application/zip"}, - {":/application_zip", "unknown/unknown", false, "application/zip"}, - {":/application_zip", "unknown/unknown", true, "application/zip"}, - {":/application_zip", "application/unknown", false, "application/zip"}, - {":/application_zip", "application/unknown", true, "application/zip"}, - {":/application_zip", "*/*", false, "application/zip"}, - {":/application_zip", "*/*", true, "application/zip"}, - {":/application_zip", "text/xml", false, 0}, - {":/application_zip", "text/xml", true, 0}, - {":/application_zip", "application/xml", false, 0}, - {":/application_zip", "application/xml", true, 0}, - {":/application_zip", "text/html", false, 0}, - {":/application_zip", "text/html", true, 0}, - {":/application_zip", "text/xml", false, 0}, - {":/application_zip", "text/xml", true, 0}, - {":/application_zip", "application/pdf", false, 0}, - {":/application_zip", "application/pdf", true, 0}, - {":/application_zip", "application/postscript", false, 0}, - {":/application_zip", "application/postscript", true, 0}, - {":/application_zip", "application/ogg", false, 0}, - {":/application_zip", "application/ogg", true, 0}, - {":/application_zip", "video/webm", false, 0}, - {":/application_zip", "video/webm", true, 0}, - {":/application_zip", "application/x-rar-compressed", false, 0}, - {":/application_zip", "application/x-rar-compressed", true, 0}, - {":/application_zip", "application/zip", false, 0}, - {":/application_zip", "application/zip", true, 0}, - {":/application_zip", "application/x-gzip", false, 0}, - {":/application_zip", "application/x-gzip", true, 0}, - {":/application_zip", "audio/x-wave", false, 0}, - {":/application_zip", "audio/x-wave", true, 0}, - {":/application_zip", "image/webp", false, 0}, - {":/application_zip", "image/webp", true, 0}, - {":/application_zip", "image/gif", false, 0}, - {":/application_zip", "image/gif", true, 0}, - {":/application_zip", "image/png", false, 0}, - {":/application_zip", "image/png", true, 0}, - {":/application_zip", "image/jpeg", false, 0}, - {":/application_zip", "image/jpeg", true, 0}, - {":/application_zip", "image/bmp", false, 0}, - {":/application_zip", "image/bmp", true, 0}, - {":/application_zip", "image/vnd.microsoft.icon", false, 0}, - {":/application_zip", "image/vnd.microsoft.icon", true, 0}, - {":/application_zip", "application/rdf+xml", false, 0}, - {":/application_zip", "application/rdf+xml", true, 0}, - {":/application_zip", "application/rss+xml", false, 0}, - {":/application_zip", "application/rss+xml", true, 0}, - {":/application_zip", "application/atom+xml", false, 0}, - {":/application_zip", "application/atom+xml", true, 0}, - {":/audio_x-wave", "text/plain", false, "audio/x-wave"}, - {":/audio_x-wave", "text/plain", true, "audio/x-wave"}, - {":/audio_x-wave", "unknown/unknown", false, "audio/x-wave"}, - {":/audio_x-wave", "unknown/unknown", true, "audio/x-wave"}, - {":/audio_x-wave", "application/unknown", false, "audio/x-wave"}, - {":/audio_x-wave", "application/unknown", true, "audio/x-wave"}, - {":/audio_x-wave", "*/*", false, "audio/x-wave"}, - {":/audio_x-wave", "*/*", true, "audio/x-wave"}, - {":/audio_x-wave", "text/xml", false, 0}, - {":/audio_x-wave", "text/xml", true, 0}, - {":/audio_x-wave", "application/xml", false, 0}, - {":/audio_x-wave", "application/xml", true, 0}, - {":/audio_x-wave", "text/html", false, 0}, - {":/audio_x-wave", "text/html", true, 0}, - {":/audio_x-wave", "text/xml", false, 0}, - {":/audio_x-wave", "text/xml", true, 0}, - {":/audio_x-wave", "application/pdf", false, 0}, - {":/audio_x-wave", "application/pdf", true, 0}, - {":/audio_x-wave", "application/postscript", false, 0}, - {":/audio_x-wave", "application/postscript", true, 0}, - {":/audio_x-wave", "application/ogg", false, 0}, - {":/audio_x-wave", "application/ogg", true, 0}, - {":/audio_x-wave", "video/webm", false, 0}, - {":/audio_x-wave", "video/webm", true, 0}, - {":/audio_x-wave", "application/x-rar-compressed", false, 0}, - {":/audio_x-wave", "application/x-rar-compressed", true, 0}, - {":/audio_x-wave", "application/zip", false, 0}, - {":/audio_x-wave", "application/zip", true, 0}, - {":/audio_x-wave", "application/x-gzip", false, 0}, - {":/audio_x-wave", "application/x-gzip", true, 0}, - {":/audio_x-wave", "audio/x-wave", false, 0}, - {":/audio_x-wave", "audio/x-wave", true, 0}, - {":/audio_x-wave", "image/webp", false, 0}, - {":/audio_x-wave", "image/webp", true, 0}, - {":/audio_x-wave", "image/gif", false, 0}, - {":/audio_x-wave", "image/gif", true, 0}, - {":/audio_x-wave", "image/png", false, 0}, - {":/audio_x-wave", "image/png", true, 0}, - {":/audio_x-wave", "image/jpeg", false, 0}, - {":/audio_x-wave", "image/jpeg", true, 0}, - {":/audio_x-wave", "image/bmp", false, 0}, - {":/audio_x-wave", "image/bmp", true, 0}, - {":/audio_x-wave", "image/vnd.microsoft.icon", false, 0}, - {":/audio_x-wave", "image/vnd.microsoft.icon", true, 0}, - {":/audio_x-wave", "application/rdf+xml", false, 0}, - {":/audio_x-wave", "application/rdf+xml", true, 0}, - {":/audio_x-wave", "application/rss+xml", false, 0}, - {":/audio_x-wave", "application/rss+xml", true, 0}, - {":/audio_x-wave", "application/atom+xml", false, 0}, - {":/audio_x-wave", "application/atom+xml", true, 0}, - {":/image_bmp", "text/plain", false, "image/bmp"}, - {":/image_bmp", "text/plain", true, "image/bmp"}, - {":/image_bmp", "unknown/unknown", false, "image/bmp"}, - {":/image_bmp", "unknown/unknown", true, "image/bmp"}, - {":/image_bmp", "application/unknown", false, "image/bmp"}, - {":/image_bmp", "application/unknown", true, "image/bmp"}, - {":/image_bmp", "*/*", false, "image/bmp"}, - {":/image_bmp", "*/*", true, "image/bmp"}, - {":/image_bmp", "text/xml", false, 0}, - {":/image_bmp", "text/xml", true, 0}, - {":/image_bmp", "application/xml", false, 0}, - {":/image_bmp", "application/xml", true, 0}, - {":/image_bmp", "text/html", false, 0}, - {":/image_bmp", "text/html", true, "image/bmp"}, - {":/image_bmp", "text/xml", false, 0}, - {":/image_bmp", "text/xml", true, 0}, - {":/image_bmp", "application/pdf", false, 0}, - {":/image_bmp", "application/pdf", true, "image/bmp"}, - {":/image_bmp", "application/postscript", false, 0}, - {":/image_bmp", "application/postscript", true, "image/bmp"}, - {":/image_bmp", "application/ogg", false, 0}, - {":/image_bmp", "application/ogg", true, "image/bmp"}, - {":/image_bmp", "video/webm", false, 0}, - {":/image_bmp", "video/webm", true, "image/bmp"}, - {":/image_bmp", "application/x-rar-compressed", false, 0}, - {":/image_bmp", "application/x-rar-compressed", true, "image/bmp"}, - {":/image_bmp", "application/zip", false, 0}, - {":/image_bmp", "application/zip", true, "image/bmp"}, - {":/image_bmp", "application/x-gzip", false, 0}, - {":/image_bmp", "application/x-gzip", true, "image/bmp"}, - {":/image_bmp", "audio/x-wave", false, 0}, - {":/image_bmp", "audio/x-wave", true, "image/bmp"}, - {":/image_bmp", "image/webp", false, 0}, - {":/image_bmp", "image/webp", true, "image/bmp"}, - {":/image_bmp", "image/gif", false, 0}, - {":/image_bmp", "image/gif", true, "image/bmp"}, - {":/image_bmp", "image/png", false, 0}, - {":/image_bmp", "image/png", true, "image/bmp"}, - {":/image_bmp", "image/jpeg", false, 0}, - {":/image_bmp", "image/jpeg", true, "image/bmp"}, - {":/image_bmp", "image/bmp", false, 0}, - {":/image_bmp", "image/bmp", true, "image/bmp"}, - {":/image_bmp", "image/vnd.microsoft.icon", false, 0}, - {":/image_bmp", "image/vnd.microsoft.icon", true, "image/bmp"}, - {":/image_bmp", "application/rdf+xml", false, 0}, - {":/image_bmp", "application/rdf+xml", true, 0}, - {":/image_bmp", "application/rss+xml", false, 0}, - {":/image_bmp", "application/rss+xml", true, 0}, - {":/image_bmp", "application/atom+xml", false, 0}, - {":/image_bmp", "application/atom+xml", true, 0}, - {":/image_gif", "text/plain", false, "image/gif"}, - {":/image_gif", "text/plain", true, "image/gif"}, - {":/image_gif", "unknown/unknown", false, "image/gif"}, - {":/image_gif", "unknown/unknown", true, "image/gif"}, - {":/image_gif", "application/unknown", false, "image/gif"}, - {":/image_gif", "application/unknown", true, "image/gif"}, - {":/image_gif", "*/*", false, "image/gif"}, - {":/image_gif", "*/*", true, "image/gif"}, - {":/image_gif", "text/xml", false, 0}, - {":/image_gif", "text/xml", true, 0}, - {":/image_gif", "application/xml", false, 0}, - {":/image_gif", "application/xml", true, 0}, - {":/image_gif", "text/html", false, 0}, - {":/image_gif", "text/html", true, "image/gif"}, - {":/image_gif", "text/xml", false, 0}, - {":/image_gif", "text/xml", true, 0}, - {":/image_gif", "application/pdf", false, 0}, - {":/image_gif", "application/pdf", true, "image/gif"}, - {":/image_gif", "application/postscript", false, 0}, - {":/image_gif", "application/postscript", true, "image/gif"}, - {":/image_gif", "application/ogg", false, 0}, - {":/image_gif", "application/ogg", true, "image/gif"}, - {":/image_gif", "video/webm", false, 0}, - {":/image_gif", "video/webm", true, "image/gif"}, - {":/image_gif", "application/x-rar-compressed", false, 0}, - {":/image_gif", "application/x-rar-compressed", true, "image/gif"}, - {":/image_gif", "application/zip", false, 0}, - {":/image_gif", "application/zip", true, "image/gif"}, - {":/image_gif", "application/x-gzip", false, 0}, - {":/image_gif", "application/x-gzip", true, "image/gif"}, - {":/image_gif", "audio/x-wave", false, 0}, - {":/image_gif", "audio/x-wave", true, "image/gif"}, - {":/image_gif", "image/webp", false, 0}, - {":/image_gif", "image/webp", true, "image/gif"}, - {":/image_gif", "image/gif", false, 0}, - {":/image_gif", "image/gif", true, "image/gif"}, - {":/image_gif", "image/png", false, 0}, - {":/image_gif", "image/png", true, "image/gif"}, - {":/image_gif", "image/jpeg", false, 0}, - {":/image_gif", "image/jpeg", true, "image/gif"}, - {":/image_gif", "image/bmp", false, 0}, - {":/image_gif", "image/bmp", true, "image/gif"}, - {":/image_gif", "image/vnd.microsoft.icon", false, 0}, - {":/image_gif", "image/vnd.microsoft.icon", true, "image/gif"}, - {":/image_gif", "application/rdf+xml", false, 0}, - {":/image_gif", "application/rdf+xml", true, 0}, - {":/image_gif", "application/rss+xml", false, 0}, - {":/image_gif", "application/rss+xml", true, 0}, - {":/image_gif", "application/atom+xml", false, 0}, - {":/image_gif", "application/atom+xml", true, 0}, - {":/image_jpeg", "text/plain", false, "image/jpeg"}, - {":/image_jpeg", "text/plain", true, "image/jpeg"}, - {":/image_jpeg", "unknown/unknown", false, "image/jpeg"}, - {":/image_jpeg", "unknown/unknown", true, "image/jpeg"}, - {":/image_jpeg", "application/unknown", false, "image/jpeg"}, - {":/image_jpeg", "application/unknown", true, "image/jpeg"}, - {":/image_jpeg", "*/*", false, "image/jpeg"}, - {":/image_jpeg", "*/*", true, "image/jpeg"}, - {":/image_jpeg", "text/xml", false, 0}, - {":/image_jpeg", "text/xml", true, 0}, - {":/image_jpeg", "application/xml", false, 0}, - {":/image_jpeg", "application/xml", true, 0}, - {":/image_jpeg", "text/html", false, 0}, - {":/image_jpeg", "text/html", true, "image/jpeg"}, - {":/image_jpeg", "text/xml", false, 0}, - {":/image_jpeg", "text/xml", true, 0}, - {":/image_jpeg", "application/pdf", false, 0}, - {":/image_jpeg", "application/pdf", true, "image/jpeg"}, - {":/image_jpeg", "application/postscript", false, 0}, - {":/image_jpeg", "application/postscript", true, "image/jpeg"}, - {":/image_jpeg", "application/ogg", false, 0}, - {":/image_jpeg", "application/ogg", true, "image/jpeg"}, - {":/image_jpeg", "video/webm", false, 0}, - {":/image_jpeg", "video/webm", true, "image/jpeg"}, - {":/image_jpeg", "application/x-rar-compressed", false, 0}, - {":/image_jpeg", "application/x-rar-compressed", true, "image/jpeg"}, - {":/image_jpeg", "application/zip", false, 0}, - {":/image_jpeg", "application/zip", true, "image/jpeg"}, - {":/image_jpeg", "application/x-gzip", false, 0}, - {":/image_jpeg", "application/x-gzip", true, "image/jpeg"}, - {":/image_jpeg", "audio/x-wave", false, 0}, - {":/image_jpeg", "audio/x-wave", true, "image/jpeg"}, - {":/image_jpeg", "image/webp", false, 0}, - {":/image_jpeg", "image/webp", true, "image/jpeg"}, - {":/image_jpeg", "image/gif", false, 0}, - {":/image_jpeg", "image/gif", true, "image/jpeg"}, - {":/image_jpeg", "image/png", false, 0}, - {":/image_jpeg", "image/png", true, "image/jpeg"}, - {":/image_jpeg", "image/jpeg", false, 0}, - {":/image_jpeg", "image/jpeg", true, "image/jpeg"}, - {":/image_jpeg", "image/bmp", false, 0}, - {":/image_jpeg", "image/bmp", true, "image/jpeg"}, - {":/image_jpeg", "image/vnd.microsoft.icon", false, 0}, - {":/image_jpeg", "image/vnd.microsoft.icon", true, "image/jpeg"}, - {":/image_jpeg", "application/rdf+xml", false, 0}, - {":/image_jpeg", "application/rdf+xml", true, 0}, - {":/image_jpeg", "application/rss+xml", false, 0}, - {":/image_jpeg", "application/rss+xml", true, 0}, - {":/image_jpeg", "application/atom+xml", false, 0}, - {":/image_jpeg", "application/atom+xml", true, 0}, - {":/image_png", "text/plain", false, "image/png"}, - {":/image_png", "text/plain", true, "image/png"}, - {":/image_png", "unknown/unknown", false, "image/png"}, - {":/image_png", "unknown/unknown", true, "image/png"}, - {":/image_png", "application/unknown", false, "image/png"}, - {":/image_png", "application/unknown", true, "image/png"}, - {":/image_png", "*/*", false, "image/png"}, - {":/image_png", "*/*", true, "image/png"}, - {":/image_png", "text/xml", false, 0}, - {":/image_png", "text/xml", true, 0}, - {":/image_png", "application/xml", false, 0}, - {":/image_png", "application/xml", true, 0}, - {":/image_png", "text/html", false, 0}, - {":/image_png", "text/html", true, "image/png"}, - {":/image_png", "text/xml", false, 0}, - {":/image_png", "text/xml", true, 0}, - {":/image_png", "application/pdf", false, 0}, - {":/image_png", "application/pdf", true, "image/png"}, - {":/image_png", "application/postscript", false, 0}, - {":/image_png", "application/postscript", true, "image/png"}, - {":/image_png", "application/ogg", false, 0}, - {":/image_png", "application/ogg", true, "image/png"}, - {":/image_png", "video/webm", false, 0}, - {":/image_png", "video/webm", true, "image/png"}, - {":/image_png", "application/x-rar-compressed", false, 0}, - {":/image_png", "application/x-rar-compressed", true, "image/png"}, - {":/image_png", "application/zip", false, 0}, - {":/image_png", "application/zip", true, "image/png"}, - {":/image_png", "application/x-gzip", false, 0}, - {":/image_png", "application/x-gzip", true, "image/png"}, - {":/image_png", "audio/x-wave", false, 0}, - {":/image_png", "audio/x-wave", true, "image/png"}, - {":/image_png", "image/webp", false, 0}, - {":/image_png", "image/webp", true, "image/png"}, - {":/image_png", "image/gif", false, 0}, - {":/image_png", "image/gif", true, "image/png"}, - {":/image_png", "image/png", false, 0}, - {":/image_png", "image/png", true, "image/png"}, - {":/image_png", "image/jpeg", false, 0}, - {":/image_png", "image/jpeg", true, "image/png"}, - {":/image_png", "image/bmp", false, 0}, - {":/image_png", "image/bmp", true, "image/png"}, - {":/image_png", "image/vnd.microsoft.icon", false, 0}, - {":/image_png", "image/vnd.microsoft.icon", true, "image/png"}, - {":/image_png", "application/rdf+xml", false, 0}, - {":/image_png", "application/rdf+xml", true, 0}, - {":/image_png", "application/rss+xml", false, 0}, - {":/image_png", "application/rss+xml", true, 0}, - {":/image_png", "application/atom+xml", false, 0}, - {":/image_png", "application/atom+xml", true, 0}, - {":/image_vnd.microsoft.icon", "text/plain", false, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "text/plain", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "unknown/unknown", false, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "unknown/unknown", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "application/unknown", false, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "application/unknown", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "*/*", false, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "*/*", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "text/xml", false, 0}, - {":/image_vnd.microsoft.icon", "text/xml", true, 0}, - {":/image_vnd.microsoft.icon", "application/xml", false, 0}, - {":/image_vnd.microsoft.icon", "application/xml", true, 0}, - {":/image_vnd.microsoft.icon", "text/html", false, 0}, - {":/image_vnd.microsoft.icon", "text/html", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "text/xml", false, 0}, - {":/image_vnd.microsoft.icon", "text/xml", true, 0}, - {":/image_vnd.microsoft.icon", "application/pdf", false, 0}, - {":/image_vnd.microsoft.icon", "application/pdf", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "application/postscript", false, 0}, - {":/image_vnd.microsoft.icon", "application/postscript", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "application/ogg", false, 0}, - {":/image_vnd.microsoft.icon", "application/ogg", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "video/webm", false, 0}, - {":/image_vnd.microsoft.icon", "video/webm", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "application/x-rar-compressed", false, 0}, - {":/image_vnd.microsoft.icon", "application/x-rar-compressed", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "application/zip", false, 0}, - {":/image_vnd.microsoft.icon", "application/zip", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "application/x-gzip", false, 0}, - {":/image_vnd.microsoft.icon", "application/x-gzip", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "audio/x-wave", false, 0}, - {":/image_vnd.microsoft.icon", "audio/x-wave", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "image/webp", false, 0}, - {":/image_vnd.microsoft.icon", "image/webp", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "image/gif", false, 0}, - {":/image_vnd.microsoft.icon", "image/gif", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "image/png", false, 0}, - {":/image_vnd.microsoft.icon", "image/png", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "image/jpeg", false, 0}, - {":/image_vnd.microsoft.icon", "image/jpeg", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "image/bmp", false, 0}, - {":/image_vnd.microsoft.icon", "image/bmp", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "image/vnd.microsoft.icon", false, 0}, - {":/image_vnd.microsoft.icon", "image/vnd.microsoft.icon", true, "image/vnd.microsoft.icon"}, - {":/image_vnd.microsoft.icon", "application/rdf+xml", false, 0}, - {":/image_vnd.microsoft.icon", "application/rdf+xml", true, 0}, - {":/image_vnd.microsoft.icon", "application/rss+xml", false, 0}, - {":/image_vnd.microsoft.icon", "application/rss+xml", true, 0}, - {":/image_vnd.microsoft.icon", "application/atom+xml", false, 0}, - {":/image_vnd.microsoft.icon", "application/atom+xml", true, 0}, - {":/image_webp", "text/plain", false, "image/webp"}, - {":/image_webp", "text/plain", true, "image/webp"}, - {":/image_webp", "unknown/unknown", false, "image/webp"}, - {":/image_webp", "unknown/unknown", true, "image/webp"}, - {":/image_webp", "application/unknown", false, "image/webp"}, - {":/image_webp", "application/unknown", true, "image/webp"}, - {":/image_webp", "*/*", false, "image/webp"}, - {":/image_webp", "*/*", true, "image/webp"}, - {":/image_webp", "text/xml", false, 0}, - {":/image_webp", "text/xml", true, 0}, - {":/image_webp", "application/xml", false, 0}, - {":/image_webp", "application/xml", true, 0}, - {":/image_webp", "text/html", false, 0}, - {":/image_webp", "text/html", true, "image/webp"}, - {":/image_webp", "text/xml", false, 0}, - {":/image_webp", "text/xml", true, 0}, - {":/image_webp", "application/pdf", false, 0}, - {":/image_webp", "application/pdf", true, "image/webp"}, - {":/image_webp", "application/postscript", false, 0}, - {":/image_webp", "application/postscript", true, "image/webp"}, - {":/image_webp", "application/ogg", false, 0}, - {":/image_webp", "application/ogg", true, "image/webp"}, - {":/image_webp", "video/webm", false, 0}, - {":/image_webp", "video/webm", true, "image/webp"}, - {":/image_webp", "application/x-rar-compressed", false, 0}, - {":/image_webp", "application/x-rar-compressed", true, "image/webp"}, - {":/image_webp", "application/zip", false, 0}, - {":/image_webp", "application/zip", true, "image/webp"}, - {":/image_webp", "application/x-gzip", false, 0}, - {":/image_webp", "application/x-gzip", true, "image/webp"}, - {":/image_webp", "audio/x-wave", false, 0}, - {":/image_webp", "audio/x-wave", true, "image/webp"}, - {":/image_webp", "image/webp", false, 0}, - {":/image_webp", "image/webp", true, "image/webp"}, - {":/image_webp", "image/gif", false, 0}, - {":/image_webp", "image/gif", true, "image/webp"}, - {":/image_webp", "image/png", false, 0}, - {":/image_webp", "image/png", true, "image/webp"}, - {":/image_webp", "image/jpeg", false, 0}, - {":/image_webp", "image/jpeg", true, "image/webp"}, - {":/image_webp", "image/bmp", false, 0}, - {":/image_webp", "image/bmp", true, "image/webp"}, - {":/image_webp", "image/vnd.microsoft.icon", false, 0}, - {":/image_webp", "image/vnd.microsoft.icon", true, "image/webp"}, - {":/image_webp", "application/rdf+xml", false, 0}, - {":/image_webp", "application/rdf+xml", true, 0}, - {":/image_webp", "application/rss+xml", false, 0}, - {":/image_webp", "application/rss+xml", true, 0}, - {":/image_webp", "application/atom+xml", false, 0}, - {":/image_webp", "application/atom+xml", true, 0}, - {":/text_html", "text/plain", false, "text/plain"}, - {":/text_html", "text/plain", true, "text/plain"}, - {":/text_html", "unknown/unknown", false, "text/html"}, - {":/text_html", "unknown/unknown", true, "text/html"}, - {":/text_html", "application/unknown", false, "text/html"}, - {":/text_html", "application/unknown", true, "text/html"}, - {":/text_html", "*/*", false, "text/html"}, - {":/text_html", "*/*", true, "text/html"}, - {":/text_html", "text/xml", false, 0}, - {":/text_html", "text/xml", true, 0}, - {":/text_html", "application/xml", false, 0}, - {":/text_html", "application/xml", true, 0}, - {":/text_html", "text/html", false, 0}, - {":/text_html", "text/html", true, 0}, - {":/text_html", "text/xml", false, 0}, - {":/text_html", "text/xml", true, 0}, - {":/text_html", "application/pdf", false, 0}, - {":/text_html", "application/pdf", true, 0}, - {":/text_html", "application/postscript", false, 0}, - {":/text_html", "application/postscript", true, 0}, - {":/text_html", "application/ogg", false, 0}, - {":/text_html", "application/ogg", true, 0}, - {":/text_html", "video/webm", false, 0}, - {":/text_html", "video/webm", true, 0}, - {":/text_html", "application/x-rar-compressed", false, 0}, - {":/text_html", "application/x-rar-compressed", true, 0}, - {":/text_html", "application/zip", false, 0}, - {":/text_html", "application/zip", true, 0}, - {":/text_html", "application/x-gzip", false, 0}, - {":/text_html", "application/x-gzip", true, 0}, - {":/text_html", "audio/x-wave", false, 0}, - {":/text_html", "audio/x-wave", true, 0}, - {":/text_html", "image/webp", false, 0}, - {":/text_html", "image/webp", true, 0}, - {":/text_html", "image/gif", false, 0}, - {":/text_html", "image/gif", true, 0}, - {":/text_html", "image/png", false, 0}, - {":/text_html", "image/png", true, 0}, - {":/text_html", "image/jpeg", false, 0}, - {":/text_html", "image/jpeg", true, 0}, - {":/text_html", "image/bmp", false, 0}, - {":/text_html", "image/bmp", true, 0}, - {":/text_html", "image/vnd.microsoft.icon", false, 0}, - {":/text_html", "image/vnd.microsoft.icon", true, 0}, - {":/text_html", "application/rdf+xml", false, 0}, - {":/text_html", "application/rdf+xml", true, 0}, - {":/text_html", "application/rss+xml", false, 0}, - {":/text_html", "application/rss+xml", true, 0}, - {":/text_html", "application/atom+xml", false, 0}, - {":/text_html", "application/atom+xml", true, 0}, - {":/text_xml", "text/plain", false, "text/plain"}, - {":/text_xml", "text/plain", true, "text/plain"}, - {":/text_xml", "unknown/unknown", false, "text/xml"}, - {":/text_xml", "unknown/unknown", true, "text/xml"}, - {":/text_xml", "application/unknown", false, "text/xml"}, - {":/text_xml", "application/unknown", true, "text/xml"}, - {":/text_xml", "*/*", false, "text/xml"}, - {":/text_xml", "*/*", true, "text/xml"}, - {":/text_xml", "text/xml", false, 0}, - {":/text_xml", "text/xml", true, 0}, - {":/text_xml", "application/xml", false, 0}, - {":/text_xml", "application/xml", true, 0}, - {":/text_xml", "text/html", false, 0}, - {":/text_xml", "text/html", true, 0}, - {":/text_xml", "text/xml", false, 0}, - {":/text_xml", "text/xml", true, 0}, - {":/text_xml", "application/pdf", false, 0}, - {":/text_xml", "application/pdf", true, 0}, - {":/text_xml", "application/postscript", false, 0}, - {":/text_xml", "application/postscript", true, 0}, - {":/text_xml", "application/ogg", false, 0}, - {":/text_xml", "application/ogg", true, 0}, - {":/text_xml", "video/webm", false, 0}, - {":/text_xml", "video/webm", true, 0}, - {":/text_xml", "application/x-rar-compressed", false, 0}, - {":/text_xml", "application/x-rar-compressed", true, 0}, - {":/text_xml", "application/zip", false, 0}, - {":/text_xml", "application/zip", true, 0}, - {":/text_xml", "application/x-gzip", false, 0}, - {":/text_xml", "application/x-gzip", true, 0}, - {":/text_xml", "audio/x-wave", false, 0}, - {":/text_xml", "audio/x-wave", true, 0}, - {":/text_xml", "image/webp", false, 0}, - {":/text_xml", "image/webp", true, 0}, - {":/text_xml", "image/gif", false, 0}, - {":/text_xml", "image/gif", true, 0}, - {":/text_xml", "image/png", false, 0}, - {":/text_xml", "image/png", true, 0}, - {":/text_xml", "image/jpeg", false, 0}, - {":/text_xml", "image/jpeg", true, 0}, - {":/text_xml", "image/bmp", false, 0}, - {":/text_xml", "image/bmp", true, 0}, - {":/text_xml", "image/vnd.microsoft.icon", false, 0}, - {":/text_xml", "image/vnd.microsoft.icon", true, 0}, - {":/text_xml", "application/rdf+xml", false, 0}, - {":/text_xml", "application/rdf+xml", true, 0}, - {":/text_xml", "application/rss+xml", false, 0}, - {":/text_xml", "application/rss+xml", true, 0}, - {":/text_xml", "application/atom+xml", false, 0}, - {":/text_xml", "application/atom+xml", true, 0}, - {":/video_webm", "text/plain", false, "video/webm"}, - {":/video_webm", "text/plain", true, "video/webm"}, - {":/video_webm", "unknown/unknown", false, "video/webm"}, - {":/video_webm", "unknown/unknown", true, "video/webm"}, - {":/video_webm", "application/unknown", false, "video/webm"}, - {":/video_webm", "application/unknown", true, "video/webm"}, - {":/video_webm", "*/*", false, "video/webm"}, - {":/video_webm", "*/*", true, "video/webm"}, - {":/video_webm", "text/xml", false, 0}, - {":/video_webm", "text/xml", true, 0}, - {":/video_webm", "application/xml", false, 0}, - {":/video_webm", "application/xml", true, 0}, - {":/video_webm", "text/html", false, 0}, - {":/video_webm", "text/html", true, 0}, - {":/video_webm", "text/xml", false, 0}, - {":/video_webm", "text/xml", true, 0}, - {":/video_webm", "application/pdf", false, 0}, - {":/video_webm", "application/pdf", true, 0}, - {":/video_webm", "application/postscript", false, 0}, - {":/video_webm", "application/postscript", true, 0}, - {":/video_webm", "application/ogg", false, 0}, - {":/video_webm", "application/ogg", true, 0}, - {":/video_webm", "video/webm", false, 0}, - {":/video_webm", "video/webm", true, 0}, - {":/video_webm", "application/x-rar-compressed", false, 0}, - {":/video_webm", "application/x-rar-compressed", true, 0}, - {":/video_webm", "application/zip", false, 0}, - {":/video_webm", "application/zip", true, 0}, - {":/video_webm", "application/x-gzip", false, 0}, - {":/video_webm", "application/x-gzip", true, 0}, - {":/video_webm", "audio/x-wave", false, 0}, - {":/video_webm", "audio/x-wave", true, 0}, - {":/video_webm", "image/webp", false, 0}, - {":/video_webm", "image/webp", true, 0}, - {":/video_webm", "image/gif", false, 0}, - {":/video_webm", "image/gif", true, 0}, - {":/video_webm", "image/png", false, 0}, - {":/video_webm", "image/png", true, 0}, - {":/video_webm", "image/jpeg", false, 0}, - {":/video_webm", "image/jpeg", true, 0}, - {":/video_webm", "image/bmp", false, 0}, - {":/video_webm", "image/bmp", true, 0}, - {":/video_webm", "image/vnd.microsoft.icon", false, 0}, - {":/video_webm", "image/vnd.microsoft.icon", true, 0}, - {":/video_webm", "application/rdf+xml", false, 0}, - {":/video_webm", "application/rdf+xml", true, 0}, - {":/video_webm", "application/rss+xml", false, 0}, - {":/video_webm", "application/rss+xml", true, 0}, - {":/video_webm", "application/atom+xml", false, 0}, - {":/video_webm", "application/atom+xml", true, 0} -}; -static const size_t testListSize = sizeof(testList) / sizeof(testList[0]); - -#endif // TestData_h diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources.qrc b/Source/WebKit/qt/tests/MIMESniffing/resources.qrc deleted file mode 100644 index b4afb321e..000000000 --- a/Source/WebKit/qt/tests/MIMESniffing/resources.qrc +++ /dev/null @@ -1,23 +0,0 @@ - - - resources/application_atom+xml - resources/application_ogg - resources/application_pdf - resources/application_postscript - resources/application_rdf+xml - resources/application_rss+xml - resources/application_x-gzip - resources/application_x-rar-compressed - resources/application_zip - resources/audio_x-wave - resources/image_bmp - resources/image_gif - resources/image_jpeg - resources/image_png - resources/image_vnd.microsoft.icon - resources/image_webp - resources/text_html - resources/text_xml - resources/video_webm - - diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/application_atom+xml b/Source/WebKit/qt/tests/MIMESniffing/resources/application_atom+xml deleted file mode 100644 index 54086a7be..000000000 --- a/Source/WebKit/qt/tests/MIMESniffing/resources/application_atom+xml +++ /dev/null @@ -1,17 +0,0 @@ - - - Example Feed - - 2003-12-13T18:30:02Z - - John Doe - - urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 - - Atom-Powered Robots Run Amok - - urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a - 2003-12-13T18:30:02Z - Some text. - - diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/application_ogg b/Source/WebKit/qt/tests/MIMESniffing/resources/application_ogg deleted file mode 100644 index b9cc1b291..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/application_ogg and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/application_pdf b/Source/WebKit/qt/tests/MIMESniffing/resources/application_pdf deleted file mode 100644 index 7f8996f6a..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/application_pdf and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/application_postscript b/Source/WebKit/qt/tests/MIMESniffing/resources/application_postscript deleted file mode 100644 index c4b9ae6cb..000000000 --- a/Source/WebKit/qt/tests/MIMESniffing/resources/application_postscript +++ /dev/null @@ -1,137 +0,0 @@ -%!PS-Adobe-2.0 EPSF-1.2 -%%Creator: HiJaak 2.1 -%%CreationDate: 12/29/93 13:52:08 -%%BoundingBox:126 216 486 576 -%%EndComments -/ld {load def} bind def -/s /stroke ld /f /fill ld /m /moveto ld /l /lineto ld /c /curveto ld /rgb {255 div 3 1 roll 255 div 3 1 roll 255 div 3 1 roll setrgbcolor} def -126 216 translate -360.0000 360.0000 scale -/picstr 124 string def -124 124 8 [124 0 0 -124 0 124] {currentfile picstr readhexstring pop} image -65656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565ADADADADADADADADADADADADADADADADADADADADADADADADADADADADADADAD1B1B1B1B1B1B1B1B1B1BFF -65656565656565656565656565656565656565656565656565656565656565006565656565006565656500656565656565000000656565656565656565656565656565656565656565656565656565656565ADADAD00ADADAD000000ADAD00ADADADADAD00AD00ADADADAD00ADADADAD00000000001B1B001B1B1BFF -65656565656565656565656565656565656565656565656565656565656565000065656500006565650065006565656500656565006565656565656565656565656565656565656565656565656565656565ADADAD00ADAD00ADADAD00ADAD00ADADAD00ADAD0000ADADAD00ADADADAD001B1B1B1B001B001B1B1BFF -65656565656565656565656565656565656565656565656565656565656565000065656500006565650065006565650065656565650065656565656565656565656565656565656565656565656565656565ADADAD00AD00ADADADADADADAD00ADADAD00ADAD00AD00ADAD00ADADADAD001B1B1B1B001B001B1B1BFF -65656565656565656565656565656565656565656565656565656565656565006500650065006565650065006565650065656565656565656565656565656565656565656565656565656565656565656565ADADAD00AD00ADADADADADADADAD00AD00ADADAD00AD00ADAD00ADADADAD00000000001B1B001B1B1BFF -65656565656565656565656565656565656565656565656565656565656565006500650065006565006565650065650065656500000065656565656565656565656565656565656565656565656565656565ADADAD00AD00ADADADADADADADADAD00ADADADAD00ADAD00AD00ADADADAD001B1B1B1B001B001B1B1BFF -65656565656565656565656565656565656565656565656565656565656565006500650065006565000000000065650065656565650065656565656565656565656565656565656565656565656565656565ADADAD00AD00ADADADADADADADADAD00ADADADAD00ADAD00AD00ADADADAD001B1B1B1B001B001B1B1BFF -65656565656565656565656565656565656565656565656565656565656565006565006565006500656565656500656500656565006565656565656565656565656565656565656565656565656565656565ADADAD00ADAD00ADADAD00ADADADAD00ADADADAD00ADADAD0000ADADADAD001B1B1B1B001B001B1B1BFF -65656565656565656565656565656565656565656565656565656565656565006565006565006500656565656500656565000000656565656565656565656565656565656565656565656565656565656565ADADAD00ADADAD000000ADADADADAD00ADADADAD00ADADADAD00ADADADAD00000000001B1B00000000FF -65656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565ADADAD00ADADADADADADADADADADADADADADADADADADADADADADADADADADAD1B1B1B1B1B1B1B1B1B1BFF -65656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565ADADAD00ADADADADADADADADADADADADADADADADADADADADADADADADADADAD1B1B1B1B1B1B1B1B1B1BFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDC0000DC0000000000DC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292000000009292000000000092920000929200009292929292ADADADAD00000000ADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDC0000DC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929200009292000092000092920000920000929200009292929292ADADAD0000ADAD0000ADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC00DCDC00DCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292920000929292929292000092920000920000009200009292929292ADAD0000ADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC00000000DCDC0000000000DC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292920000929292929292000092920000920000009200009292929292ADAD0000ADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292920000929200000092000000000092920000920000009292929292ADAD0000ADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292920000929292000092000092000092920000920000009292929292ADAD0000ADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929200009292000092000092920000920000929200009292929292ADADAD0000ADAD0000ADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDCDC0000000000DC000000000000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292000000009292000092929200000000929200009292929292ADADADAD00000000ADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00000000004A4A00000000004A00000000004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDC0000DCDC0000DC0000000000DC0000DCDCDCDCDCDCDCDCDCDCDC00000065656500000065FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A4A00004A00004A4A4A4A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDC0000DCDC0000DC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDC00000065656500000065FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A4A00004A00004A4A4A4A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDC00DCDC00DCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDC00000000650000000065FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A4A00004A00000000004A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDC00000000DCDC0000000000DC0000DCDCDCDCDCDCDCDCDCDCDC00000000650000000065FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00000000004A4A00004A4A4A4A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDC00006500650065000065FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A00004A4A00004A4A4A4A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDC00006500000065000065FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A4A00004A00004A4A4A4A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDC00006500000065000065FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A4A4A000000000000004A00000000004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDC0000DCDCDC0000000000DC000000000000DCDCDCDCDCDCDC00006565006565000065FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A00000000004A4A4A4A0000004A4A4A00000000004A4A4A4A004A4A4A4A4A00000000004A00000000004A00000000004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A004A4A4A4A004A4A004A4A4A004A4A4A4A004A4A4A4A4A4A004A4A4A4A4A004A4A4A4A4A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A004A4A4A4A004A004A4A4A4A4A004A4A4A004A4A4A4A4A4A004A4A4A4A4A004A4A4A4A4A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A00000000004A4A004A4A4A4A4A004A4A4A004A4A4A4A4A4A004A4A4A4A4A00000000004A000000004A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A004A4A4A4A004A004A4A4A4A4A004A4A4A004A4A4A4A4A4A004A4A4A4A4A004A4A4A4A4A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A004A4A4A4A004A004A4A4A4A4A004A4A4A004A4A4A4A4A4A004A4A4A4A4A004A4A4A4A4A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A004A4A4A4A004A4A004A4A4A004A4A4A4A004A4A4A4A4A4A004A4A4A4A4A004A4A4A4A4A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A00000000004A4A4A4A0000004A4A4A4A4A004A4A4A4A4A4A00000000004A00000000004A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF -showpage - \ No newline at end of file diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/application_rdf+xml b/Source/WebKit/qt/tests/MIMESniffing/resources/application_rdf+xml deleted file mode 100644 index e21414543..000000000 --- a/Source/WebKit/qt/tests/MIMESniffing/resources/application_rdf+xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - XML.com - http://xml.com/pub - - XML.com features a rich mix of information and services - for the XML community. - - - - - - - - - - - - - - - XML.com - http://www.xml.com - http://xml.com/universal/images/xml_tiny.gif - - - - Processing Inclusions with XSLT - http://xml.com/pub/2000/08/09/xslt/xslt.html - - Processing document inclusions with general XML tools can be - problematic. This article proposes a way of preserving inclusion - information through SAX-based processing. - - - - - Putting RDF to Work - http://xml.com/pub/2000/08/09/rdfdb/index.html - - Tool and API support for the Resource Description Framework - is slowly coming of age. Edd Dumbill takes a look at RDFDB, - one of the most exciting new RDF toolkits. - - - - diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/application_rss+xml b/Source/WebKit/qt/tests/MIMESniffing/resources/application_rss+xml deleted file mode 100644 index 3537c41c5..000000000 --- a/Source/WebKit/qt/tests/MIMESniffing/resources/application_rss+xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - -Folha.com - Ambiente - Principal -http://redir.folha.com.br/redir/online/ambiente/rss091/*http://www1.folha.uol.com.br/ambiente/ -Primeiro jornal em tempo real em língua portuguesa -pt-br -Copyright Folha.com. Todos os direitos reservados. -http://redir.folha.com.br/redir/online/ambiente/rss091/*http://www1.folha.uol.com.br/folha/conheca/arquivo_e_copyright.shtml -webmaster@grupofolha.com.br (Webmaster Folha.com) - - -Folha.com - Ambiente - Principal -http://www1.folha.uol.com.br/folha/images/lgo-folha_com-88x31.gif -http://redir.folha.com.br/redir/online/ambiente/rss091/*http://www1.folha.uol.com.br/ambiente/ -88 -31 -Primeiro jornal em tempo real em língua portuguesa - - - -Nasa dimensiona danos da seca na Amazônia em 2,4 mi de km2 -http://redir.folha.com.br/redir/online/ambiente/rss091/*http://www1.folha.uol.com.br/ambiente/895526-nasa-dimensiona-danos-da-seca-na-amazonia-em-24-mi-de-km2.shtml - -Os satélites da Nasa (agência espacial americana) forneceram material para uma análise dos estragos provocados pela <a href="http://www1.folha.uol.com.br/ambiente/870588-amazonia-teve-a-pior-seca-dos-ultimos-cem-anos.shtml">pior seca a atingir a Amazônia em 2010</a>. -Pela tomada aérea, estima-se que foram 2,5 milhões de quilômetros quadrados afetados --pouco menos da metade do ecossistema amazônico. -<table class="articleGraphic"> -<tr> -<td rowspan="3" class="articleGraphicSpace"></td> -<td class="articleGraphicCredit">Universidade de Boston/Nasa</td> -<td rowspan="3" class="articleGraphicSpace"></td> -</tr> -<tr> -<td class="articleGraphicImage"><img src="http://f.i.uol.com.br/folha/ambiente/images/11090120.jpeg" alt="Área (vermelho) mostra redução do índice do verdor, onde a vegetação ficou menos verde e mais seca" border="0" /></td> -</tr> -<tr> -<td class="articleGraphicCaption">Área (vermelho) mostra redução do índice do verdor, onde a vegetação ficou menos verde e mais seca</td> -</tr> -</table> -<a href="http://redir.folha.com.br/redir/online/ambiente/rss091/*http://www1.folha.uol.com.br/ambiente/895526-nasa-dimensiona-danos-da-seca-na-amazonia-em-24-mi-de-km2.shtml">Leia mais</a> (29/03/2011 - 18h04) -29 Mar 2011 18:04:00 -0300 - - - diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/application_x-gzip b/Source/WebKit/qt/tests/MIMESniffing/resources/application_x-gzip deleted file mode 100644 index a5e7d3131..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/application_x-gzip and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/application_x-rar-compressed b/Source/WebKit/qt/tests/MIMESniffing/resources/application_x-rar-compressed deleted file mode 100644 index d9cb6ae25..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/application_x-rar-compressed and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/application_zip b/Source/WebKit/qt/tests/MIMESniffing/resources/application_zip deleted file mode 100644 index 8aec52fb2..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/application_zip and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/audio_x-wave b/Source/WebKit/qt/tests/MIMESniffing/resources/audio_x-wave deleted file mode 100644 index a0f9b85ff..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/audio_x-wave and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/image_bmp b/Source/WebKit/qt/tests/MIMESniffing/resources/image_bmp deleted file mode 100644 index b61d3688f..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/image_bmp and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/image_gif b/Source/WebKit/qt/tests/MIMESniffing/resources/image_gif deleted file mode 100644 index 32b1ea23f..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/image_gif and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/image_jpeg b/Source/WebKit/qt/tests/MIMESniffing/resources/image_jpeg deleted file mode 100644 index 187457663..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/image_jpeg and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/image_png b/Source/WebKit/qt/tests/MIMESniffing/resources/image_png deleted file mode 100644 index bef59c785..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/image_png and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/image_vnd.microsoft.icon b/Source/WebKit/qt/tests/MIMESniffing/resources/image_vnd.microsoft.icon deleted file mode 100644 index 58921b8bb..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/image_vnd.microsoft.icon and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/image_webp b/Source/WebKit/qt/tests/MIMESniffing/resources/image_webp deleted file mode 100644 index 0da983e2c..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/image_webp and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/text_html b/Source/WebKit/qt/tests/MIMESniffing/resources/text_html deleted file mode 100644 index 21eeee345..000000000 --- a/Source/WebKit/qt/tests/MIMESniffing/resources/text_html +++ /dev/null @@ -1,3 +0,0 @@ - - -

It works!

\ No newline at end of file diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/text_xml b/Source/WebKit/qt/tests/MIMESniffing/resources/text_xml deleted file mode 100644 index 38a9fe548..000000000 --- a/Source/WebKit/qt/tests/MIMESniffing/resources/text_xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - Empire Burlesque - Bob Dylan - USA - Columbia - 10.90 - 1985 - - - Unchain my heart - Joe Cocker - USA - EMI - 8.20 - 1987 - - diff --git a/Source/WebKit/qt/tests/MIMESniffing/resources/video_webm b/Source/WebKit/qt/tests/MIMESniffing/resources/video_webm deleted file mode 100644 index 95d5031a8..000000000 Binary files a/Source/WebKit/qt/tests/MIMESniffing/resources/video_webm and /dev/null differ diff --git a/Source/WebKit/qt/tests/MIMESniffing/tst_MIMESniffing.cpp b/Source/WebKit/qt/tests/MIMESniffing/tst_MIMESniffing.cpp deleted file mode 100644 index 8c5417f26..000000000 --- a/Source/WebKit/qt/tests/MIMESniffing/tst_MIMESniffing.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" -#include "MIMESniffing.h" - -#include "TestData.h" - -#include -#include -#include - -class tst_MIMESniffing : public QObject { - Q_OBJECT - -public: - tst_MIMESniffing(); - -private Q_SLOTS: - void testCase1(); -}; - -tst_MIMESniffing::tst_MIMESniffing() -{ -} - -static inline const char* errorText(const TestData& data, const char* sniffedType) -{ - return QString("file: %1, advertised: %2, image: %3. sniffed mime type was expected to be \"%4\" but instead was \"%5\"").arg(data.file).arg(data.advertisedType).arg(data.isImage).arg(data.sniffedType).arg(sniffedType).toLatin1(); -} - -void tst_MIMESniffing::testCase1() -{ - - for (int i = 0; i < testListSize; ++i) { - QFile file(testList[i].file); - QVERIFY2(file.open(QIODevice::ReadOnly), QString("unable to open file %1").arg(file.fileName()).toLatin1()); - - MIMESniffer sniffer(testList[i].advertisedType, testList[i].isImage); - QByteArray data = file.peek(sniffer.dataSize()); - - const char* sniffedType = sniffer.sniff(data.constData(), data.size()); - - QVERIFY2(!(sniffedType || testList[i].sniffedType) || (sniffedType && testList[i].sniffedType), errorText(testList[i], sniffedType)); - - if (sniffedType) - QVERIFY2(!strcmp(sniffedType, testList[i].sniffedType), errorText(testList[i], sniffedType)); - - } - - QVERIFY2(true, "Failure"); -} - -QTEST_APPLESS_MAIN(tst_MIMESniffing); - -#include "tst_MIMESniffing.moc" diff --git a/Source/WebKit/qt/tests/benchmarks/loading/tst_loading.cpp b/Source/WebKit/qt/tests/benchmarks/loading/tst_loading.cpp deleted file mode 100644 index 2ebf3775d..000000000 --- a/Source/WebKit/qt/tests/benchmarks/loading/tst_loading.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2009 Holger Hans Peter Freyther - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef QT_NO_BEARERMANAGEMENT -#include -#endif - -#include - -#include -#include -#include - -#include "util.h" - -class tst_Loading : public QObject -{ - Q_OBJECT - -public: - -public Q_SLOTS: - void init(); - void cleanup(); - -private Q_SLOTS: - void load_data(); - void load(); - -private: -#ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager m_manager; -#endif - QWebView* m_view; - QWebPage* m_page; -}; - -void tst_Loading::init() -{ - m_view = new QWebView; - m_page = m_view->page(); - - QSize viewportSize(1024, 768); - m_view->setFixedSize(viewportSize); - m_page->setViewportSize(viewportSize); -} - -void tst_Loading::cleanup() -{ - delete m_view; -} - -void tst_Loading::load_data() -{ - QTest::addColumn("url"); - QTest::newRow("amazon") << QUrl("http://www.amazon.com"); - QTest::newRow("kde") << QUrl("http://www.kde.org"); - QTest::newRow("apple") << QUrl("http://www.apple.com"); -} - -void tst_Loading::load() -{ - QFETCH(QUrl, url); - -#ifndef QT_NO_BEARERMANAGEMENT - if (!m_manager.isOnline()) - W_QSKIP("This test requires an active network connection", SkipSingle); -#endif - - QBENCHMARK { - m_view->load(url); - - // really wait for loading, painting is in another test - ::waitForSignal(m_view, SIGNAL(loadFinished(bool)), 0); - } -} - -QTEST_MAIN(tst_Loading) -#include "tst_loading.moc" diff --git a/Source/WebKit/qt/tests/benchmarks/painting/tst_painting.cpp b/Source/WebKit/qt/tests/benchmarks/painting/tst_painting.cpp deleted file mode 100644 index 8abba4bad..000000000 --- a/Source/WebKit/qt/tests/benchmarks/painting/tst_painting.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2009 Holger Hans Peter Freyther - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef QT_NO_BEARERMANAGEMENT -#include -#endif - -#include - -#include -#include -#include -#include - -#include "util.h" - -class tst_Painting : public QObject -{ - Q_OBJECT - -public: - -public Q_SLOTS: - void init(); - void cleanup(); - -private Q_SLOTS: - void paint_data(); - void paint(); - void textAreas(); - -private: -#ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager m_manager; -#endif - QWebView* m_view; - QWebPage* m_page; -}; - -void tst_Painting::init() -{ - m_view = new QWebView; - m_page = m_view->page(); - - QSize viewportSize(1024, 768); - m_view->setFixedSize(viewportSize); - m_page->setViewportSize(viewportSize); -} - -void tst_Painting::cleanup() -{ - delete m_view; -} - -void tst_Painting::paint_data() -{ - QTest::addColumn("url"); - QTest::newRow("amazon") << QUrl("http://www.amazon.com"); -} - -void tst_Painting::paint() -{ - QFETCH(QUrl, url); - -#ifndef QT_NO_BEARERMANAGEMENT - if (!m_manager.isOnline()) - W_QSKIP("This test requires an active network connection", SkipSingle); -#endif - - m_view->load(url); - ::waitForSignal(m_view, SIGNAL(loadFinished(bool)), 0); - - /* force a layout */ - QWebFrame* mainFrame = m_page->mainFrame(); - mainFrame->toPlainText(); - - QPixmap pixmap(m_page->viewportSize()); - QBENCHMARK { - QPainter painter(&pixmap); - mainFrame->render(&painter, QRect(QPoint(0, 0), m_page->viewportSize())); - painter.end(); - } -} - -void tst_Painting::textAreas() -{ - m_view->load(QUrl("data:text/html;")); - ::waitForSignal(m_view, SIGNAL(loadFinished(bool)), 0); - - QWebElement bodyElement = m_page->mainFrame()->findFirstElement("body"); - - int count = 100; - while (count--) { - QString markup(""); - bodyElement.appendInside(markup); - } - - /* force a layout */ - QWebFrame* mainFrame = m_page->mainFrame(); - mainFrame->toPlainText(); - - QPixmap pixmap(mainFrame->contentsSize()); - QBENCHMARK { - QPainter painter(&pixmap); - mainFrame->render(&painter, QRect(QPoint(0, 0), mainFrame->contentsSize())); - painter.end(); - } -} - -QTEST_MAIN(tst_Painting) -#include "tst_painting.moc" diff --git a/Source/WebKit/qt/tests/benchmarks/webgl/10000_triangles.html b/Source/WebKit/qt/tests/benchmarks/webgl/10000_triangles.html deleted file mode 100644 index fd061aa27..000000000 --- a/Source/WebKit/qt/tests/benchmarks/webgl/10000_triangles.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - diff --git a/Source/WebKit/qt/tests/benchmarks/webgl/tst_webgl.cpp b/Source/WebKit/qt/tests/benchmarks/webgl/tst_webgl.cpp deleted file mode 100644 index 14ff1a80f..000000000 --- a/Source/WebKit/qt/tests/benchmarks/webgl/tst_webgl.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - - -#include "../../util.h" -#include -#include -#include -#include -#include -#include - -class GraphicsView; - -class tst_WebGlPerformance : public QObject { - Q_OBJECT - -private Q_SLOTS: - void init(); - void cleanup(); - - void benchSoftwareFallbackRgb16(); - void benchSoftwareFallbackRgb32(); - void benchSoftwareFallbackArgb32(); - void benchSoftwareFallbackArgb32Premultiplied(); - -private: - void benchmarkFrameRenderingOnImage(QImage::Format); - - QScopedPointer m_view; -}; - -class GraphicsView : public QGraphicsView { -public: - GraphicsView(); - QGraphicsWebView* m_webView; - -protected: - void resizeEvent(QResizeEvent*); -}; - -GraphicsView::GraphicsView() -{ - QGraphicsScene* const scene = new QGraphicsScene(this); - setScene(scene); - - m_webView = new QGraphicsWebView; - scene->addItem(m_webView); - - m_webView->page()->settings()->setAttribute(QWebSettings::WebGLEnabled, true); - - resize(800, 600); - setFrameShape(QFrame::NoFrame); - setViewport(new QGLWidget); -} - -void GraphicsView::resizeEvent(QResizeEvent* event) -{ - QGraphicsView::resizeEvent(event); - QRectF rect(QPoint(0, 0), event->size()); - m_webView->setGeometry(rect); - scene()->setSceneRect(rect); -} - -void tst_WebGlPerformance::init() -{ - m_view.reset(new GraphicsView); - m_view->showMaximized(); - QTest::qWaitForWindowShown(m_view.data()); -} - -void tst_WebGlPerformance::cleanup() -{ - m_view.reset(); -} - -void tst_WebGlPerformance::benchSoftwareFallbackRgb16() -{ - benchmarkFrameRenderingOnImage(QImage::Format_RGB16); -} - -void tst_WebGlPerformance::benchSoftwareFallbackRgb32() -{ - benchmarkFrameRenderingOnImage(QImage::Format_RGB32); -} - -void tst_WebGlPerformance::benchSoftwareFallbackArgb32() -{ - benchmarkFrameRenderingOnImage(QImage::Format_ARGB32); -} - -void tst_WebGlPerformance::benchSoftwareFallbackArgb32Premultiplied() -{ - benchmarkFrameRenderingOnImage(QImage::Format_ARGB32_Premultiplied); -} - -void tst_WebGlPerformance::benchmarkFrameRenderingOnImage(QImage::Format format) -{ - m_view->m_webView->load(QUrl(QLatin1String("qrc:///testcases/10000_triangles.html"))); - const bool pageLoaded = waitForSignal(m_view->m_webView, SIGNAL(loadFinished(bool))); - Q_ASSERT(pageLoaded); - Q_UNUSED(pageLoaded); - - QImage target(m_view->size(), format); - QBENCHMARK { - QPainter painter(&target); - m_view->render(&painter); - painter.end(); - } -} - -QTEST_MAIN(tst_WebGlPerformance) - -#include "tst_webgl.moc" diff --git a/Source/WebKit/qt/tests/benchmarks/webgl/tst_webgl.qrc b/Source/WebKit/qt/tests/benchmarks/webgl/tst_webgl.qrc deleted file mode 100644 index b849448d7..000000000 --- a/Source/WebKit/qt/tests/benchmarks/webgl/tst_webgl.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - 10000_triangles.html - - diff --git a/Source/WebKit/qt/tests/hybridPixmap/test.html b/Source/WebKit/qt/tests/hybridPixmap/test.html deleted file mode 100644 index a6cbed1fb..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/test.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - diff --git a/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.cpp b/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.cpp deleted file mode 100644 index 84891580a..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "../util.h" - -#include "widget.h" -#include - -class tst_hybridPixmap : public QObject { - Q_OBJECT - -public: - tst_hybridPixmap(QObject* o = 0) : QObject(o) {} - -public Q_SLOTS: - void init() - { - } - - void cleanup() - { - } - -private Q_SLOTS: - void hybridPixmap() - { - Widget widget; - widget.show(); - widget.start(); - waitForSignal(&widget, SIGNAL(testComplete())); - } -}; - -QTEST_MAIN(tst_hybridPixmap) - -#include diff --git a/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.qrc b/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.qrc deleted file mode 100644 index 5fd47e32d..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - test.html - - diff --git a/Source/WebKit/qt/tests/hybridPixmap/widget.cpp b/Source/WebKit/qt/tests/hybridPixmap/widget.cpp deleted file mode 100644 index 6c4d2cd49..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/widget.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "widget.h" - -#include "qwebelement.h" -#include "qwebframe.h" -#include "ui_widget.h" -#include -#include - -Widget::Widget(QWidget* parent) : - QWidget(parent), - ui(new Ui::Widget), - abcFilledImage(32, 32, QImage::Format_ARGB32) -{ - ui->setupUi(this); - abcFilledImage.fill(qRgba(0xaa, 0xbb, 0xcc, 0xff)); -} - -void Widget::refreshJS() -{ - ui->webView->page()->mainFrame()->addToJavaScriptWindowObject("myWidget", this); -} -void Widget::start() -{ - ui->webView->load(QUrl("qrc:///test.html")); - connect(ui->webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(refreshJS())); - ui->webView->page()->mainFrame()->addToJavaScriptWindowObject("myWidget", this); -} - -void Widget::completeTest() -{ - QCOMPARE(ui->lbl1->pixmap()->size(), ui->lbl2->size()); - QCOMPARE(ui->lbl3->size(), ui->lbl4->pixmap()->size()); - QCOMPARE(ui->lbl2->size().width(), ui->webView->page()->mainFrame()->findFirstElement("#img1").evaluateJavaScript("this.width").toInt()); - QCOMPARE(ui->lbl3->size().width(), ui->webView->page()->mainFrame()->findFirstElement("#img2").evaluateJavaScript("this.width").toInt()); - emit testComplete(); -} - -void Widget::setPixmap(const QPixmap& p) -{ - ui->lbl1->setPixmap(p); -} -QPixmap Widget::pixmap() const -{ - QPixmap px(ui->lbl3->size()); - { - QPainter p(&px); - ui->lbl3->render(&p); - } - return px; -} -void Widget::setImage(const QImage& img) -{ - ui->lbl4->setPixmap(QPixmap::fromImage(img)); -} - -QImage Widget::image() const -{ - QImage img(ui->lbl2->size(), QImage::Format_ARGB32); - { - QPainter p(&img); - ui->lbl2->render(&p); - } - return img; -} - -QImage Widget::abcImage(int format) -{ - return abcFilledImage.convertToFormat(static_cast(format)); -} - -Widget::~Widget() -{ - delete ui; -} - -void Widget::changeEvent(QEvent* e) -{ - QWidget::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} -void Widget::compare(const QVariant& a, const QVariant& b) -{ - QCOMPARE(a, b); -} - -void Widget::imageSlot(const QImage& img) -{ - QCOMPARE(img.size(), ui->lbl3->size()); - emit pixmapSignal(QPixmap::fromImage(img)); -} - -void Widget::pixmapSlot(const QPixmap& pxm) -{ - QCOMPARE(pxm.size(), ui->lbl2->size()); - emit imageSignal(ui->lbl4->pixmap()->toImage()); -} - -void Widget::randomSlot(const QPixmap& pxm) -{ - QVERIFY(pxm.isNull()); -} diff --git a/Source/WebKit/qt/tests/hybridPixmap/widget.h b/Source/WebKit/qt/tests/hybridPixmap/widget.h deleted file mode 100644 index b78df8b5e..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/widget.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef widget_h -#define widget_h - -#include -#include -#include -#include "qwebview.h" - -typedef QWebView WebView; - -QT_BEGIN_NAMESPACE -namespace Ui { -class Widget; -} -QT_END_NAMESPACE - -class Widget : public QWidget { - Q_OBJECT - Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) - Q_PROPERTY(QImage image READ image WRITE setImage) - -public: - Widget(QWidget* parent = 0); - ~Widget(); - void setPixmap(const QPixmap&); - QPixmap pixmap() const; - void setImage(const QImage&); - QImage image() const; - -private Q_SLOTS: - void refreshJS(); - -public Q_SLOTS: - void completeTest(); - void start(); - void compare(const QVariant& a, const QVariant& b); - void imageSlot(const QImage&); - void pixmapSlot(const QPixmap&); - void randomSlot(const QPixmap&); - QImage abcImage(int format); - -Q_SIGNALS: - void testComplete(); - void imageSignal(const QImage&); - void pixmapSignal(const QPixmap&); - -protected: - void changeEvent(QEvent* e); - -private: - Ui::Widget* ui; - QImage abcFilledImage; -}; - -#endif // widget_h diff --git a/Source/WebKit/qt/tests/hybridPixmap/widget.ui b/Source/WebKit/qt/tests/hybridPixmap/widget.ui deleted file mode 100644 index 272d6a71f..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/widget.ui +++ /dev/null @@ -1,95 +0,0 @@ - - - Widget - - - - 0 - 0 - 600 - 400 - - - - Widget - - - - - - - about:blank - - - - - - - - - - - - - - - - - - 120 - 30 - - - - - 120 - 30 - - - - Image from Qt to HTML - - - - - - - Pixmap from Qt to HTML - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - WebView - QWidget -
widget.h
-
-
- - -
diff --git a/Source/WebKit/qt/tests/keyeddecoderqt/tst_keyeddecoderqt.cpp b/Source/WebKit/qt/tests/keyeddecoderqt/tst_keyeddecoderqt.cpp deleted file mode 100644 index 515328028..000000000 --- a/Source/WebKit/qt/tests/keyeddecoderqt/tst_keyeddecoderqt.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (C) 2016 Konstantin Tokarev - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "KeyedDecoderQt.h" -#include "KeyedEncoderQt.h" - -#include - -using WebCore::KeyedDecoder; -using WebCore::KeyedDecoderQt; - -static QVariantMap testData() -{ - return { - { "string", QStringLiteral("привет") }, - { "array", QVariantList { - QVariantMap { - { "baz", QVariantMap { { "int", 1 } } }, - { "string", "1" }, - }, - QVariantMap { - { "baz", QVariantMap { { "int", 2 } } }, - { "string", "2" }, - }, - QVariantMap { - { "baz", QVariantMap { { "int", 3 } } }, - { "string", "3" }, - }, - } }, - { "foo", QVariantMap { - { "begin", "beginFoo" }, - { "bar", QVariantMap { { "float", 2.5f } } }, - { "end", "endFoo" }, - } }, - { "bool", true }, - { "float", 1.5 }, - { "bytes", QByteArray::fromRawData("\0\0\1\0\0", 5) }, - { "longlong", 1234567890123456789ll } - }; -} - -static std::unique_ptr makeDecoder() -{ - return std::make_unique(testData()); -} - -class tst_KeyedDecoderQt : public QObject { - Q_OBJECT - -private slots: - void stringValue() - { - WTF::String s; - KeyedDecoderQt decoder(testData()); - QVERIFY(decoder.decodeString("string", s)); - QCOMPARE(s, WTF::String::fromUTF8("привет")); - } - - void boolValue() - { - bool b; - KeyedDecoderQt decoder(testData()); - QVERIFY(decoder.decodeBool("bool", b)); - QCOMPARE(b, true); - } - - void floatValue() - { - float f; - KeyedDecoderQt decoder(testData()); - QVERIFY(decoder.decodeFloat("float", f)); - QCOMPARE(f, 1.5f); - } - - void bytesValue() - { - const uint8_t* bytes; - size_t size; - KeyedDecoderQt decoder(testData()); - QVERIFY(decoder.decodeBytes("bytes", bytes, size)); - - const uint8_t expected[] = { 0, 0, 1, 0, 0 }; - QCOMPARE(size, (size_t)5); - QCOMPARE(bytes[0], (uint8_t)0); - QCOMPARE(bytes[1], (uint8_t)0); - QCOMPARE(bytes[2], (uint8_t)1); - QCOMPARE(bytes[3], (uint8_t)0); - QCOMPARE(bytes[4], (uint8_t)0); - } - - void int64Value() - { - int64_t i; - KeyedDecoderQt decoder(testData()); - QVERIFY(decoder.decodeInt64("longlong", i)); - QCOMPARE(i, (int64_t)1234567890123456789ll); - } - - void missingValue() - { - WTF::String s; - KeyedDecoderQt decoder(testData()); - QVERIFY(!decoder.decodeString("foobar", s)); - QCOMPARE(s, WTF::String()); - } - - void wrongType1() - { - float f = 1.0; - KeyedDecoderQt decoder(testData()); - QVERIFY(!decoder.decodeFloat("string", f)); - QCOMPARE(f, 1.0); - } - - void wrongType2() - { - WTF::String s; - KeyedDecoderQt decoder(testData()); - QVERIFY(!decoder.decodeString("array", s)); - QVERIFY(!decoder.decodeString("foo", s)); - } - - void object() - { - struct Foo { - WTF::String begin; - WTF::String end; - float f; - } foo; - - KeyedDecoderQt decoder(testData()); - decoder.decodeObject("foo", foo, [&](KeyedDecoder& d1, Foo& foo) -> bool { - if (!d1.decodeString("begin", foo.begin)) - return false; - if (!d1.decodeString("end", foo.end)) - return false; - return d1.decodeObject("bar", foo, [&](KeyedDecoder& d2, Foo& foo) { - return d2.decodeFloat("float", foo.f); - }); - }); - QCOMPARE(foo.begin, WTF::String("beginFoo")); - QCOMPARE(foo.end, WTF::String("endFoo")); - QCOMPARE(foo.f, 2.5f); - } - - void array() - { - struct Foo { - WTF::String s; - int i; - }; - - WTF::Vector v; - - KeyedDecoderQt decoder(testData()); - decoder.decodeObjects("array", v, [&](KeyedDecoder& d1, Foo& foo) -> bool { - if (!d1.decodeString("string", foo.s)) - return false; - return d1.decodeObject("baz", foo, [&](KeyedDecoder& d2, Foo& foo) { - return d2.decodeInt32("int", foo.i); - }); - }); - QCOMPARE(v.size(), (size_t)3); - QCOMPARE(v[0].s, WTF::String("1")); - QCOMPARE(v[0].i, 1); - QCOMPARE(v[1].s, WTF::String("2")); - QCOMPARE(v[1].i, 2); - QCOMPARE(v[2].s, WTF::String("3")); - QCOMPARE(v[2].i, 3); - } -}; - -QTEST_GUILESS_MAIN(tst_KeyedDecoderQt) -#include "tst_keyeddecoderqt.moc" diff --git a/Source/WebKit/qt/tests/keyedencoderqt/tst_keyedencoderqt.cpp b/Source/WebKit/qt/tests/keyedencoderqt/tst_keyedencoderqt.cpp deleted file mode 100644 index a61c02059..000000000 --- a/Source/WebKit/qt/tests/keyedencoderqt/tst_keyedencoderqt.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2016 Konstantin Tokarev - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "KeyedEncoderQt.h" - -#include - -using WebCore::KeyedEncoder; -using WebCore::KeyedEncoderQt; - -class tst_KeyedEncoderQt : public QObject { - Q_OBJECT - std::unique_ptr m_encoder { nullptr }; - -private slots: - void init() - { - m_encoder.reset(new KeyedEncoderQt); - } - - void cleanup() - { - m_encoder = nullptr; - } - - void simpleValues() - { - m_encoder->encodeBool("bool", true); - const uint8_t bytes[] = { 0, 0, 1, 0, 0 }; - m_encoder->encodeBytes("bytes", bytes, 5); - m_encoder->encodeString("string", QStringLiteral("привет")); - - auto result = m_encoder->toMap(); - QCOMPARE(result["bool"].type(), QVariant::Bool); - QCOMPARE(result["bool"].toBool(), true); - QCOMPARE(result["bytes"].type(), QVariant::ByteArray); - QCOMPARE(result["bytes"].toByteArray(), QByteArray::fromRawData("\0\0\1\0\0", 5)); - QCOMPARE(result["string"].type(), QVariant::String); - QCOMPARE(result["string"].toString(), QStringLiteral("привет")); - } - - void nestedObjects() - { - struct dummy {}; - - m_encoder->encodeString("begin", "begin"); - m_encoder->encodeObject("foo", dummy(), [](KeyedEncoder& e1, dummy) { - e1.encodeString("begin", "beginFoo"); - e1.encodeObject("bar", dummy(), [](KeyedEncoder& e2, dummy) { - e2.encodeFloat("float", 1.5); - }); - e1.encodeString("end", "endFoo"); - }); - m_encoder->encodeString("end", "end"); - - QVariantMap expected = { - { "begin", "begin" }, - { "foo", QVariantMap { - { "begin", "beginFoo" }, - { "bar", QVariantMap { { "float", 1.5f } } }, - { "end", "endFoo" }, - } }, - { "end", "end" }, - }; - - QCOMPARE(m_encoder->toMap(), expected); - } - - void array() - { - QList values = { 1, 2, 3 }; - - m_encoder->encodeString("begin", "begin"); - m_encoder->encodeObjects("array", values.begin(), values.end(), - [](KeyedEncoder& e, int v) { - e.encodeUInt32("int", v); - e.encodeString("string", QString::number(v)); - }); - m_encoder->encodeString("end", "end"); - - QVariantMap expected = { - { "begin", "begin" }, - { "array", QVariantList { - QVariantMap { { "int", 1 }, { "string", "1" } }, - QVariantMap { { "int", 2 }, { "string", "2" } }, - QVariantMap { { "int", 3 }, { "string", "3" } }, - } }, - { "end", "end" }, - }; - - QCOMPARE(m_encoder->toMap(), expected); - } - - void arrayWithObjects() - { - QList values = { 1, 2, 3 }; - struct dummy {}; - - m_encoder->encodeString("begin", "begin"); - m_encoder->encodeObjects("array", values.begin(), values.end(), - [](KeyedEncoder& e1, int v) { - e1.encodeObject("foo", dummy(), [v](KeyedEncoder& e2, dummy) { - e2.encodeInt32("int", v); - }); - e1.encodeString("string", QString::number(v)); - }); - m_encoder->encodeString("end", "end"); - - QVariantMap expected = { - { "begin", "begin" }, - { "array", QVariantList { - QVariantMap { - { "foo", QVariantMap { { "int", 1 } } }, - { "string", "1" }, - }, - QVariantMap { - { "foo", QVariantMap { { "int", 2 } } }, - { "string", "2" }, - }, - QVariantMap { - { "foo", QVariantMap { { "int", 3 } } }, - { "string", "3" }, - }, - } }, - { "end", "end" }, - }; - - QCOMPARE(m_encoder->toMap(), expected); - } - -}; - -QTEST_GUILESS_MAIN(tst_KeyedEncoderQt) -#include "tst_keyedencoderqt.moc" diff --git a/Source/WebKit/qt/tests/qgraphicswebview/resources/greendiv.html b/Source/WebKit/qt/tests/qgraphicswebview/resources/greendiv.html deleted file mode 100644 index 2f7fa97ca..000000000 --- a/Source/WebKit/qt/tests/qgraphicswebview/resources/greendiv.html +++ /dev/null @@ -1,8 +0,0 @@ - -
- - diff --git a/Source/WebKit/qt/tests/qgraphicswebview/resources/input_types.html b/Source/WebKit/qt/tests/qgraphicswebview/resources/input_types.html deleted file mode 100644 index 18ab314bf..000000000 --- a/Source/WebKit/qt/tests/qgraphicswebview/resources/input_types.html +++ /dev/null @@ -1,8 +0,0 @@ - -
-
-
-
-
-
" - \ No newline at end of file diff --git a/Source/WebKit/qt/tests/qgraphicswebview/resources/pointing_right.html b/Source/WebKit/qt/tests/qgraphicswebview/resources/pointing_right.html deleted file mode 100644 index bc592fbde..000000000 --- a/Source/WebKit/qt/tests/qgraphicswebview/resources/pointing_right.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - diff --git a/Source/WebKit/qt/tests/qgraphicswebview/resources/pointing_up.html b/Source/WebKit/qt/tests/qgraphicswebview/resources/pointing_up.html deleted file mode 100644 index 474a56d3f..000000000 --- a/Source/WebKit/qt/tests/qgraphicswebview/resources/pointing_up.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - diff --git a/Source/WebKit/qt/tests/qgraphicswebview/resources/scrolltest_page.html b/Source/WebKit/qt/tests/qgraphicswebview/resources/scrolltest_page.html deleted file mode 100644 index 18fcbbebe..000000000 --- a/Source/WebKit/qt/tests/qgraphicswebview/resources/scrolltest_page.html +++ /dev/null @@ -1,6 +0,0 @@ - -Scrolling test - -
- - diff --git a/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp deleted file mode 100644 index 8417d0ef7..000000000 --- a/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp +++ /dev/null @@ -1,728 +0,0 @@ -/* - Copyright (C) 2009 Jakub Wieczorek - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "../util.h" -#include -#include -#include -#include -#include -#include -#include - -#if defined(ENABLE_WEBGL) && ENABLE_WEBGL -#include -#endif - -class tst_QGraphicsWebView : public QObject -{ - Q_OBJECT - -private Q_SLOTS: - void qgraphicswebview(); - void crashOnViewlessWebPages(); - void microFocusCoordinates(); - void focusInputTypes(); - void crashOnSetScaleBeforeSetUrl(); - void widgetsRenderingThroughCache(); - void windowResizeEvent(); - void horizontalScrollbarTest(); - -#if !(defined(USE_QT_MOBILE_THEME) && USE_QT_MOBILE_THEME) - void setPalette_data(); - void setPalette(); -#endif - void renderHints(); -#if defined(USE_TILED_BACKING_STORE) && USE_TILED_BACKING_STORE - void bug57798(); - void bug56929(); -#endif -#if defined(ENABLE_WEBGL) && ENABLE_WEBGL - void webglSoftwareFallbackVerticalOrientation(); - void webglSoftwareFallbackHorizontalOrientation(); - -private: - void compareCanvasToImage(const QUrl&, const QImage&); -#endif -}; - -void tst_QGraphicsWebView::qgraphicswebview() -{ - QGraphicsWebView item; - item.url(); - item.title(); - item.icon(); - item.zoomFactor(); - item.history(); - item.settings(); - item.page(); - item.setPage(0); - item.page(); - item.setUrl(QUrl()); - item.setZoomFactor(0); - item.load(QUrl()); - item.setHtml(QString()); - item.setContent(QByteArray()); - item.isModified(); -} - -class WebPage : public QWebPage -{ - Q_OBJECT - -public: - WebPage(QObject* parent = 0): QWebPage(parent) - { - } - - QGraphicsWebView* webView; - -private Q_SLOTS: - // Force a webview deletion during the load. - // It should not cause WebPage to crash due to - // it accessing invalid pageClient pointer. - void aborting() - { - delete webView; - } -}; - -class GraphicsWebView : public QGraphicsWebView -{ - Q_OBJECT - -public: - GraphicsWebView(QGraphicsItem* parent = 0): QGraphicsWebView(parent) - { - } - - void fireMouseClick(QPointF point) { - QGraphicsSceneMouseEvent presEv(QEvent::GraphicsSceneMousePress); - presEv.setPos(point); - presEv.setButton(Qt::LeftButton); - presEv.setButtons(Qt::LeftButton); - QGraphicsSceneMouseEvent relEv(QEvent::GraphicsSceneMouseRelease); - relEv.setPos(point); - relEv.setButton(Qt::LeftButton); - relEv.setButtons(Qt::LeftButton); - QGraphicsWebView::sceneEvent(&presEv); - QGraphicsWebView::sceneEvent(&relEv); - } -}; - -void tst_QGraphicsWebView::crashOnViewlessWebPages() -{ - QGraphicsScene scene; - QGraphicsView view(&scene); - - QGraphicsWebView* webView = new QGraphicsWebView; - WebPage* page = new WebPage; - webView->setPage(page); - page->webView = webView; - scene.addItem(webView); - - view.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - view.resize(600, 480); - webView->resize(view.geometry().size()); - - QCoreApplication::processEvents(); - view.show(); - - // Resizing the page will resize and layout the empty "about:blank" - // page, so we first connect the signal afterward. - connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), page, SLOT(aborting())); - - page->mainFrame()->load(QUrl("data:text/html," - "" - "" - "" - "")); - - QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); - delete page; -} - -void tst_QGraphicsWebView::crashOnSetScaleBeforeSetUrl() -{ - QGraphicsWebView* webView = new QGraphicsWebView; - webView->setScale(2.0); - delete webView; -} - -void tst_QGraphicsWebView::widgetsRenderingThroughCache() -{ - // Widgets should be rendered the same way with and without - // intermediate cache (tiling for example). - // See bug https://bugs.webkit.org/show_bug.cgi?id=47767 where - // widget are rendered as disabled when caching is using. - - QGraphicsWebView* webView = new QGraphicsWebView; - webView->setHtml(QLatin1String("")); - - QGraphicsView view; - // Disable the scrollbars on the graphics view because QtWebKit handles scrolling and scrollbar automatically - view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view.show(); - QGraphicsScene* scene = new QGraphicsScene(&view); - view.setScene(scene); - scene->addItem(webView); - view.setGeometry(QRect(0, 0, 500, 500)); - QWidget *const widget = &view; - QTest::qWaitForWindowExposed(widget); - - // 1. Reference without tiling. - webView->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, false); - QPixmap referencePixmap(view.size()); - QApplication::processEvents(); - widget->render(&referencePixmap); - - // 2. With tiling. - webView->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); - QPixmap viewWithTiling(view.size()); - widget->render(&viewWithTiling); - QApplication::processEvents(); - widget->render(&viewWithTiling); - - QCOMPARE(referencePixmap.toImage(), viewWithTiling.toImage()); -} - -#if defined(USE_TILED_BACKING_STORE) && USE_TILED_BACKING_STORE -void tst_QGraphicsWebView::bug57798() -{ - // When content size grows from less than viewport size to more than that, tiles may need to be regenerated. - - QGraphicsWebView* webView = new QGraphicsWebView(); - webView->setGeometry(QRectF(0.0, 0.0, 100.0, 100.0)); - QGraphicsView view(new QGraphicsScene()); - view.scene()->setParent(&view); - view.scene()->addItem(webView); - webView->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); - QStyleOptionGraphicsItem option; - option.exposedRect = view.sceneRect(); - QImage img(view.width(), view.height(), - QImage::Format_ARGB32_Premultiplied); - QPainter painter(&img); - // This will not paint anything as the tiles are not ready, but will trigger tile creation with size (0, 0). - webView->paint(&painter, &option); - QApplication::processEvents(); - QUrl url("qrc:///resources/greendiv.html"); - webView->load(url); - QVERIFY(waitForSignal(webView, SIGNAL(loadFinished(bool)))); - // This should trigger the recreation of the tiles. - webView->paint(&painter, &option); - QApplication::processEvents(); - painter.fillRect(option.exposedRect, Qt::red); // This is here to ensure failure if paint does not paint anything - webView->paint(&painter, &option); - QCOMPARE(img.pixel(option.exposedRect.width() / 4, option.exposedRect.height() / 4), qRgba(0, 128, 0, 255)); -} - -void tst_QGraphicsWebView::bug56929() -{ - // When rendering from tiles sychronous layout should not be triggered - // and scrollbars should be in sync with the size of the document in the displayed state. - - QGraphicsWebView* webView = new QGraphicsWebView(); - webView->setGeometry(QRectF(0.0, 0.0, 100.0, 100.0)); - QGraphicsView view(new QGraphicsScene()); - view.scene()->setParent(&view); - view.scene()->addItem(webView); - webView->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); - QUrl url("qrc:///resources/greendiv.html"); - webView->load(url); - QVERIFY(waitForSignal(webView, SIGNAL(loadFinished(bool)))); - QStyleOptionGraphicsItem option; - option.exposedRect = webView->geometry(); - QImage img(option.exposedRect.width(), option.exposedRect.height(), QImage::Format_ARGB32_Premultiplied); - QPainter painter(&img); - // This will not paint anything as the tiles are not ready, yet. - webView->paint(&painter, &option); - QApplication::processEvents(); - webView->paint(&painter, &option); - QCOMPARE(img.pixel(option.exposedRect.width() - 2, option.exposedRect.height() / 2), qRgba(255, 255, 255, 255)); - painter.fillRect(option.exposedRect, Qt::black); - QCOMPARE(img.pixel(option.exposedRect.width() - 2, option.exposedRect.height() / 2), qRgba(0, 0, 0, 255)); - webView->page()->mainFrame()->evaluateJavaScript(QString("resizeDiv();")); - webView->paint(&painter, &option); - QCOMPARE(img.pixel(option.exposedRect.width() - 2, option.exposedRect.height() / 2), qRgba(255, 255, 255, 255)); -} -#endif - -void tst_QGraphicsWebView::microFocusCoordinates() -{ - QWebPage* page = new QWebPage; - QGraphicsWebView* webView = new QGraphicsWebView; - webView->setPage( page ); - QGraphicsView* view = new QGraphicsView; - QGraphicsScene* scene = new QGraphicsScene(view); - view->setScene(scene); - scene->addItem(webView); - view->setGeometry(QRect(0,0,500,500)); - - page->mainFrame()->setHtml("" \ - "
" \ - "" \ - "
" \ - "" \ - ""); - - page->mainFrame()->setFocus(); - - QVariant initialMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); - QVERIFY(initialMicroFocus.isValid()); - - page->mainFrame()->scroll(0,300); - - QVariant currentMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); - QVERIFY(currentMicroFocus.isValid()); - - QCOMPARE(initialMicroFocus.toRect().translated(QPoint(0,-300)), currentMicroFocus.toRect()); - - delete view; -} - -void tst_QGraphicsWebView::focusInputTypes() -{ - QWebPage* page = new QWebPage; - GraphicsWebView* webView = new GraphicsWebView; - webView->setPage( page ); - QGraphicsView* view = new QGraphicsView; - QGraphicsScene* scene = new QGraphicsScene(view); - view->setScene(scene); - scene->addItem(webView); - view->setGeometry(QRect(0,0,500,500)); - QCoreApplication::processEvents(); - QUrl url("qrc:///resources/input_types.html"); - page->mainFrame()->load(url); - page->mainFrame()->setFocus(); - - QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); - - // 'text' type - webView->fireMouseClick(QPointF(20.0, 10.0)); - QVERIFY(webView->inputMethodHints() == Qt::ImhNone); - - // 'password' field - webView->fireMouseClick(QPointF(20.0, 60.0)); - QVERIFY(webView->inputMethodHints() & Qt::ImhHiddenText); - - // 'tel' field - webView->fireMouseClick(QPointF(20.0, 110.0)); - QVERIFY(webView->inputMethodHints() & Qt::ImhDialableCharactersOnly); - - // 'number' field - webView->fireMouseClick(QPointF(20.0, 160.0)); - QVERIFY(webView->inputMethodHints() & Qt::ImhDigitsOnly); - - // 'email' field - webView->fireMouseClick(QPointF(20.0, 210.0)); - QVERIFY(webView->inputMethodHints() & Qt::ImhEmailCharactersOnly); - - // 'url' field - webView->fireMouseClick(QPointF(20.0, 260.0)); - QVERIFY(webView->inputMethodHints() & Qt::ImhUrlCharactersOnly); - - delete webView; - delete view; -} - -#if !(defined(USE_QT_MOBILE_THEME) && USE_QT_MOBILE_THEME) -void tst_QGraphicsWebView::setPalette_data() -{ - QTest::addColumn("active"); - QTest::addColumn("background"); - QTest::newRow("activeBG") << true << true; - QTest::newRow("activeFG") << true << false; - QTest::newRow("inactiveBG") << false << true; - QTest::newRow("inactiveFG") << false << false; -} - -// Render a QGraphicsWebView to a QImage twice, each time with a different palette set, -// verify that images rendered are not the same, confirming WebCore usage of -// custom palette on selections. -void tst_QGraphicsWebView::setPalette() -{ - QString html = "" - "" - "Some text here" - "" - ""; - - QFETCH(bool, active); - QFETCH(bool, background); - - QWidget* activeView = 0; - - // Use controlView to manage active/inactive state of test views by raising - // or lowering their position in the window stack. - QGraphicsScene controlScene; - QGraphicsView controlView(&controlScene); - QGraphicsWebView controlWebView; - controlScene.addItem(&controlWebView); - controlWebView.setHtml(html); - controlWebView.setGeometry(QRectF(0, 0, 200, 200)); - - QGraphicsScene scene1; - QGraphicsView view1(&scene1); - view1.setSceneRect(0, 0, 300, 300); - QGraphicsWebView webView1; - webView1.setResizesToContents(true); - scene1.addItem(&webView1); - webView1.setFocus(); - - QPalette palette1; - QBrush brush1(Qt::red); - brush1.setStyle(Qt::SolidPattern); - if (active && background) { - // Rendered image must have red background on an active QGraphicsWebView. - palette1.setBrush(QPalette::Active, QPalette::Highlight, brush1); - } else if (active && !background) { - // Rendered image must have red foreground on an active QGraphicsWebView. - palette1.setBrush(QPalette::Active, QPalette::HighlightedText, brush1); - } else if (!active && background) { - // Rendered image must have red background on an inactive QGraphicsWebView. - palette1.setBrush(QPalette::Inactive, QPalette::Highlight, brush1); - } else if (!active && !background) { - // Rendered image must have red foreground on an inactive QGraphicsWebView. - palette1.setBrush(QPalette::Inactive, QPalette::HighlightedText, brush1); - } - - webView1.setHtml(html); - view1.resize(webView1.page()->viewportSize()); - webView1.setPalette(palette1); - view1.show(); - - QVERIFY(webView1.palette() == palette1); - QVERIFY(webView1.page()->palette() == palette1); - - QTest::qWaitForWindowExposed(&view1); - - if (!active) { - controlView.show(); - QTest::qWaitForWindowExposed(&controlView); - QApplication::setActiveWindow(&controlView); - activeView = &controlView; - controlView.activateWindow(); - } else { - QApplication::setActiveWindow(&view1); - view1.activateWindow(); - activeView = &view1; - } - - QTRY_COMPARE(QApplication::activeWindow(), activeView); - - webView1.page()->triggerAction(QWebPage::SelectAll); - - QImage img1(webView1.page()->viewportSize(), QImage::Format_ARGB32); - QPainter painter1(&img1); - webView1.page()->currentFrame()->render(&painter1); - painter1.end(); - view1.close(); - controlView.close(); - - QGraphicsScene scene2; - QGraphicsView view2(&scene2); - view2.setSceneRect(0, 0, 300, 300); - QGraphicsWebView webView2; - webView2.setResizesToContents(true); - scene2.addItem(&webView2); - webView2.setFocus(); - - QPalette palette2; - QBrush brush2(Qt::blue); - brush2.setStyle(Qt::SolidPattern); - if (active && background) { - // Rendered image must have blue background on an active QGraphicsWebView. - palette2.setBrush(QPalette::Active, QPalette::Highlight, brush2); - } else if (active && !background) { - // Rendered image must have blue foreground on an active QGraphicsWebView. - palette2.setBrush(QPalette::Active, QPalette::HighlightedText, brush2); - } else if (!active && background) { - // Rendered image must have blue background on an inactive QGraphicsWebView. - palette2.setBrush(QPalette::Inactive, QPalette::Highlight, brush2); - } else if (!active && !background) { - // Rendered image must have blue foreground on an inactive QGraphicsWebView. - palette2.setBrush(QPalette::Inactive, QPalette::HighlightedText, brush2); - } - - webView2.setHtml(html); - view2.resize(webView2.page()->viewportSize()); - webView2.setPalette(palette2); - view2.show(); - - QTest::qWaitForWindowExposed(&view2); - - if (!active) { - controlView.show(); - QTest::qWaitForWindowExposed(&controlView); - QApplication::setActiveWindow(&controlView); - activeView = &controlView; - controlView.activateWindow(); - } else { - QApplication::setActiveWindow(&view2); - view2.activateWindow(); - activeView = &view2; - } - - QTRY_COMPARE(QApplication::activeWindow(), activeView); - - webView2.page()->triggerAction(QWebPage::SelectAll); - - QImage img2(webView2.page()->viewportSize(), QImage::Format_ARGB32); - QPainter painter2(&img2); - webView2.page()->currentFrame()->render(&painter2); - painter2.end(); - - view2.close(); - controlView.close(); - - QVERIFY(img1 != img2); -} -#endif - -void tst_QGraphicsWebView::renderHints() -{ - QGraphicsWebView webView; - - // default is only text antialiasing + smooth pixmap transform - QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); - QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); - QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); - - webView.setRenderHint(QPainter::Antialiasing, true); - QVERIFY(webView.renderHints() & QPainter::Antialiasing); - QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); - QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); - - webView.setRenderHint(QPainter::Antialiasing, false); - QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); - QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); - QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); - - webView.setRenderHint(QPainter::SmoothPixmapTransform, true); - QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); - QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); - QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); - - webView.setRenderHint(QPainter::SmoothPixmapTransform, false); - QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); - QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform)); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); -} - -class GraphicsView : public QGraphicsView { -public: - GraphicsView(); - QGraphicsWebView* m_webView; -}; - -#if defined(ENABLE_WEBGL) && ENABLE_WEBGL -bool compareImagesFuzzyPixelCount(const QImage& image1, const QImage& image2, qreal tolerance = 0.05) -{ - if (image1.size() != image2.size()) - return false; - - unsigned diffPixelCount = 0; - for (int row = 0; row < image1.size().width(); ++row) { - for (int column = 0; column < image1.size().height(); ++column) - if (image1.pixel(row, column) != image2.pixel(row, column)) - ++diffPixelCount; - } - - if (diffPixelCount > (image1.size().width() * image1.size().height()) * tolerance) - return false; - - return true; -} - -GraphicsView::GraphicsView() -{ - QGraphicsScene* const scene = new QGraphicsScene(this); - setScene(scene); - - m_webView = new QGraphicsWebView; - scene->addItem(m_webView); - - m_webView->page()->settings()->setAttribute(QWebSettings::WebGLEnabled, true); - m_webView->setResizesToContents(true); - - setFrameShape(QFrame::NoFrame); - setViewport(new QGLWidget); -} - -void tst_QGraphicsWebView::webglSoftwareFallbackVerticalOrientation() -{ - QSKIP("Hangs on X11 -- https://bugs.webkit.org/show_bug.cgi?id=105820"); - QSize canvasSize(100, 100); - QImage reference(canvasSize, QImage::Format_ARGB32); - reference.fill(0xFF00FF00); - { // Reference. - QPainter painter(&reference); - QPolygonF triangleUp; - triangleUp << QPointF(0, canvasSize.height()) - << QPointF(canvasSize.width(), canvasSize.height()) - << QPointF(canvasSize.width() / 2.0, canvasSize.height() / 2.0); - painter.setPen(Qt::NoPen); - painter.setBrush(Qt::red); - painter.drawPolygon(triangleUp); - } - - compareCanvasToImage(QUrl(QLatin1String("qrc:///resources/pointing_up.html")), reference); -} - -void tst_QGraphicsWebView::webglSoftwareFallbackHorizontalOrientation() -{ - QSKIP("Hangs on X11 -- https://bugs.webkit.org/show_bug.cgi?id=105820"); - QSize canvasSize(100, 100); - QImage reference(canvasSize, QImage::Format_ARGB32); - reference.fill(0xFF00FF00); - { // Reference. - QPainter painter(&reference); - QPolygonF triangleUp; - triangleUp << QPointF(0, 0) - << QPointF(0, canvasSize.height()) - << QPointF(canvasSize.width() / 2.0, canvasSize.height() / 2.0); - painter.setPen(Qt::NoPen); - painter.setBrush(Qt::red); - painter.drawPolygon(triangleUp); - } - - compareCanvasToImage(QUrl(QLatin1String("qrc:///resources/pointing_right.html")), reference); -} - -void tst_QGraphicsWebView::compareCanvasToImage(const QUrl& url, const QImage& reference) -{ - GraphicsView view; - view.show(); - QTest::qWaitForWindowExposed(&view); - - QGraphicsWebView* const graphicsWebView = view.m_webView; - graphicsWebView->load(url); - QVERIFY(waitForSignal(graphicsWebView, SIGNAL(loadFinished(bool)))); - { // Force a render, to create the accelerated compositing tree. - QPixmap pixmap(view.size()); - QPainter painter(&pixmap); - view.render(&painter); - } - - const QSize imageSize = reference.size(); - - QImage target(imageSize, QImage::Format_ARGB32); - { // Web page content. - QPainter painter(&target); - QRectF renderRect(0, 0, imageSize.width(), imageSize.height()); - view.scene()->render(&painter, renderRect, renderRect); - } - QVERIFY(compareImagesFuzzyPixelCount(target, reference, 0.01)); -} -#endif - -class ResizeSpy : public QObject { - Q_OBJECT -public Q_SLOTS: - void receiveResize(int width, int height) - { - m_size = QSize(width, height); - emit resized(); - } - - QSize size() const - { - return m_size; - } - -Q_SIGNALS: - void resized(); - -private: - QSize m_size; -}; - -void tst_QGraphicsWebView::windowResizeEvent() -{ - QGraphicsWebView webView; - ResizeSpy resizeSpy; - resizeSpy.setProperty("resizeCount", 0); - - QString html = ""; - - webView.page()->mainFrame()->setHtml(html); - webView.page()->mainFrame()->addToJavaScriptWindowObject("resizeSpy", - &resizeSpy); - webView.setGeometry(QRect(0, 0, 50, 50)); - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118670", Continue); - QVERIFY(::waitForSignal(&resizeSpy, SIGNAL(resized()), 1000)); - QCOMPARE(resizeSpy.size(), QSize(50, 50)); - - webView.page()->setActualVisibleContentRect(QRect(10, 10, 60, 60)); - webView.setGeometry(QRect(0, 0, 100, 100)); - waitForSignal(&resizeSpy, SIGNAL(resized()), 1000); - - // This will be triggered without the fix on DOMWindow::innerHeight/Width - QCOMPARE(resizeSpy.size(), QSize(60, 60)); -} - -void tst_QGraphicsWebView::horizontalScrollbarTest() -{ - QWebPage* page = new QWebPage; - GraphicsWebView* webView = new GraphicsWebView; - webView->setPage(page); - webView->setGeometry(QRect(0, 0, 600, 600)); - QGraphicsView* view = new QGraphicsView; - QGraphicsScene* scene = new QGraphicsScene(view); - view->setScene(scene); - scene->addItem(webView); - - // Turn off scrolling on the containing QGraphicsView, let the - // QGraphicsWebView handle the scrolling by itself. - view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view->show(); - QCoreApplication::processEvents(); - - QUrl url("qrc:///resources/scrolltest_page.html"); - page->mainFrame()->load(url); - page->mainFrame()->setFocus(); - - QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); - - QVERIFY(webView->page()->mainFrame()->scrollPosition() == QPoint(0, 0)); - - // Note: The test below assumes that the layout direction is Qt::LeftToRight. - webView->fireMouseClick(QPointF(550.0, 590.0)); - QVERIFY(page->mainFrame()->scrollPosition().x() > 0); - - // Note: The test below assumes that the layout direction is Qt::LeftToRight. - webView->fireMouseClick(QPointF(20.0, 590.0)); - QVERIFY(page->mainFrame()->scrollPosition() == QPoint(0, 0)); - - delete webView; - delete view; -} - -QTEST_MAIN(tst_QGraphicsWebView) - -#include "tst_qgraphicswebview.moc" diff --git a/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc b/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc deleted file mode 100644 index ff06bd8c4..000000000 --- a/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc +++ /dev/null @@ -1,9 +0,0 @@ - - - resources/input_types.html - resources/pointing_right.html - resources/pointing_up.html - resources/greendiv.html - resources/scrolltest_page.html - - diff --git a/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp b/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp deleted file mode 100644 index a46d39050..000000000 --- a/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp +++ /dev/null @@ -1,2271 +0,0 @@ -/* - Copyright (C) 2008,2009 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include - -#include -#include -#include -#include -#include - -struct CustomType { - QString string; -}; -Q_DECLARE_METATYPE(CustomType) - -Q_DECLARE_METATYPE(QBrush*) -Q_DECLARE_METATYPE(QObjectList) -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QVariantList) -Q_DECLARE_METATYPE(QVariantMap) - -class MyQObject : public QObject { - Q_OBJECT - - Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty) - Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty) - Q_PROPERTY(QVariantList variantListProperty READ variantListProperty WRITE setVariantListProperty) - Q_PROPERTY(QVariantMap variantMapProperty READ variantMapProperty WRITE setVariantMapProperty) - Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty) - Q_PROPERTY(QStringList stringListProperty READ stringListProperty WRITE setStringListProperty) - Q_PROPERTY(QByteArray byteArrayProperty READ byteArrayProperty WRITE setByteArrayProperty) - Q_PROPERTY(QBrush brushProperty READ brushProperty WRITE setBrushProperty) - Q_PROPERTY(double hiddenProperty READ hiddenProperty WRITE setHiddenProperty SCRIPTABLE false) - Q_PROPERTY(int writeOnlyProperty WRITE setWriteOnlyProperty) - Q_PROPERTY(int readOnlyProperty READ readOnlyProperty) - Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) - Q_PROPERTY(CustomType propWithCustomType READ propWithCustomType WRITE setPropWithCustomType) - Q_PROPERTY(QWebElement webElementProperty READ webElementProperty WRITE setWebElementProperty) - Q_PROPERTY(QObject* objectStarProperty READ objectStarProperty WRITE setObjectStarProperty) - Q_ENUMS(Policy Strategy) - Q_FLAGS(Ability) - -public: - enum Policy { - FooPolicy = 0, - BarPolicy, - BazPolicy - }; - - enum Strategy { - FooStrategy = 10, - BarStrategy, - BazStrategy - }; - - enum AbilityFlag { - NoAbility = 0x000, - FooAbility = 0x001, - BarAbility = 0x080, - BazAbility = 0x200, - AllAbility = FooAbility | BarAbility | BazAbility - }; - - Q_DECLARE_FLAGS(Ability, AbilityFlag) - - MyQObject(QObject* parent = 0) - : QObject(parent), - m_intValue(123), - m_variantValue(QLatin1String("foo")), - m_variantListValue(QVariantList() << QVariant(123) << QVariant(QLatin1String("foo"))), - m_stringValue(QLatin1String("bar")), - m_stringListValue(QStringList() << QLatin1String("zig") << QLatin1String("zag")), - m_brushValue(QColor(10, 20, 30, 40)), - m_hiddenValue(456.0), - m_writeOnlyValue(789), - m_readOnlyValue(987), - m_objectStar(0), - m_qtFunctionInvoked(-1) - { - m_variantMapValue.insert("a", QVariant(123)); - m_variantMapValue.insert("b", QVariant(QLatin1String("foo"))); - m_variantMapValue.insert("c", QVariant::fromValue(this)); - } - - ~MyQObject() { } - - int intProperty() const - { - return m_intValue; - } - void setIntProperty(int value) - { - m_intValue = value; - } - - QVariant variantProperty() const - { - return m_variantValue; - } - void setVariantProperty(const QVariant& value) - { - m_variantValue = value; - } - - QVariantList variantListProperty() const - { - return m_variantListValue; - } - void setVariantListProperty(const QVariantList& value) - { - m_variantListValue = value; - } - - QVariantMap variantMapProperty() const - { - return m_variantMapValue; - } - void setVariantMapProperty(const QVariantMap& value) - { - m_variantMapValue = value; - } - - QString stringProperty() const - { - return m_stringValue; - } - void setStringProperty(const QString& value) - { - m_stringValue = value; - } - - QStringList stringListProperty() const - { - return m_stringListValue; - } - void setStringListProperty(const QStringList& value) - { - m_stringListValue = value; - } - - QByteArray byteArrayProperty() const - { - return m_byteArrayValue; - } - void setByteArrayProperty(const QByteArray& value) - { - m_byteArrayValue = value; - } - - QBrush brushProperty() const - { - return m_brushValue; - } - void setBrushProperty(const QBrush& value) - { - m_brushValue = value; - } - - double hiddenProperty() const - { - return m_hiddenValue; - } - void setHiddenProperty(double value) - { - m_hiddenValue = value; - } - - int writeOnlyProperty() const - { - return m_writeOnlyValue; - } - void setWriteOnlyProperty(int value) - { - m_writeOnlyValue = value; - } - - int readOnlyProperty() const - { - return m_readOnlyValue; - } - - QKeySequence shortcut() const - { - return m_shortcut; - } - void setShortcut(const QKeySequence& seq) - { - m_shortcut = seq; - } - - QWebElement webElementProperty() const - { - return m_webElement; - } - void setWebElementProperty(const QWebElement& element) - { - m_webElement = element; - } - - CustomType propWithCustomType() const - { - return m_customType; - } - void setPropWithCustomType(const CustomType& c) - { - m_customType = c; - } - - QObject* objectStarProperty() const - { - return m_objectStar; - } - void setObjectStarProperty(QObject* object) - { - m_objectStar = object; - } - - - int qtFunctionInvoked() const - { - return m_qtFunctionInvoked; - } - - QVariantList qtFunctionActuals() const - { - return m_actuals; - } - - void resetQtFunctionInvoked() - { - m_qtFunctionInvoked = -1; - m_actuals.clear(); - } - - Q_INVOKABLE void myInvokable() - { - m_qtFunctionInvoked = 0; - } - Q_INVOKABLE void myInvokableWithIntArg(int arg) - { - m_qtFunctionInvoked = 1; - m_actuals << arg; - } - Q_INVOKABLE void myInvokableWithLonglongArg(qlonglong arg) - { - m_qtFunctionInvoked = 2; - m_actuals << arg; - } - Q_INVOKABLE void myInvokableWithFloatArg(float arg) - { - m_qtFunctionInvoked = 3; - m_actuals << arg; - } - Q_INVOKABLE void myInvokableWithDoubleArg(double arg) - { - m_qtFunctionInvoked = 4; - m_actuals << arg; - } - Q_INVOKABLE void myInvokableWithStringArg(const QString& arg) - { - m_qtFunctionInvoked = 5; - m_actuals << arg; - } - Q_INVOKABLE void myInvokableWithIntArgs(int arg1, int arg2) - { - m_qtFunctionInvoked = 6; - m_actuals << arg1 << arg2; - } - Q_INVOKABLE int myInvokableReturningInt() - { - m_qtFunctionInvoked = 7; - return 123; - } - Q_INVOKABLE qlonglong myInvokableReturningLongLong() - { - m_qtFunctionInvoked = 39; - return 456; - } - Q_INVOKABLE QString myInvokableReturningString() - { - m_qtFunctionInvoked = 8; - return QLatin1String("ciao"); - } - Q_INVOKABLE void myInvokableWithIntArg(int arg1, int arg2) // Overload. - { - m_qtFunctionInvoked = 9; - m_actuals << arg1 << arg2; - } - Q_INVOKABLE void myInvokableWithEnumArg(Policy policy) - { - m_qtFunctionInvoked = 10; - m_actuals << policy; - } - Q_INVOKABLE void myInvokableWithQualifiedEnumArg(MyQObject::Policy policy) - { - m_qtFunctionInvoked = 36; - m_actuals << policy; - } - Q_INVOKABLE Policy myInvokableReturningEnum() - { - m_qtFunctionInvoked = 37; - return BazPolicy; - } - Q_INVOKABLE MyQObject::Policy myInvokableReturningQualifiedEnum() - { - m_qtFunctionInvoked = 38; - return BazPolicy; - } - Q_INVOKABLE QVector myInvokableReturningVectorOfInt() - { - m_qtFunctionInvoked = 11; - return QVector(); - } - Q_INVOKABLE void myInvokableWithVectorOfIntArg(const QVector&) - { - m_qtFunctionInvoked = 12; - } - Q_INVOKABLE QObject* myInvokableReturningQObjectStar() - { - m_qtFunctionInvoked = 13; - return this; - } - Q_INVOKABLE QObjectList myInvokableWithQObjectListArg(const QObjectList& lst) - { - m_qtFunctionInvoked = 14; - m_actuals << QVariant::fromValue(lst); - return lst; - } - Q_INVOKABLE QVariant myInvokableWithVariantArg(const QVariant& v) - { - m_qtFunctionInvoked = 15; - m_actuals << v; - return v; - } - Q_INVOKABLE QVariantMap myInvokableWithVariantMapArg(const QVariantMap& vm) - { - m_qtFunctionInvoked = 16; - m_actuals << vm; - return vm; - } - Q_INVOKABLE QList myInvokableWithListOfIntArg(const QList& lst) - { - m_qtFunctionInvoked = 17; - m_actuals << QVariant::fromValue(lst); - return lst; - } - Q_INVOKABLE QObject* myInvokableWithQObjectStarArg(QObject* obj) - { - m_qtFunctionInvoked = 18; - m_actuals << QVariant::fromValue(obj); - return obj; - } - Q_INVOKABLE QBrush myInvokableWithQBrushArg(const QBrush& brush) - { - m_qtFunctionInvoked = 19; - m_actuals << QVariant::fromValue(brush); - return brush; - } - Q_INVOKABLE void myInvokableWithBrushStyleArg(Qt::BrushStyle style) - { - m_qtFunctionInvoked = 43; - // Qt::BrushStyle isn't registered and this shouldn't be reached. - QVERIFY(false); - } - Q_INVOKABLE void myInvokableWithVoidStarArg(void* arg) - { - m_qtFunctionInvoked = 44; - m_actuals << QVariant::fromValue(arg); - } - Q_INVOKABLE void myInvokableWithAmbiguousArg(int arg) - { - m_qtFunctionInvoked = 45; - m_actuals << QVariant::fromValue(arg); - } - Q_INVOKABLE void myInvokableWithAmbiguousArg(uint arg) - { - m_qtFunctionInvoked = 46; - m_actuals << QVariant::fromValue(arg); - } - Q_INVOKABLE void myInvokableWithDefaultArgs(int arg1, const QString& arg2 = QString()) - { - m_qtFunctionInvoked = 47; - m_actuals << QVariant::fromValue(arg1) << qVariantFromValue(arg2); - } - Q_INVOKABLE QObject& myInvokableReturningRef() - { - m_qtFunctionInvoked = 48; - return *this; - } - Q_INVOKABLE const QObject& myInvokableReturningConstRef() const - { - const_cast(this)->m_qtFunctionInvoked = 49; - return *this; - } - Q_INVOKABLE void myInvokableWithPointArg(const QPoint &arg) { - const_cast(this)->m_qtFunctionInvoked = 50; - m_actuals << QVariant::fromValue(arg); - } - Q_INVOKABLE void myInvokableWithPointArg(const QPointF &arg) { - const_cast(this)->m_qtFunctionInvoked = 51; - m_actuals << QVariant::fromValue(arg); - } - Q_INVOKABLE void myInvokableWithBoolArg(bool arg) { - m_qtFunctionInvoked = 52; - m_actuals << arg; - } - - void emitMySignal() - { - emit mySignal(); - } - void emitMySignalWithIntArg(int arg) - { - emit mySignalWithIntArg(arg); - } - void emitMySignal2(bool arg) - { - emit mySignal2(arg); - } - void emitMySignal2() - { - emit mySignal2(); - } - void emitMySignalWithDateTimeArg(QDateTime dt) - { - emit mySignalWithDateTimeArg(dt); - } - -public Q_SLOTS: - void mySlot() - { - m_qtFunctionInvoked = 20; - } - - void mySlotWithIntArg(int arg) - { - m_qtFunctionInvoked = 21; - m_actuals << arg; - } - - void mySlotWithDoubleArg(double arg) - { - m_qtFunctionInvoked = 22; - m_actuals << arg; - } - - void mySlotWithStringArg(const QString &arg) - { - m_qtFunctionInvoked = 23; - m_actuals << arg; - } - - void myOverloadedSlot() - { - m_qtFunctionInvoked = 24; - } - - void myOverloadedSlot(QObject* arg) - { - m_qtFunctionInvoked = 41; - m_actuals << QVariant::fromValue(arg); - } - - void myOverloadedSlot(bool arg) - { - m_qtFunctionInvoked = 25; - m_actuals << arg; - } - - void myOverloadedSlot(const QStringList &arg) - { - m_qtFunctionInvoked = 42; - m_actuals << arg; - } - - void myOverloadedSlot(double arg) - { - m_qtFunctionInvoked = 26; - m_actuals << arg; - } - - void myOverloadedSlot(float arg) - { - m_qtFunctionInvoked = 27; - m_actuals << arg; - } - - void myOverloadedSlot(int arg) - { - m_qtFunctionInvoked = 28; - m_actuals << arg; - } - - void myOverloadedSlot(const QString &arg) - { - m_qtFunctionInvoked = 29; - m_actuals << arg; - } - - void myOverloadedSlot(const QColor &arg) - { - m_qtFunctionInvoked = 30; - m_actuals << arg; - } - - void myOverloadedSlot(const QBrush &arg) - { - m_qtFunctionInvoked = 31; - m_actuals << arg; - } - - void myOverloadedSlot(const QDateTime &arg) - { - m_qtFunctionInvoked = 32; - m_actuals << arg; - } - - void myOverloadedSlot(const QDate &arg) - { - m_qtFunctionInvoked = 33; - m_actuals << arg; - } - - void myOverloadedSlot(const QVariant &arg) - { - m_qtFunctionInvoked = 35; - m_actuals << arg; - } - - void myOverloadedSlot(const QWebElement &arg) - { - m_qtFunctionInvoked = 36; - m_actuals << QVariant::fromValue(arg); - } - -protected Q_SLOTS: - void myProtectedSlot() - { - m_qtFunctionInvoked = 36; - } - -private Q_SLOTS: - void myPrivateSlot() { } - -Q_SIGNALS: - void mySignal(); - void mySignalWithIntArg(int); - void mySignalWithDoubleArg(double); - void mySignal2(bool arg = false); - void mySignalWithDateTimeArg(QDateTime); - -private: - int m_intValue; - QVariant m_variantValue; - QVariantList m_variantListValue; - QVariantMap m_variantMapValue; - QString m_stringValue; - QStringList m_stringListValue; - QByteArray m_byteArrayValue; - QBrush m_brushValue; - double m_hiddenValue; - int m_writeOnlyValue; - int m_readOnlyValue; - QKeySequence m_shortcut; - QWebElement m_webElement; - CustomType m_customType; - QObject* m_objectStar; - int m_qtFunctionInvoked; - QVariantList m_actuals; -}; - -class MyWebElementSlotOnlyObject : public QObject { - Q_OBJECT - Q_PROPERTY(QString tagName READ tagName) -public Q_SLOTS: - void doSomethingWithWebElement(const QWebElement& element) - { - m_tagName = element.tagName(); - } - -public: - QString tagName() const - { - return m_tagName; - } -private: - QString m_tagName; -}; - -class MyOtherQObject : public MyQObject { -public: - MyOtherQObject(QObject* parent = 0) - : MyQObject(parent) { } -}; - -class tst_QObjectBridge : public QObject { - Q_OBJECT - -public: - tst_QObjectBridge(); - -public Q_SLOTS: - void init(); - void cleanup(); - -private Q_SLOTS: - void getSetStaticProperty(); - void getSetDynamicProperty(); - void getSetChildren(); - void callQtInvokable(); - void connectAndDisconnect(); - void overrideInvokable(); - void overloadedSlots(); - void webElementSlotOnly(); - void enumerate_data(); - void enumerate(); - void objectDeleted(); - void typeConversion(); - void arrayObjectEnumerable(); - void domCycles(); - void jsByteArray(); - void ownership(); - void nullValue(); - void qObjectWrapperWithSameIdentity(); - void introspectQtMethods_data(); - void introspectQtMethods(); - void scriptablePlugin(); - void exceptionInSlot(); - -private: - QString evalJS(const QString& s) - { - QVariant ret = evalJSV(s); - if (!ret.isValid()) - return "undefined"; - return ret.toString(); - } - - QVariant evalJSV(const QString& s) - { - return m_page->mainFrame()->evaluateJavaScript(s); - } - - QString evalJS(const QString& s, QString& type) - { - return evalJSV(s, type).toString(); - } - - QVariant evalJSV(const QString& s, QString& type) - { - // As a special measure, if we get an exception we set the type to 'error' - // (in ecma, an Error object has typeof object, but qtscript has a convenience function) - // Similarly, an array is an object, but we'd prefer to have a type of 'array' - QString escaped = s; - escaped.replace('\'', "\\'"); // Don't preescape your single quotes! - QString code("var retvalue; " - "var typevalue; " - "try { " - " retvalue = eval('%1'); " - " typevalue = typeof retvalue; " - " if (retvalue instanceof Array) " - " typevalue = 'array'; " - "} catch(e) { " - " retvalue = e.name + ': ' + e.message; " - " typevalue = 'error'; " - "}"); - evalJS(code.arg(escaped)); - - QVariant ret = evalJSV("retvalue"); - if (ret.isValid()) - type = evalJS("typevalue"); - else { - ret = QString("undefined"); - type = sUndefined; - } - evalJS("delete retvalue; delete typevalue"); - return ret; - } - - const QString sTrue; - const QString sFalse; - const QString sUndefined; - const QString sArray; - const QString sFunction; - const QString sError; - const QString sString; - const QString sObject; - const QString sNumber; - -private: - QWebView* m_view; - QWebPage* m_page; - MyQObject* m_myObject; -}; - -tst_QObjectBridge::tst_QObjectBridge() - : sTrue("true") - , sFalse("false") - , sUndefined("undefined") - , sArray("array") - , sFunction("function") - , sError("error") - , sString("string") - , sObject("object") - , sNumber("number") -{ -} - -void tst_QObjectBridge::init() -{ - m_view = new QWebView(); - m_page = m_view->page(); - m_myObject = new MyQObject(); - m_page->mainFrame()->addToJavaScriptWindowObject("myObject", m_myObject); -} - -void tst_QObjectBridge::cleanup() -{ - delete m_view; - delete m_myObject; -} - -void tst_QObjectBridge::getSetStaticProperty() -{ - m_page->mainFrame()->setHtml(""); - QCOMPARE(evalJS("typeof myObject.noSuchProperty"), sUndefined); - - // initial value (set in MyQObject constructor) - { - QString type; - QVariant ret = evalJSV("myObject.intProperty", type); - QCOMPARE(type, sNumber); - QCOMPARE(ret.type(), QVariant::Double); - QCOMPARE(ret.toInt(), 123); - } - QCOMPARE(evalJS("myObject.intProperty === 123.0"), sTrue); - - { - QString type; - QVariant ret = evalJSV("myObject.variantProperty", type); - QCOMPARE(type, sString); - QCOMPARE(ret.type(), QVariant::String); - QCOMPARE(ret.toString(), QLatin1String("foo")); - } - QCOMPARE(evalJS("myObject.variantProperty == 'foo'"), sTrue); - - { - QString type; - QVariant ret = evalJSV("myObject.stringProperty", type); - QCOMPARE(type, sString); - QCOMPARE(ret.type(), QVariant::String); - QCOMPARE(ret.toString(), QLatin1String("bar")); - } - QCOMPARE(evalJS("myObject.stringProperty === 'bar'"), sTrue); - - { - QString type; - QVariant ret = evalJSV("myObject.variantListProperty", type); - QCOMPARE(type, sArray); - QCOMPARE(ret.type(), QVariant::List); - QVariantList vl = ret.value(); - QCOMPARE(vl.size(), 2); - QCOMPARE(vl.at(0).toInt(), 123); - QCOMPARE(vl.at(1).toString(), QLatin1String("foo")); - } - QCOMPARE(evalJS("myObject.variantListProperty.length === 2"), sTrue); - QCOMPARE(evalJS("myObject.variantListProperty[0] === 123"), sTrue); - QCOMPARE(evalJS("myObject.variantListProperty[1] === 'foo'"), sTrue); - - { - QString type; - QVariant ret = evalJSV("myObject.variantMapProperty", type); - QCOMPARE(type, sObject); - QCOMPARE(ret.type(), QVariant::Map); - QVariantMap vm = ret.value(); - QCOMPARE(vm.size(), 3); - QCOMPARE(vm.value("a").toInt(), 123); - QCOMPARE(vm.value("b").toString(), QLatin1String("foo")); - QCOMPARE(vm.value("c").value(), static_cast(m_myObject)); - } - QCOMPARE(evalJS("myObject.variantMapProperty.a === 123"), sTrue); - QCOMPARE(evalJS("myObject.variantMapProperty.b === 'foo'"), sTrue); - QCOMPARE(evalJS("myObject.variantMapProperty.c.variantMapProperty.b === 'foo'"), sTrue); - - { - QString type; - QVariant ret = evalJSV("myObject.stringListProperty", type); - QCOMPARE(type, sArray); - QCOMPARE(ret.type(), QVariant::List); - QVariantList vl = ret.value(); - QCOMPARE(vl.size(), 2); - QCOMPARE(vl.at(0).toString(), QLatin1String("zig")); - QCOMPARE(vl.at(1).toString(), QLatin1String("zag")); - } - QCOMPARE(evalJS("myObject.stringListProperty.length === 2"), sTrue); - QCOMPARE(evalJS("typeof myObject.stringListProperty[0]"), sString); - QCOMPARE(evalJS("myObject.stringListProperty[0]"), QLatin1String("zig")); - QCOMPARE(evalJS("typeof myObject.stringListProperty[1]"), sString); - QCOMPARE(evalJS("myObject.stringListProperty[1]"), QLatin1String("zag")); - - // property change in C++ should be reflected in script - m_myObject->setIntProperty(456); - QCOMPARE(evalJS("myObject.intProperty == 456"), sTrue); - m_myObject->setIntProperty(789); - QCOMPARE(evalJS("myObject.intProperty == 789"), sTrue); - - m_myObject->setVariantProperty(QLatin1String("bar")); - QCOMPARE(evalJS("myObject.variantProperty === 'bar'"), sTrue); - m_myObject->setVariantProperty(42); - QCOMPARE(evalJS("myObject.variantProperty === 42"), sTrue); - m_myObject->setVariantProperty(QVariant::fromValue(QBrush())); - - m_myObject->setStringProperty(QLatin1String("baz")); - QCOMPARE(evalJS("myObject.stringProperty === 'baz'"), sTrue); - m_myObject->setStringProperty(QLatin1String("zab")); - QCOMPARE(evalJS("myObject.stringProperty === 'zab'"), sTrue); - - // property change in script should be reflected in C++ - QCOMPARE(evalJS("myObject.intProperty = 123"), QLatin1String("123")); - QCOMPARE(evalJS("myObject.intProperty == 123"), sTrue); - QCOMPARE(m_myObject->intProperty(), 123); - QCOMPARE(evalJS("myObject.intProperty = 'ciao!';" - "myObject.intProperty == 0"), sTrue); - QCOMPARE(m_myObject->intProperty(), 0); - QCOMPARE(evalJS("myObject.intProperty = '123';" - "myObject.intProperty == 123"), sTrue); - QCOMPARE(m_myObject->intProperty(), 123); - - QCOMPARE(evalJS("myObject.stringProperty = 'ciao'"), QLatin1String("ciao")); - QCOMPARE(evalJS("myObject.stringProperty"), QLatin1String("ciao")); - QCOMPARE(m_myObject->stringProperty(), QLatin1String("ciao")); - QCOMPARE(evalJS("myObject.stringProperty = 123;" - "myObject.stringProperty"), QLatin1String("123")); - QCOMPARE(m_myObject->stringProperty(), QLatin1String("123")); - QCOMPARE(evalJS("myObject.stringProperty = null"), QString()); - QCOMPARE(evalJS("myObject.stringProperty"), QString()); - QCOMPARE(m_myObject->stringProperty(), QString()); - QCOMPARE(evalJS("myObject.stringProperty = undefined"), sUndefined); - QCOMPARE(evalJS("myObject.stringProperty"), QString()); - QCOMPARE(m_myObject->stringProperty(), QString()); - - QCOMPARE(evalJS("myObject.variantProperty = new Number(1234);" - "myObject.variantProperty").toDouble(), 1234.0); - QCOMPARE(m_myObject->variantProperty().toDouble(), 1234.0); - - QCOMPARE(evalJS("myObject.variantProperty = new Boolean(1234);" - "myObject.variantProperty"), sTrue); - QCOMPARE(m_myObject->variantProperty().toBool(), true); - - QCOMPARE(evalJS("myObject.variantProperty = null;" - "myObject.variantProperty.valueOf()"), sUndefined); - QCOMPARE(m_myObject->variantProperty(), QVariant()); - QCOMPARE(evalJS("myObject.variantProperty = undefined;" - "myObject.variantProperty.valueOf()"), sUndefined); - QCOMPARE(m_myObject->variantProperty(), QVariant()); - - QCOMPARE(evalJS("myObject.variantProperty = 'foo';" - "myObject.variantProperty.valueOf()"), QLatin1String("foo")); - QCOMPARE(m_myObject->variantProperty(), QVariant(QLatin1String("foo"))); - QCOMPARE(evalJS("myObject.variantProperty = 42;" - "myObject.variantProperty").toDouble(), 42.0); - QCOMPARE(m_myObject->variantProperty().toDouble(), 42.0); - - QCOMPARE(evalJS("myObject.variantListProperty = [1, 'two', true];" - "myObject.variantListProperty.length == 3"), sTrue); - QCOMPARE(evalJS("myObject.variantListProperty[0] === 1"), sTrue); - QCOMPARE(evalJS("myObject.variantListProperty[1]"), QLatin1String("two")); - QCOMPARE(evalJS("myObject.variantListProperty[2] === true"), sTrue); - - QCOMPARE(evalJS("myObject.stringListProperty = [1, 'two', true];" - "myObject.stringListProperty.length == 3"), sTrue); - QCOMPARE(evalJS("typeof myObject.stringListProperty[0]"), sString); - QCOMPARE(evalJS("myObject.stringListProperty[0] == '1'"), sTrue); - QCOMPARE(evalJS("typeof myObject.stringListProperty[1]"), sString); - QCOMPARE(evalJS("myObject.stringListProperty[1]"), QLatin1String("two")); - QCOMPARE(evalJS("typeof myObject.stringListProperty[2]"), sString); - QCOMPARE(evalJS("myObject.stringListProperty[2]"), QLatin1String("true")); - evalJS("myObject.webElementProperty=document.body;"); - QCOMPARE(evalJS("myObject.webElementProperty.tagName"), QLatin1String("BODY")); - - // try to delete - QCOMPARE(evalJS("delete myObject.intProperty"), sFalse); - QCOMPARE(evalJS("myObject.intProperty == 123"), sTrue); - - QCOMPARE(evalJS("delete myObject.variantProperty"), sFalse); - QCOMPARE(evalJS("myObject.variantProperty").toDouble(), 42.0); - - // custom property - QCOMPARE(evalJS("myObject.customProperty"), sUndefined); - QCOMPARE(evalJS("myObject.customProperty = 123;" - "myObject.customProperty == 123"), sTrue); - QVariant v = m_page->mainFrame()->evaluateJavaScript("myObject.customProperty"); - QCOMPARE(v.type(), QVariant::Double); - QCOMPARE(v.toInt(), 123); - - // non-scriptable property - QCOMPARE(m_myObject->hiddenProperty(), 456.0); - QCOMPARE(evalJS("myObject.hiddenProperty"), sUndefined); - QCOMPARE(evalJS("myObject.hiddenProperty = 123;" - "myObject.hiddenProperty == 123"), sTrue); - QCOMPARE(m_myObject->hiddenProperty(), 456.0); - - // write-only property - QCOMPARE(m_myObject->writeOnlyProperty(), 789); - QCOMPARE(evalJS("typeof myObject.writeOnlyProperty"), sUndefined); - QCOMPARE(evalJS("myObject.writeOnlyProperty = 123;" - "typeof myObject.writeOnlyProperty"), sUndefined); - QCOMPARE(m_myObject->writeOnlyProperty(), 123); - - // read-only property - QCOMPARE(m_myObject->readOnlyProperty(), 987); - QCOMPARE(evalJS("myObject.readOnlyProperty == 987"), sTrue); - QCOMPARE(evalJS("myObject.readOnlyProperty = 654;" - "myObject.readOnlyProperty == 987"), sTrue); - QCOMPARE(m_myObject->readOnlyProperty(), 987); - - // QObject* property - m_myObject->setObjectStarProperty(0); - QCOMPARE(m_myObject->objectStarProperty(), (QObject*)0); - QCOMPARE(evalJS("myObject.objectStarProperty == null"), sTrue); - QCOMPARE(evalJS("typeof myObject.objectStarProperty"), sObject); - QCOMPARE(evalJS("Boolean(myObject.objectStarProperty)"), sFalse); - QCOMPARE(evalJS("String(myObject.objectStarProperty) == 'null'"), sTrue); - QCOMPARE(evalJS("myObject.objectStarProperty.objectStarProperty"), - sUndefined); - m_myObject->setObjectStarProperty(this); - QCOMPARE(evalJS("myObject.objectStarProperty != null"), sTrue); - QCOMPARE(evalJS("typeof myObject.objectStarProperty"), sObject); - QCOMPARE(evalJS("Boolean(myObject.objectStarProperty)"), sTrue); - QCOMPARE(evalJS("String(myObject.objectStarProperty) != 'null'"), sTrue); -} - -void tst_QObjectBridge::getSetDynamicProperty() -{ - // initially the object does not have the property - // In WebKit, RuntimeObjects do not inherit Object, so don't have hasOwnProperty - - // QCOMPARE(evalJS("myObject.hasOwnProperty('dynamicProperty')"), sFalse); - QCOMPARE(evalJS("typeof myObject.dynamicProperty"), sUndefined); - - // add a dynamic property in C++ - QCOMPARE(m_myObject->setProperty("dynamicProperty", 123), false); - // QCOMPARE(evalJS("myObject.hasOwnProperty('dynamicProperty')"), sTrue); - QCOMPARE(evalJS("typeof myObject.dynamicProperty != 'undefined'"), sTrue); - QCOMPARE(evalJS("myObject.dynamicProperty == 123"), sTrue); - - // property change in script should be reflected in C++ - QCOMPARE(evalJS("myObject.dynamicProperty = 'foo';" - "myObject.dynamicProperty"), QLatin1String("foo")); - QCOMPARE(m_myObject->property("dynamicProperty").toString(), QLatin1String("foo")); - - // delete the property (XFAIL - can't delete properties) - QEXPECT_FAIL("", "can't delete properties", Continue); - QCOMPARE(evalJS("delete myObject.dynamicProperty"), sTrue); - /* - QCOMPARE(m_myObject->property("dynamicProperty").isValid(), false); - QCOMPARE(evalJS("typeof myObject.dynamicProperty"), sUndefined); - // QCOMPARE(evalJS("myObject.hasOwnProperty('dynamicProperty')"), sFalse); - QCOMPARE(evalJS("typeof myObject.dynamicProperty"), sUndefined); - */ -} - -void tst_QObjectBridge::getSetChildren() -{ - // initially the object does not have the child - // (again, no hasOwnProperty) - - // QCOMPARE(evalJS("myObject.hasOwnProperty('child')"), sFalse); - QCOMPARE(evalJS("typeof myObject.child"), sUndefined); - - // add a child - MyQObject* child = new MyQObject(m_myObject); - child->setObjectName("child"); -// QCOMPARE(evalJS("myObject.hasOwnProperty('child')"), sTrue); - QCOMPARE(evalJS("typeof myObject.child != 'undefined'"), sTrue); - - // add a grandchild - MyQObject* grandChild = new MyQObject(child); - grandChild->setObjectName("grandChild"); -// QCOMPARE(evalJS("myObject.child.hasOwnProperty('grandChild')"), sTrue); - QCOMPARE(evalJS("typeof myObject.child.grandChild != 'undefined'"), sTrue); - - // delete grandchild - delete grandChild; -// QCOMPARE(evalJS("myObject.child.hasOwnProperty('grandChild')"), sFalse); - QCOMPARE(evalJS("typeof myObject.child.grandChild == 'undefined'"), sTrue); - - // delete child - delete child; -// QCOMPARE(evalJS("myObject.hasOwnProperty('child')"), sFalse); - QCOMPARE(evalJS("typeof myObject.child == 'undefined'"), sTrue); -} - -Q_DECLARE_METATYPE(QVector) -Q_DECLARE_METATYPE(QVector) -Q_DECLARE_METATYPE(QVector) - -void tst_QObjectBridge::callQtInvokable() -{ - qRegisterMetaType(); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokable()"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 0); - QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList()); - - // extra arguments should silently be ignored - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokable(10, 20, 30)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 0); - QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList()); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArg(123)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArg('123')"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithLonglongArg(123)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 2); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toLongLong(), qlonglong(123)); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithFloatArg(123.5)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 3); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.5); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithDoubleArg(123.5)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 4); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.5); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithDoubleArg(new Number(1234.5))"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 4); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 1234.5); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithBoolArg(new Boolean(true))"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 52); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toBool(), true); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithStringArg('ciao')"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 5); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("ciao")); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithStringArg(123)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 5); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("123")); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithStringArg(null)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 5); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QString()); - QVERIFY(m_myObject->qtFunctionActuals().at(0).toString().isEmpty()); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithStringArg(undefined)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 5); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QString()); - QVERIFY(m_myObject->qtFunctionActuals().at(0).toString().isEmpty()); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArgs(123, 456)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 6); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 2); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); - QCOMPARE(m_myObject->qtFunctionActuals().at(1).toInt(), 456); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("myObject.myInvokableReturningInt()"), QLatin1String("123")); - QCOMPARE(m_myObject->qtFunctionInvoked(), 7); - QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList()); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("myObject.myInvokableReturningLongLong()"), QLatin1String("456")); - QCOMPARE(m_myObject->qtFunctionInvoked(), 39); - QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList()); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("myObject.myInvokableReturningString()"), QLatin1String("ciao")); - QCOMPARE(m_myObject->qtFunctionInvoked(), 8); - QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList()); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArg(123, 456)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 9); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 2); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); - QCOMPARE(m_myObject->qtFunctionActuals().at(1).toInt(), 456); - - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("typeof myObject.myInvokableWithVoidStarArg(null)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 44); - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QString ret = evalJS("myObject.myInvokableWithVoidStarArg(123)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: incompatible type of argument(s) in call to myInvokableWithVoidStarArg(); candidates were\n myInvokableWithVoidStarArg(void*)")); - QCOMPARE(m_myObject->qtFunctionInvoked(), -1); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QString ret = evalJS("myObject.myInvokableWithAmbiguousArg(123)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: ambiguous call of overloaded function myInvokableWithAmbiguousArg(); candidates were\n myInvokableWithAmbiguousArg(int)\n myInvokableWithAmbiguousArg(uint)")); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QString ret = evalJS("myObject.myInvokableWithDefaultArgs(123, 'hello')", type); - QCOMPARE(type, sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 47); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 2); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); - QCOMPARE(m_myObject->qtFunctionActuals().at(1).toString(), QLatin1String("hello")); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QString ret = evalJS("myObject.myInvokableWithDefaultArgs(456)", type); - QCOMPARE(type, sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 47); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 2); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456); - QCOMPARE(m_myObject->qtFunctionActuals().at(1).toString(), QString()); - } - - // calling function that returns (const)ref - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QString ret = evalJS("typeof myObject.myInvokableReturningRef()"); - QCOMPARE(ret, sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 48); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QString ret = evalJS("typeof myObject.myInvokableReturningConstRef()"); - QCOMPARE(ret, sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 49); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QVariant ret = evalJSV("myObject.myInvokableReturningQObjectStar()", type); - QCOMPARE(m_myObject->qtFunctionInvoked(), 13); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 0); - QCOMPARE(type, sObject); - QCOMPARE(ret.userType(), int(QMetaType::QObjectStar)); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QVariant ret = evalJSV("myObject.myInvokableWithQObjectListArg([myObject])", type); - QCOMPARE(m_myObject->qtFunctionInvoked(), 14); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(type, sArray); - QCOMPARE(ret.userType(), int(QVariant::List)); // All lists get downgraded to QVariantList - QVariantList vl = qvariant_cast(ret); - QCOMPARE(vl.count(), 1); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - m_myObject->setVariantProperty(QVariant(123)); - QVariant ret = evalJSV("myObject.myInvokableWithVariantArg(myObject.variantProperty)", type); - QCOMPARE(type, sNumber); - QCOMPARE(m_myObject->qtFunctionInvoked(), 15); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0), m_myObject->variantProperty()); - QCOMPARE(ret.userType(), int(QMetaType::Double)); // all JS numbers are doubles, even though this started as an int - QCOMPARE(ret.toInt(), 123); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QVariant ret = evalJSV("myObject.myInvokableWithVariantArg(null)", type); - QCOMPARE(type, sObject); - QCOMPARE(m_myObject->qtFunctionInvoked(), 15); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant()); - QVERIFY(!m_myObject->qtFunctionActuals().at(0).isValid()); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QVariant ret = evalJSV("myObject.myInvokableWithVariantArg(undefined)", type); - QCOMPARE(type, sObject); - QCOMPARE(m_myObject->qtFunctionInvoked(), 15); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant()); - QVERIFY(!m_myObject->qtFunctionActuals().at(0).isValid()); - } - - /* XFAIL - variant support - m_myObject->resetQtFunctionInvoked(); - { - m_myObject->setVariantProperty(QVariant::fromValue(QBrush())); - QVariant ret = evalJS("myObject.myInvokableWithVariantArg(myObject.variantProperty)"); - QVERIFY(ret.isVariant()); - QCOMPARE(m_myObject->qtFunctionInvoked(), 15); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(ret.toVariant(), m_myObject->qtFunctionActuals().at(0)); - QCOMPARE(ret.toVariant(), m_myObject->variantProperty()); - } - */ - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QVariant ret = evalJSV("myObject.myInvokableWithVariantArg(123)", type); - QCOMPARE(type, sNumber); - QCOMPARE(m_myObject->qtFunctionInvoked(), 15); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant(123)); - QCOMPARE(ret.userType(), int(QMetaType::Double)); - QCOMPARE(ret.toInt(), 123); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QVariant ret = evalJSV("myObject.myInvokableWithVariantMapArg({ a:123, b:'ciao' })", type); - QCOMPARE(m_myObject->qtFunctionInvoked(), 16); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - - QVariant v = m_myObject->qtFunctionActuals().at(0); - QCOMPARE(v.userType(), int(QMetaType::QVariantMap)); - - QVariantMap vmap = qvariant_cast(v); - QCOMPARE(vmap.keys().size(), 2); - QCOMPARE(vmap.keys().at(0), QLatin1String("a")); - QCOMPARE(vmap.value("a"), QVariant(123)); - QCOMPARE(vmap.keys().at(1), QLatin1String("b")); - QCOMPARE(vmap.value("b"), QVariant("ciao")); - - QCOMPARE(type, sObject); - - QCOMPARE(ret.userType(), int(QMetaType::QVariantMap)); - vmap = qvariant_cast(ret); - QCOMPARE(vmap.keys().size(), 2); - QCOMPARE(vmap.keys().at(0), QLatin1String("a")); - QCOMPARE(vmap.value("a"), QVariant(123)); - QCOMPARE(vmap.keys().at(1), QLatin1String("b")); - QCOMPARE(vmap.value("b"), QVariant("ciao")); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QVariant ret = evalJSV("myObject.myInvokableWithListOfIntArg([1, 5])", type); - QCOMPARE(m_myObject->qtFunctionInvoked(), 17); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QVariant v = m_myObject->qtFunctionActuals().at(0); - QCOMPARE(v.userType(), qMetaTypeId >()); - QList ilst = qvariant_cast >(v); - QCOMPARE(ilst.size(), 2); - QCOMPARE(ilst.at(0), 1); - QCOMPARE(ilst.at(1), 5); - - QCOMPARE(type, sArray); - QCOMPARE(ret.userType(), int(QMetaType::QVariantList)); // ints get converted to doubles, so this is a qvariantlist - QVariantList vlst = qvariant_cast(ret); - QCOMPARE(vlst.size(), 2); - QCOMPARE(vlst.at(0).toInt(), 1); - QCOMPARE(vlst.at(1).toInt(), 5); - } - - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QVariant ret = evalJSV("myObject.myInvokableWithQObjectStarArg(myObject)", type); - QCOMPARE(m_myObject->qtFunctionInvoked(), 18); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QVariant v = m_myObject->qtFunctionActuals().at(0); - QCOMPARE(v.userType(), int(QMetaType::QObjectStar)); - QCOMPARE(qvariant_cast(v), (QObject*)m_myObject); - - QCOMPARE(ret.userType(), int(QMetaType::QObjectStar)); - QCOMPARE(qvariant_cast(ret), (QObject*)m_myObject); - - QCOMPARE(type, sObject); - } - - m_myObject->resetQtFunctionInvoked(); - { - // no implicit conversion from integer to QObject* - QString type; - evalJS("myObject.myInvokableWithQObjectStarArg(123)", type); - QCOMPARE(type, sError); - } - - /* - m_myObject->resetQtFunctionInvoked(); - { - QString fun = evalJS("myObject.myInvokableWithQBrushArg"); - Q_ASSERT(fun.isFunction()); - QColor color(10, 20, 30, 40); - // QColor should be converted to a QBrush - QVariant ret = fun.call(QString(), QStringList() - << qScriptValueFromValue(m_engine, color)); - QCOMPARE(m_myObject->qtFunctionInvoked(), 19); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QVariant v = m_myObject->qtFunctionActuals().at(0); - QCOMPARE(v.userType(), int(QMetaType::QBrush)); - QCOMPARE(qvariant_cast(v), color); - - QCOMPARE(qscriptvalue_cast(ret), color); - } - */ - - // private slots should not be part of the QObject binding - QCOMPARE(evalJS("typeof myObject.myPrivateSlot"), sUndefined); - - // protected slots should be fine - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myProtectedSlot()"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 36); - - // call with too few arguments - { - QString type; - QString ret = evalJS("myObject.myInvokableWithIntArg()", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: too few arguments in call to myInvokableWithIntArg(); candidates are\n myInvokableWithIntArg(int,int)\n myInvokableWithIntArg(int)")); - } - - // call function where not all types have been registered - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QString ret = evalJS("myObject.myInvokableWithBrushStyleArg(0)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: cannot call myInvokableWithBrushStyleArg(): unknown type `Qt::BrushStyle'")); - QCOMPARE(m_myObject->qtFunctionInvoked(), -1); - } - - // call function with incompatible argument type - m_myObject->resetQtFunctionInvoked(); - { - QString type; - QString ret = evalJS("myObject.myInvokableWithQBrushArg(null)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: incompatible type of argument(s) in call to myInvokableWithQBrushArg(); candidates were\n myInvokableWithQBrushArg(QBrush)")); - QCOMPARE(m_myObject->qtFunctionInvoked(), -1); - } -} - -void tst_QObjectBridge::connectAndDisconnect() -{ - // connect(function) - QCOMPARE(evalJS("typeof myObject.mySignal"), sFunction); - QCOMPARE(evalJS("typeof myObject.mySignal.connect"), sFunction); - QCOMPARE(evalJS("typeof myObject.mySignal.disconnect"), sFunction); - - { - QString type; - evalJS("myObject.mySignal.connect(123)", type); - QCOMPARE(type, sError); - } - - evalJS("myHandler = function() { window.gotSignal = true; window.signalArgs = arguments; window.slotThisObject = this; }"); - - QCOMPARE(evalJS("myObject.mySignal.connect(myHandler)"), sUndefined); - - evalJS("gotSignal = false"); - evalJS("myObject.mySignal()"); - QCOMPARE(evalJS("gotSignal"), sTrue); - QCOMPARE(evalJS("signalArgs.length == 0"), sTrue); - QCOMPARE(evalJS("slotThisObject == window"), sTrue); - - evalJS("gotSignal = false"); - m_myObject->emitMySignal(); - QCOMPARE(evalJS("gotSignal"), sTrue); - QCOMPARE(evalJS("signalArgs.length == 0"), sTrue); - - QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myHandler)"), sUndefined); - - evalJS("gotSignal = false"); - m_myObject->emitMySignalWithIntArg(123); - QCOMPARE(evalJS("gotSignal"), sTrue); - QCOMPARE(evalJS("signalArgs.length == 1"), sTrue); - QCOMPARE(evalJS("signalArgs[0] == 123.0"), sTrue); - - QCOMPARE(evalJS("myObject.mySignal.disconnect(myHandler)"), sUndefined); - { - QString type; - evalJS("myObject.mySignal.disconnect(myHandler)", type); - QCOMPARE(type, sError); - } - - evalJS("gotSignal = false"); - QCOMPARE(evalJS("myObject.mySignal2.connect(myHandler)"), sUndefined); - m_myObject->emitMySignal2(true); - QCOMPARE(evalJS("gotSignal"), sTrue); - QCOMPARE(evalJS("signalArgs.length == 1"), sTrue); - QCOMPARE(evalJS("signalArgs[0]"), sTrue); - - QCOMPARE(evalJS("myObject.mySignal2.disconnect(myHandler)"), sUndefined); - - QCOMPARE(evalJS("typeof myObject['mySignal2()']"), sFunction); - QCOMPARE(evalJS("typeof myObject['mySignal2()'].connect"), sFunction); - QCOMPARE(evalJS("typeof myObject['mySignal2()'].disconnect"), sFunction); - - QCOMPARE(evalJS("myObject['mySignal2()'].connect(myHandler)"), sUndefined); - - evalJS("gotSignal = false"); - m_myObject->emitMySignal2(); - QCOMPARE(evalJS("gotSignal"), sTrue); - - QCOMPARE(evalJS("myObject['mySignal2()'].disconnect(myHandler)"), sUndefined); - - // connect(object, function) - evalJS("otherObject = { name:'foo' }"); - QCOMPARE(evalJS("myObject.mySignal.connect(otherObject, myHandler)"), sUndefined); - QCOMPARE(evalJS("myObject.mySignal.disconnect(otherObject, myHandler)"), sUndefined); - evalJS("gotSignal = false"); - m_myObject->emitMySignal(); - QCOMPARE(evalJS("gotSignal"), sFalse); - - { - QString type; - evalJS("myObject.mySignal.disconnect(otherObject, myHandler)", type); - QCOMPARE(type, sError); - } - - QCOMPARE(evalJS("myObject.mySignal.connect(otherObject, myHandler)"), sUndefined); - evalJS("gotSignal = false"); - m_myObject->emitMySignal(); - QCOMPARE(evalJS("gotSignal"), sTrue); - QCOMPARE(evalJS("signalArgs.length == 0"), sTrue); - QCOMPARE(evalJS("slotThisObject"), evalJS("otherObject")); - QCOMPARE(evalJS("slotThisObject.name"), QLatin1String("foo")); - QCOMPARE(evalJS("myObject.mySignal.disconnect(otherObject, myHandler)"), sUndefined); - - evalJS("yetAnotherObject = { name:'bar', func : function() { } }"); - QCOMPARE(evalJS("myObject.mySignal2.connect(yetAnotherObject, myHandler)"), sUndefined); - evalJS("gotSignal = false"); - m_myObject->emitMySignal2(true); - QCOMPARE(evalJS("gotSignal"), sTrue); - QCOMPARE(evalJS("signalArgs.length == 1"), sTrue); - QCOMPARE(evalJS("slotThisObject == yetAnotherObject"), sTrue); - QCOMPARE(evalJS("slotThisObject.name"), QLatin1String("bar")); - QCOMPARE(evalJS("myObject.mySignal2.disconnect(yetAnotherObject, myHandler)"), sUndefined); - - QCOMPARE(evalJS("myObject.mySignal2.connect(myObject, myHandler)"), sUndefined); - evalJS("gotSignal = false"); - m_myObject->emitMySignal2(true); - QCOMPARE(evalJS("gotSignal"), sTrue); - QCOMPARE(evalJS("signalArgs.length == 1"), sTrue); - QCOMPARE(evalJS("slotThisObject == myObject"), sTrue); - QCOMPARE(evalJS("myObject.mySignal2.disconnect(myObject, myHandler)"), sUndefined); - - // connect(obj, string) - { - QString type; - QCOMPARE(evalJS("myObject.mySignal.connect(yetAnotherObject, 'func')", type), sUndefined); - QCOMPARE(evalJS("myObject.mySignal.connect(myObject, 'mySlot')", type), sUndefined); - QCOMPARE(evalJS("myObject.mySignal.disconnect(yetAnotherObject, 'func')", type), sUndefined); - QCOMPARE(evalJS("myObject.mySignal.disconnect(myObject, 'mySlot')", type), sUndefined); - } - - // check that emitting signals from script works - - // no arguments - QCOMPARE(evalJS("myObject.mySignal.connect(myObject.mySlot)"), sUndefined); - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("myObject.mySignal()"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 20); - QCOMPARE(evalJS("myObject.mySignal.disconnect(myObject.mySlot)"), sUndefined); - - // one argument - QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.mySlotWithIntArg)"), sUndefined); - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 21); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); - QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithIntArg)"), sUndefined); - - QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.mySlotWithDoubleArg)"), sUndefined); - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 22); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.0); - QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithDoubleArg)"), sUndefined); - - QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.mySlotWithStringArg)"), sUndefined); - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 23); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("123")); - QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithStringArg)"), sUndefined); - - // connecting to overloaded slot - QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.myOverloadedSlot)"), sUndefined); - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 26); // double overload - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); - QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.myOverloadedSlot)"), sUndefined); - - QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject['myOverloadedSlot(int)'])"), sUndefined); - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("myObject.mySignalWithIntArg(456)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 28); // int overload - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456); - QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject['myOverloadedSlot(int)'])"), sUndefined); - - QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject, 'myOverloadedSlot(int)')"), sUndefined); - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("myObject.mySignalWithIntArg(456)"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 28); // int overload - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456); - QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject, 'myOverloadedSlot(int)')"), sUndefined); - - // erroneous input -#define NOT_A_FUNCTION(f, expr) \ - "TypeError: " f " is not a function. (In '" expr "', '" f "' is undefined)" - - { - // ### QtScript adds .connect to all functions, WebKit does only to signals/slots - QString type; - QString ret = evalJS("(function() { }).connect()", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String(NOT_A_FUNCTION("(function() { }).connect", "(function() { }).connect()"))); - } - { - QString type; - QString ret = evalJS("var o = { }; o.connect = Function.prototype.connect; o.connect()", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String(NOT_A_FUNCTION("o.connect", "o.connect()"))); - } - - { - QString type; - QString ret = evalJS("(function() { }).connect(123)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String(NOT_A_FUNCTION("(function() { }).connect", "(function() { }).connect(123)"))); - } - { - QString type; - QString ret = evalJS("var o = { }; o.connect = Function.prototype.connect; o.connect(123)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String(NOT_A_FUNCTION("o.connect", "o.connect(123)"))); - } - - { - QString type; - QString ret = evalJS("myObject.myInvokable.connect(123)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.connect: MyQObject::myInvokable() is not a signal")); - } - { - QString type; - QString ret = evalJS("myObject.myInvokable.connect(function() { })", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.connect: MyQObject::myInvokable() is not a signal")); - } - - { - QString type; - QString ret = evalJS("myObject.mySignal.connect(123)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.connect: target is not a function")); - } - - { - QString type; - QString ret = evalJS("var randomObject = new Object; myObject.mySignal.connect(myObject, randomObject)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.connect: target is not a function")); - } - - { - QString type; - QString ret = evalJS("myObject.mySignal.connect(myObject, 'nonExistantSlot')", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.connect: target is not a function")); - } - - { - QString type; - QString ret = evalJS("myObject.mySignal.disconnect()", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: no arguments given")); - } - { - QString type; - QString ret = evalJS("var o = { }; o.disconnect = myObject.mySignal.disconnect; o.disconnect()", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: no arguments given")); - } - - { - QString type; - QString ret = evalJS("myObject.mySignal.disconnect(myObject, 'nonExistantSlot')", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: target is not a function")); - } - - /* XFAIL - Function.prototype doesn't get connect/disconnect, just signals/slots - { - QString type; - QString ret = evalJS("(function() { }).disconnect(123)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("TypeError: QtMetaMethod.disconnect: this object is not a signal")); - } - */ - - { - QString type; - QString ret = evalJS("var o = { }; o.disconnect = myObject.myInvokable.disconnect; o.disconnect(123)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: MyQObject::myInvokable() is not a signal")); - } - - { - QString type; - QString ret = evalJS("myObject.myInvokable.disconnect(123)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: MyQObject::myInvokable() is not a signal")); - } - { - QString type; - QString ret = evalJS("myObject.myInvokable.disconnect(function() { })", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: MyQObject::myInvokable() is not a signal")); - } - - { - QString type; - QString ret = evalJS("myObject.mySignal.disconnect(123)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: target is not a function")); - } - - { - QString type; - QString ret = evalJS("myObject.mySignal.disconnect(function() { })", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: failed to disconnect from MyQObject::mySignal()")); - } - - // when the wrapper dies, the connection stays alive - QCOMPARE(evalJS("myObject.mySignal.connect(myObject.mySlot)"), sUndefined); - m_myObject->resetQtFunctionInvoked(); - m_myObject->emitMySignal(); - QCOMPARE(m_myObject->qtFunctionInvoked(), 20); - evalJS("myObject = null"); - evalJS("gc()"); - m_myObject->resetQtFunctionInvoked(); - m_myObject->emitMySignal(); - QCOMPARE(m_myObject->qtFunctionInvoked(), 20); -} - -void tst_QObjectBridge::overrideInvokable() -{ - m_myObject->resetQtFunctionInvoked(); - QCOMPARE(evalJS("myObject.myInvokable()"), sUndefined); - QCOMPARE(m_myObject->qtFunctionInvoked(), 0); - - /* XFAIL - can't write to functions with RuntimeObject - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myInvokable = function() { window.a = 123; }"); - evalJS("myObject.myInvokable()"); - QCOMPARE(m_myObject->qtFunctionInvoked(), -1); - QCOMPARE(evalJS("window.a").toDouble(), 123.0); - - evalJS("myObject.myInvokable = function() { window.a = 456; }"); - evalJS("myObject.myInvokable()"); - QCOMPARE(m_myObject->qtFunctionInvoked(), -1); - QCOMPARE(evalJS("window.a").toDouble(), 456.0); - */ - - evalJS("delete myObject.myInvokable"); - evalJS("myObject.myInvokable()"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 0); - - /* XFAIL - ditto - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myInvokable = myObject.myInvokableWithIntArg"); - evalJS("myObject.myInvokable(123)"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 1); - */ - - evalJS("delete myObject.myInvokable"); - m_myObject->resetQtFunctionInvoked(); - // this form (with the '()') is read-only - evalJS("myObject['myInvokable()'] = function() { window.a = 123; }"); - evalJS("myObject.myInvokable()"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 0); -} - -void tst_QObjectBridge::overloadedSlots() -{ - // should pick myOverloadedSlot(double) - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myOverloadedSlot(10)"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 26); - - // should pick myOverloadedSlot(double) - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myOverloadedSlot(10.0)"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 26); - - // should pick myOverloadedSlot(QString) - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myOverloadedSlot('10')"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 29); - - // should pick myOverloadedSlot(bool) - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myOverloadedSlot(true)"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 25); - - // should pick myOverloadedSlot(QDateTime) - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myOverloadedSlot(new Date())"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 32); - - // should pick myOverloadedSlot(QVariant) - /* XFAIL - m_myObject->resetQtFunctionInvoked(); - QString f = evalJS("myObject.myOverloadedSlot"); - f.call(QString(), QStringList() << m_engine->newVariant(QVariant("ciao"))); - QCOMPARE(m_myObject->qtFunctionInvoked(), 35); - */ - - // Should pick myOverloadedSlot(QWebElement). - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myOverloadedSlot(document.body)"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 36); - - // should pick myOverloadedSlot(QObject*) - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myOverloadedSlot(myObject)"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 41); - - // should pick myOverloadedSlot(QObject*) - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myOverloadedSlot(null)"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 41); - - // should pick myOverloadedSlot(QStringList) - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myOverloadedSlot(['hello'])"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 42); -} - -class MyEnumTestQObject : public QObject { - Q_OBJECT - Q_PROPERTY(QString p1 READ p1) - Q_PROPERTY(QString p2 READ p2) - Q_PROPERTY(QString p3 READ p3 SCRIPTABLE false) - Q_PROPERTY(QString p4 READ p4) - Q_PROPERTY(QString p5 READ p5 SCRIPTABLE false) - Q_PROPERTY(QString p6 READ p6) -public: - MyEnumTestQObject(QObject* parent = 0) - : QObject(parent) { } - - QString p1() const { return QLatin1String("p1"); } - QString p2() const { return QLatin1String("p2"); } - QString p3() const { return QLatin1String("p3"); } - QString p4() const { return QLatin1String("p4"); } - QString p5() const { return QLatin1String("p5"); } - QString p6() const { return QLatin1String("p6"); } - -public Q_SLOTS: - void mySlot() { } - void myOtherSlot() { } -Q_SIGNALS: - void mySignal(); -}; - -void tst_QObjectBridge::enumerate_data() -{ - QTest::addColumn("expectedNames"); - - QTest::newRow("enumerate all") - << (QStringList() - // meta-object-defined properties: - // inherited - << "objectName" - // non-inherited - << "p1" << "p2" << "p4" << "p6" - // dynamic properties - << "dp1" << "dp2" << "dp3" - // inherited signals and slots - << "destroyed(QObject*)" << "destroyed()" - << "objectNameChanged(QString)" - << "deleteLater()" - // not included because it's private: - // << "_q_reregisterTimers(void*)" - // signals - << "mySignal()" - // slots - << "mySlot()" << "myOtherSlot()"); -} - -void tst_QObjectBridge::enumerate() -{ - QFETCH(QStringList, expectedNames); - - MyEnumTestQObject enumQObject; - // give it some dynamic properties - enumQObject.setProperty("dp1", "dp1"); - enumQObject.setProperty("dp2", "dp2"); - enumQObject.setProperty("dp3", "dp3"); - m_page->mainFrame()->addToJavaScriptWindowObject("myEnumObject", &enumQObject); - - // enumerate in script - { - evalJS("var enumeratedProperties = []"); - evalJS("for (var p in myEnumObject) { enumeratedProperties.push(p); }"); - QStringList result = evalJSV("enumeratedProperties").toStringList(); - QCOMPARE(result.size(), expectedNames.size()); - for (int i = 0; i < expectedNames.size(); ++i) - QCOMPARE(result.at(i), expectedNames.at(i)); - } -} - -void tst_QObjectBridge::objectDeleted() -{ - MyQObject* qobj = new MyQObject(); - m_page->mainFrame()->addToJavaScriptWindowObject("bar", qobj); - evalJS("bar.objectName = 'foo';"); - QCOMPARE(qobj->objectName(), QLatin1String("foo")); - evalJS("bar.intProperty = 123;"); - QCOMPARE(qobj->intProperty(), 123); - qobj->resetQtFunctionInvoked(); - evalJS("bar.myInvokable.call(bar);"); - QCOMPARE(qobj->qtFunctionInvoked(), 0); - - // do this, to ensure that we cache that it implements call - evalJS("bar()"); - - // now delete the object - delete qobj; - - QCOMPARE(evalJS("typeof bar"), sObject); - - // any attempt to access properties of the object should result in an exception - { - QString type; - QString ret = evalJS("bar.objectName", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: cannot access member `objectName' of deleted QObject")); - } - { - QString type; - QString ret = evalJS("bar.objectName = 'foo'", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: cannot access member `objectName' of deleted QObject")); - } - - // myInvokable is stored in member table (since we've accessed it before deletion) - { - QString type; - evalJS("bar.myInvokable", type); - QCOMPARE(type, sFunction); - } - - { - QString type; - QString ret = evalJS("bar.myInvokable.call(bar);", type); - ret = evalJS("bar.myInvokable(bar)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: cannot call function of deleted QObject")); - } - // myInvokableWithIntArg is not stored in member table (since we've not accessed it) - { - QString type; - QString ret = evalJS("bar.myInvokableWithIntArg", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: cannot access member `myInvokableWithIntArg' of deleted QObject")); - } - - // access from script - evalJS("window.o = bar;"); - { - QString type; - QString ret = evalJS("o.objectName", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: cannot access member `objectName' of deleted QObject")); - } - { - QString type; - QString ret = evalJS("o.myInvokable()", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: cannot call function of deleted QObject")); - } - { - QString type; - QString ret = evalJS("o.myInvokableWithIntArg(10)", type); - QCOMPARE(type, sError); - QCOMPARE(ret, QLatin1String("Error: cannot access member `myInvokableWithIntArg' of deleted QObject")); - } -} - -void tst_QObjectBridge::typeConversion() -{ - m_myObject->resetQtFunctionInvoked(); - - QDateTime localdt(QDate(2008, 1, 18), QTime(12, 31, 0)); - QDateTime utclocaldt = localdt.toUTC(); - QDateTime utcdt(QDate(2008, 1, 18), QTime(12, 31, 0), Qt::UTC); - - // Dates in JS (default to local) - evalJS("myObject.myOverloadedSlot(new Date(2008,0,18,12,31,0))"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 32); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDateTime().toUTC(), utclocaldt); - - m_myObject->resetQtFunctionInvoked(); - evalJS("myObject.myOverloadedSlot(new Date(Date.UTC(2008,0,18,12,31,0)))"); - QCOMPARE(m_myObject->qtFunctionInvoked(), 32); - QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); - QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDateTime().toUTC(), utcdt); - - // Pushing QDateTimes into JS - // Local - evalJS("function checkDate(d) {window.__date_equals = (d.toString() == new Date(2008,0,18,12,31,0))?true:false;}"); - evalJS("myObject.mySignalWithDateTimeArg.connect(checkDate)"); - m_myObject->emitMySignalWithDateTimeArg(localdt); - QCOMPARE(evalJS("window.__date_equals"), sTrue); - evalJS("delete window.__date_equals"); - m_myObject->emitMySignalWithDateTimeArg(utclocaldt); - QCOMPARE(evalJS("window.__date_equals"), sTrue); - evalJS("delete window.__date_equals"); - evalJS("myObject.mySignalWithDateTimeArg.disconnect(checkDate); delete checkDate;"); - - // UTC - evalJS("function checkDate(d) {window.__date_equals = (d.toString() == new Date(Date.UTC(2008,0,18,12,31,0)))?true:false; }"); - evalJS("myObject.mySignalWithDateTimeArg.connect(checkDate)"); - m_myObject->emitMySignalWithDateTimeArg(utcdt); - QCOMPARE(evalJS("window.__date_equals"), sTrue); - evalJS("delete window.__date_equals"); - evalJS("myObject.mySignalWithDateTimeArg.disconnect(checkDate); delete checkDate;"); -} - -class StringListTestObject : public QObject { - Q_OBJECT -public Q_SLOTS: - QVariant stringList() - { - return QStringList() << "Q" << "t"; - }; -}; - -void tst_QObjectBridge::arrayObjectEnumerable() -{ - QWebPage page; - QWebFrame* frame = page.mainFrame(); - QObject* qobject = new StringListTestObject(); - frame->addToJavaScriptWindowObject("test", qobject, QWebFrame::ScriptOwnership); - - const QString script("var stringArray = test.stringList();" - "var result = '';" - "for (var i in stringArray) {" - " result += stringArray[i];" - "}" - "result;"); - QCOMPARE(frame->evaluateJavaScript(script).toString(), QString::fromLatin1("Qt")); -} - -void tst_QObjectBridge::domCycles() -{ - m_view->setHtml(""); - QVariant v = m_page->mainFrame()->evaluateJavaScript("document"); - QVERIFY(v.type() == QVariant::Map); -} - -void tst_QObjectBridge::jsByteArray() -{ - QByteArray ba("hello world"); - m_myObject->setByteArrayProperty(ba); - - // read-only property - QCOMPARE(m_myObject->byteArrayProperty(), ba); - QString type; - QVariant v = evalJSV("myObject.byteArrayProperty"); - QCOMPARE(int(v.type()), int(QVariant::ByteArray)); - - QCOMPARE(v.toByteArray(), ba); -} - -void tst_QObjectBridge::ownership() -{ - // test ownership - { - QPointer ptr = new QObject(); - QVERIFY(ptr); - { - QWebPage page; - QWebFrame* frame = page.mainFrame(); - frame->addToJavaScriptWindowObject("test", ptr.data(), QWebFrame::ScriptOwnership); - } - QVERIFY(!ptr); - } - { - QPointer ptr = new QObject(); - QVERIFY(ptr); - QObject* before = ptr.data(); - { - QWebPage page; - QWebFrame* frame = page.mainFrame(); - frame->addToJavaScriptWindowObject("test", ptr.data(), QWebFrame::QtOwnership); - } - QVERIFY(ptr.data() == before); - delete ptr.data(); - } - { - QObject* parent = new QObject(); - QObject* child = new QObject(parent); - QWebPage page; - QWebFrame* frame = page.mainFrame(); - frame->addToJavaScriptWindowObject("test", child, QWebFrame::QtOwnership); - QVariant v = frame->evaluateJavaScript("test"); - QCOMPARE(qvariant_cast(v), child); - delete parent; - v = frame->evaluateJavaScript("test"); - QCOMPARE(qvariant_cast(v), (QObject *)0); - } - { - QPointer ptr = new QObject(); - QVERIFY(ptr); - { - QWebPage page; - QWebFrame* frame = page.mainFrame(); - frame->addToJavaScriptWindowObject("test", ptr.data(), QWebFrame::AutoOwnership); - } - // no parent, so it should be like ScriptOwnership - QVERIFY(!ptr); - } - { - QObject* parent = new QObject(); - QPointer child = new QObject(parent); - QVERIFY(child); - { - QWebPage page; - QWebFrame* frame = page.mainFrame(); - frame->addToJavaScriptWindowObject("test", child.data(), QWebFrame::AutoOwnership); - } - // has parent, so it should be like QtOwnership - QVERIFY(child); - delete parent; - } -} - -void tst_QObjectBridge::nullValue() -{ - QVariant v = m_view->page()->mainFrame()->evaluateJavaScript("null"); - QVERIFY(v.isNull()); -} - -class TestFactory : public QObject { - Q_OBJECT -public: - TestFactory() - : obj(0), counter(0) - { } - - Q_INVOKABLE QObject* getNewObject() - { - delete obj; - obj = new QObject(this); - obj->setObjectName(QLatin1String("test") + QString::number(++counter)); - return obj; - - } - - QObject* obj; - int counter; -}; - -void tst_QObjectBridge::qObjectWrapperWithSameIdentity() -{ - m_view->setHtml("" - "test"); - - QWebFrame* mainFrame = m_view->page()->mainFrame(); - QCOMPARE(mainFrame->toPlainText(), QString("test")); - - mainFrame->addToJavaScriptWindowObject("test", new TestFactory, QWebFrame::ScriptOwnership); - - mainFrame->evaluateJavaScript("triggerBug();"); - QCOMPARE(mainFrame->toPlainText(), QString("test1")); - - mainFrame->evaluateJavaScript("triggerBug();"); - QCOMPARE(mainFrame->toPlainText(), QString("test2")); -} - -void tst_QObjectBridge::introspectQtMethods_data() -{ - QTest::addColumn("objectExpression"); - QTest::addColumn("methodName"); - QTest::addColumn("expectedPropertyNames"); - - QTest::newRow("myObject.mySignal") - << "myObject" << "mySignal" << (QStringList() << "connect" << "disconnect" << "name"); - QTest::newRow("myObject.mySlot") - << "myObject" << "mySlot" << (QStringList() << "connect" << "disconnect" << "name"); - QTest::newRow("myObject.myInvokable") - << "myObject" << "myInvokable" << (QStringList() << "connect" << "disconnect" << "name"); - QTest::newRow("myObject.mySignal.connect") - << "myObject.mySignal" << "connect" << (QStringList() << "name"); - QTest::newRow("myObject.mySignal.disconnect") - << "myObject.mySignal" << "disconnect" << (QStringList() << "name"); -} - -void tst_QObjectBridge::introspectQtMethods() -{ - QFETCH(QString, objectExpression); - QFETCH(QString, methodName); - QFETCH(QStringList, expectedPropertyNames); - - QString methodLookup = QString::fromLatin1("%0['%1']").arg(objectExpression).arg(methodName); - QCOMPARE(evalJSV(QString::fromLatin1("Object.getOwnPropertyNames(%0).sort()").arg(methodLookup)).toStringList(), expectedPropertyNames); - - for (int i = 0; i < expectedPropertyNames.size(); ++i) { - QString name = expectedPropertyNames.at(i); - QCOMPARE(evalJS(QString::fromLatin1("%0.hasOwnProperty('%1')").arg(methodLookup).arg(name)), sTrue); - evalJS(QString::fromLatin1("var descriptor = Object.getOwnPropertyDescriptor(%0, '%1')").arg(methodLookup).arg(name)); - QCOMPARE(evalJS("typeof descriptor"), QString::fromLatin1("object")); - QCOMPARE(evalJS("descriptor.get"), sUndefined); - QCOMPARE(evalJS("descriptor.set"), sUndefined); - QCOMPARE(evalJS(QString::fromLatin1("descriptor.value === %0['%1']").arg(methodLookup).arg(name)), sTrue); - QCOMPARE(evalJS(QString::fromLatin1("descriptor.enumerable")), sFalse); - QCOMPARE(evalJS(QString::fromLatin1("descriptor.configurable")), sFalse); - } - - QVERIFY(evalJSV("var props=[]; for (var p in myObject.deleteLater) {props.push(p);}; props.sort()").toStringList().isEmpty()); -} - -void tst_QObjectBridge::webElementSlotOnly() -{ - MyWebElementSlotOnlyObject object; - m_page->mainFrame()->setHtml(""); - m_page->mainFrame()->addToJavaScriptWindowObject("myWebElementSlotObject", &object); - evalJS("myWebElementSlotObject.doSomethingWithWebElement(document.body)"); - QCOMPARE(evalJS("myWebElementSlotObject.tagName"), QString("BODY")); -} - -class TestPluginWidget : public QWidget { - Q_OBJECT -public: - TestPluginWidget() { } - -public Q_SLOTS: - int slotWithReturnValue() { return 42; } -}; - -class TestWebPage : public QWebPage { - Q_OBJECT -public: - TestWebPage(QObject* parent = 0) - : QWebPage(parent) - , creationCount(0) - { } - - int creationCount; - -protected: - virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) - { - creationCount++; - return new TestPluginWidget; - } -}; - -void tst_QObjectBridge::scriptablePlugin() -{ -//#if !PLUGIN_VIEW_IS_BROKEN - QWebView view; - TestWebPage* page = new TestWebPage; - view.setPage(page); - page->setParent(&view); - view.settings()->setAttribute(QWebSettings::PluginsEnabled, true); - - page->mainFrame()->setHtml(""); - QCOMPARE(page->creationCount, 1); - - QVariant result = page->mainFrame()->evaluateJavaScript("document.querySelector(\"object\").slotWithReturnValue()"); - QCOMPARE(result.toString(), QLatin1String("42")); -//#endif -} - -class WebPageWithConsoleCapture : public QWebPage -{ -public: - void javaScriptConsoleMessage(const QString &message, int, const QString &) - { - consoleMessages << message; - } - - QStringList consoleMessages; -}; - -void tst_QObjectBridge::exceptionInSlot() -{ - WebPageWithConsoleCapture page; - QWebFrame* frame = page.mainFrame(); - frame->addToJavaScriptWindowObject("myObject", m_myObject); - frame->evaluateJavaScript( - "myHandler = function() { window.gotSignal = true; throw 'exception in slot'; };" - "myObject.mySignal.connect(myHandler);" - "gotSignal = false;" - "myObject.mySignal();" - ); - QString ret = frame->evaluateJavaScript("gotSignal").toString(); - QCOMPARE(ret, sTrue); - QCOMPARE(page.consoleMessages, QStringList() << "exception in slot"); -} - -QTEST_MAIN(tst_QObjectBridge) -#include "tst_qobjectbridge.moc" diff --git a/Source/WebKit/qt/tests/qwebelement/resources/image.png b/Source/WebKit/qt/tests/qwebelement/resources/image.png deleted file mode 100644 index 8d703640c..000000000 Binary files a/Source/WebKit/qt/tests/qwebelement/resources/image.png and /dev/null differ diff --git a/Source/WebKit/qt/tests/qwebelement/resources/style.css b/Source/WebKit/qt/tests/qwebelement/resources/style.css deleted file mode 100644 index 2713dfda9..000000000 --- a/Source/WebKit/qt/tests/qwebelement/resources/style.css +++ /dev/null @@ -1 +0,0 @@ -#idP {color: black !important} diff --git a/Source/WebKit/qt/tests/qwebelement/resources/style2.css b/Source/WebKit/qt/tests/qwebelement/resources/style2.css deleted file mode 100644 index 6575dcb04..000000000 --- a/Source/WebKit/qt/tests/qwebelement/resources/style2.css +++ /dev/null @@ -1 +0,0 @@ -#idP {color: green ! important} diff --git a/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp deleted file mode 100644 index 4ca5fe5f9..000000000 --- a/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp +++ /dev/null @@ -1,1080 +0,0 @@ -/* - Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include -//TESTED_CLASS= -//TESTED_FILES= - -class tst_QWebElement : public QObject -{ - Q_OBJECT - -public: - tst_QWebElement(); - virtual ~tst_QWebElement(); - -public Q_SLOTS: - void init(); - void cleanup(); - -private Q_SLOTS: - void textHtml(); - void simpleCollection(); - void attributes(); - void attributesNS(); - void listAttributes(); - void classes(); - void namespaceURI(); - void iteration(); - void nonConstIterator(); - void constIterator(); - void foreachManipulation(); - void emptyCollection(); - void appendCollection(); - void evaluateJavaScript(); - void documentElement(); - void frame(); - void style(); - void computedStyle(); - void appendAndPrepend(); - void insertBeforeAndAfter(); - void remove(); - void clear(); - void replaceWith(); - void encloseWith(); - void encloseContentsWith(); - void nullSelect(); - void firstChildNextSibling(); - void lastChildPreviousSibling(); - void hasSetFocus(); - void render(); - void addElementToHead(); - -private: - QWebView* m_view { nullptr }; - QWebPage* m_page { nullptr }; - QWebFrame* m_mainFrame { nullptr }; -}; - -tst_QWebElement::tst_QWebElement() -{ -} - -tst_QWebElement::~tst_QWebElement() -{ -} - -void tst_QWebElement::init() -{ - m_view = new QWebView(); - m_page = m_view->page(); - m_mainFrame = m_page->mainFrame(); -} - -void tst_QWebElement::cleanup() -{ - delete m_view; -} - -void tst_QWebElement::textHtml() -{ - QString html = "

test

"; - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement(); - QVERIFY(!body.isNull()); - - QCOMPARE(body.toPlainText(), QString("test")); - QCOMPARE(body.toPlainText(), m_mainFrame->toPlainText()); - - QCOMPARE(body.toInnerXml(), html); -} - -void tst_QWebElement::simpleCollection() -{ - QString html = "

first para

second para

"; - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement(); - - QWebElementCollection list = body.findAll("p"); - QCOMPARE(list.count(), 2); - QCOMPARE(list.at(0).toPlainText(), QString("first para")); - QCOMPARE(list.at(1).toPlainText(), QString("second para")); -} - -void tst_QWebElement::attributes() -{ - m_mainFrame->setHtml("

Test"); - QWebElement body = m_mainFrame->documentElement(); - - QVERIFY(!body.hasAttribute("title")); - QVERIFY(!body.hasAttributes()); - - body.setAttribute("title", "test title"); - - QVERIFY(body.hasAttributes()); - QVERIFY(body.hasAttribute("title")); - - QCOMPARE(body.attribute("title"), QString("test title")); - - body.removeAttribute("title"); - - QVERIFY(!body.hasAttribute("title")); - QVERIFY(!body.hasAttributes()); - - QCOMPARE(body.attribute("does-not-exist", "testvalue"), QString("testvalue")); -} - -void tst_QWebElement::attributesNS() -{ - QString content = "" - "" - ""; - - m_mainFrame->setContent(content.toUtf8(), "application/xhtml+xml"); - - QWebElement svg = m_mainFrame->findFirstElement("svg"); - QVERIFY(!svg.isNull()); - - QVERIFY(!svg.hasAttributeNS("http://www.w3.org/2000/svg", "foobar")); - QCOMPARE(svg.attributeNS("http://www.w3.org/2000/svg", "foobar", "defaultblah"), QString("defaultblah")); - svg.setAttributeNS("http://www.w3.org/2000/svg", "svg:foobar", "true"); - QVERIFY(svg.hasAttributeNS("http://www.w3.org/2000/svg", "foobar")); - QCOMPARE(svg.attributeNS("http://www.w3.org/2000/svg", "foobar", "defaultblah"), QString("true")); -} - -void tst_QWebElement::listAttributes() -{ - QString content = "" - "" - ""; - - m_mainFrame->setContent(content.toUtf8(), "application/xhtml+xml"); - - QWebElement svg = m_mainFrame->findFirstElement("svg"); - QVERIFY(!svg.isNull()); - - QVERIFY(svg.attributeNames().contains("foo")); - QVERIFY(svg.attributeNames("http://www.w3.org/2000/svg").contains("bar")); - - svg.setAttributeNS("http://www.w3.org/2000/svg", "svg:foobar", "true"); - QVERIFY(svg.attributeNames().contains("foo")); - QStringList attributes = svg.attributeNames("http://www.w3.org/2000/svg"); - QCOMPARE(attributes.size(), 2); - QVERIFY(attributes.contains("bar")); - QVERIFY(attributes.contains("foobar")); -} - -void tst_QWebElement::classes() -{ - m_mainFrame->setHtml("

Test"); - - QWebElement body = m_mainFrame->documentElement(); - QCOMPARE(body.classes().count(), 0); - - QWebElement p = m_mainFrame->documentElement().findAll("p").at(0); - QStringList classes = p.classes(); - QCOMPARE(classes.count(), 4); - QCOMPARE(classes[0], QLatin1String("a")); - QCOMPARE(classes[1], QLatin1String("b")); - QCOMPARE(classes[2], QLatin1String("c")); - QCOMPARE(classes[3], QLatin1String("d")); - QVERIFY(p.hasClass("a")); - QVERIFY(p.hasClass("b")); - QVERIFY(p.hasClass("c")); - QVERIFY(p.hasClass("d")); - QVERIFY(!p.hasClass("e")); - - p.addClass("f"); - QVERIFY(p.hasClass("f")); - p.addClass("a"); - QCOMPARE(p.classes().count(), 5); - QVERIFY(p.hasClass("a")); - QVERIFY(p.hasClass("b")); - QVERIFY(p.hasClass("c")); - QVERIFY(p.hasClass("d")); - - p.toggleClass("a"); - QVERIFY(!p.hasClass("a")); - QVERIFY(p.hasClass("b")); - QVERIFY(p.hasClass("c")); - QVERIFY(p.hasClass("d")); - QVERIFY(p.hasClass("f")); - QCOMPARE(p.classes().count(), 4); - p.toggleClass("f"); - QVERIFY(!p.hasClass("f")); - QCOMPARE(p.classes().count(), 3); - p.toggleClass("a"); - p.toggleClass("f"); - QVERIFY(p.hasClass("a")); - QVERIFY(p.hasClass("f")); - QCOMPARE(p.classes().count(), 5); - - p.removeClass("f"); - QVERIFY(!p.hasClass("f")); - QCOMPARE(p.classes().count(), 4); - p.removeClass("d"); - QVERIFY(!p.hasClass("d")); - QCOMPARE(p.classes().count(), 3); - p.removeClass("not-exist"); - QCOMPARE(p.classes().count(), 3); - p.removeClass("c"); - QVERIFY(!p.hasClass("c")); - QCOMPARE(p.classes().count(), 2); - p.removeClass("b"); - QVERIFY(!p.hasClass("b")); - QCOMPARE(p.classes().count(), 1); - p.removeClass("a"); - QVERIFY(!p.hasClass("a")); - QCOMPARE(p.classes().count(), 0); - p.removeClass("foobar"); - QCOMPARE(p.classes().count(), 0); -} - -void tst_QWebElement::namespaceURI() -{ - QString content = "" - "" - ""; - - m_mainFrame->setContent(content.toUtf8(), "application/xhtml+xml"); - QWebElement body = m_mainFrame->documentElement(); - QCOMPARE(body.namespaceUri(), QLatin1String("http://www.w3.org/1999/xhtml")); - - QWebElement svg = body.findAll("*#foobar").at(0); - QCOMPARE(svg.prefix(), QLatin1String("svg")); - QCOMPARE(svg.localName(), QLatin1String("svg")); - QCOMPARE(svg.tagName(), QLatin1String("svg:svg")); - QCOMPARE(svg.namespaceUri(), QLatin1String("http://www.w3.org/2000/svg")); - -} - -void tst_QWebElement::iteration() -{ - QString html = "

first para

second para

"; - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement(); - - QWebElementCollection paras = body.findAll("p"); - QList referenceList = paras.toList(); - - QList foreachList; - foreach(QWebElement p, paras) { - foreachList.append(p); - } - QVERIFY(foreachList.count() == 2); - QCOMPARE(foreachList.count(), referenceList.count()); - QCOMPARE(foreachList.at(0), referenceList.at(0)); - QCOMPARE(foreachList.at(1), referenceList.at(1)); - - QList forLoopList; - for (int i = 0; i < paras.count(); ++i) { - forLoopList.append(paras.at(i)); - } - QVERIFY(foreachList.count() == 2); - QCOMPARE(foreachList.count(), referenceList.count()); - QCOMPARE(foreachList.at(0), referenceList.at(0)); - QCOMPARE(foreachList.at(1), referenceList.at(1)); - - for (int i = 0; i < paras.count(); ++i) { - QCOMPARE(paras.at(i), paras[i]); - } - - QCOMPARE(paras.at(0), paras.first()); - QCOMPARE(paras.at(1), paras.last()); -} - -void tst_QWebElement::nonConstIterator() -{ - QString html = "

first para

second para

"; - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement(); - QWebElementCollection paras = body.findAll("p"); - - QWebElementCollection::iterator it = paras.begin(); - QCOMPARE(*it, paras.at(0)); - ++it; - (*it).encloseWith("
"); - QCOMPARE(*it, paras.at(1)); - ++it; - QCOMPARE(it, paras.end()); -} - -void tst_QWebElement::constIterator() -{ - QString html = "

first para

second para

"; - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement(); - const QWebElementCollection paras = body.findAll("p"); - - QWebElementCollection::const_iterator it = paras.begin(); - QCOMPARE(*it, paras.at(0)); - ++it; - QCOMPARE(*it, paras.at(1)); - ++it; - QCOMPARE(it, paras.end()); -} - -void tst_QWebElement::foreachManipulation() -{ - QString html = "

first para

second para

"; - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement(); - - foreach(QWebElement p, body.findAll("p")) { - p.setInnerXml("
foo
bar
"); - } - - QCOMPARE(body.findAll("div").count(), 4); -} - -void tst_QWebElement::emptyCollection() -{ - QWebElementCollection emptyCollection; - QCOMPARE(emptyCollection.count(), 0); -} - -void tst_QWebElement::appendCollection() -{ - QString html = "aaa

first para

foo
" - "bbb

second para

bar
"; - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement(); - - QWebElementCollection collection = body.findAll("p"); - QCOMPARE(collection.count(), 2); - - collection.append(body.findAll("div")); - QCOMPARE(collection.count(), 4); - - collection += body.findAll("span.a"); - QCOMPARE(collection.count(), 5); - - QWebElementCollection all = collection + body.findAll("span.b"); - QCOMPARE(all.count(), 6); - QCOMPARE(collection.count(), 5); - - all += collection; - QCOMPARE(all.count(), 11); - - QCOMPARE(collection.count(), 5); - QWebElementCollection test; - test.append(collection); - QCOMPARE(test.count(), 5); - test.append(QWebElementCollection()); - QCOMPARE(test.count(), 5); -} - -void tst_QWebElement::evaluateJavaScript() -{ - QVariant result; - m_mainFrame->setHtml("

test"); - QWebElement para = m_mainFrame->findFirstElement("p"); - - result = para.evaluateJavaScript("this.tagName"); - QVERIFY(result.isValid()); - QVERIFY(result.type() == QVariant::String); - QCOMPARE(result.toString(), QLatin1String("P")); - - result = para.evaluateJavaScript("this.hasAttributes()"); - QVERIFY(result.isValid()); - QVERIFY(result.type() == QVariant::Bool); - QVERIFY(!result.toBool()); - - para.evaluateJavaScript("this.setAttribute('align', 'left');"); - QCOMPARE(para.attribute("align"), QLatin1String("left")); - - result = para.evaluateJavaScript("this.hasAttributes()"); - QVERIFY(result.isValid()); - QVERIFY(result.type() == QVariant::Bool); - QVERIFY(result.toBool()); -} - -void tst_QWebElement::documentElement() -{ - m_mainFrame->setHtml("

Test"); - - QWebElement para = m_mainFrame->documentElement().findAll("p").at(0); - QVERIFY(para.parent().parent() == m_mainFrame->documentElement()); - QVERIFY(para.document() == m_mainFrame->documentElement()); -} - -void tst_QWebElement::frame() -{ - m_mainFrame->setHtml("

test"); - - QWebElement doc = m_mainFrame->documentElement(); - QVERIFY(doc.webFrame() == m_mainFrame); - - m_mainFrame->load(QUrl("data:text/html,frame1\">" - "frame2\">")); - - waitForSignal(m_page, SIGNAL(loadFinished(bool))); - - QCOMPARE(m_mainFrame->childFrames().count(), 2); - - QWebFrame* firstFrame = m_mainFrame->childFrames().at(0); - QWebFrame* secondFrame = m_mainFrame->childFrames().at(1); - - QCOMPARE(firstFrame->toPlainText(), QString("frame1")); - QCOMPARE(secondFrame->toPlainText(), QString("frame2")); - - QWebElement firstPara = firstFrame->documentElement().findAll("p").at(0); - QWebElement secondPara = secondFrame->documentElement().findAll("p").at(0); - - QVERIFY(firstPara.webFrame() == firstFrame); - QVERIFY(secondPara.webFrame() == secondFrame); -} - -void tst_QWebElement::style() -{ - QString html = "" - "" - "" - "" - "

some text

" - ""; - - m_mainFrame->setHtml(html); - - QWebElement p = m_mainFrame->documentElement().findAll("p").at(0); - QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); - QVERIFY(p.styleProperty("cursor", QWebElement::InlineStyle).isEmpty()); - - p.setStyleProperty("color", "red"); - p.setStyleProperty("cursor", "auto"); - - QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("red")); - QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("yellow")); - QCOMPARE(p.styleProperty("cursor", QWebElement::InlineStyle), QLatin1String("auto")); - - p.setStyleProperty("color", "green !important"); - QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("green")); - QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("green")); - - p.setStyleProperty("color", "blue"); - // A current important InlineStyle shouldn't be overwritten by a non-important one. - QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("green")); - QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("green")); - - p.setStyleProperty("color", "blue !important"); - QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); - QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue")); - - QString html2 = "" - "" - "" - "" - "

some text

" - ""; - - m_mainFrame->setHtml(html2); - p = m_mainFrame->documentElement().findAll("p").at(0); - - QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); - QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue")); - - QString html3 = "" - "" - "" - "" - "

some text

" - ""; - - m_mainFrame->setHtml(html3); - p = m_mainFrame->documentElement().findAll("p").at(0); - - QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); - QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue")); - - QString html5 = "" - "" - "" - "" - "

some text

" - ""; - - m_mainFrame->setHtml(html5); - p = m_mainFrame->documentElement().findAll("p").at(0); - - QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("")); - QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("red")); - - QString html6 = "" - "" - "" - "" - "" - "

some text

" - ""; - - // in few seconds, the CSS should be completey loaded - m_mainFrame->setHtml(html6); - waitForSignal(m_page, SIGNAL(loadFinished(bool)), 200); - - p = m_mainFrame->documentElement().findAll("p").at(0); - QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); - QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("black")); - - QString html7 = "" - "" - "" - "" - "" - "

some text

" - ""; - - // in few seconds, the style should be completey loaded - m_mainFrame->setHtml(html7); - waitForSignal(m_page, SIGNAL(loadFinished(bool)), 200); - - p = m_mainFrame->documentElement().findAll("p").at(0); - QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("black")); - - QString html8 = "

some text

"; - - m_mainFrame->setHtml(html8); - p = m_mainFrame->documentElement().findAll("p").at(0); - - QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("")); - QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("")); -} - -void tst_QWebElement::computedStyle() -{ - QString html = "

some text

"; - m_mainFrame->setHtml(html); - - QWebElement p = m_mainFrame->documentElement().findAll("p").at(0); - QCOMPARE(p.styleProperty("cursor", QWebElement::ComputedStyle), QLatin1String("auto")); - QVERIFY(!p.styleProperty("cursor", QWebElement::ComputedStyle).isEmpty()); - QVERIFY(p.styleProperty("cursor", QWebElement::InlineStyle).isEmpty()); - - p.setStyleProperty("cursor", "text"); - p.setStyleProperty("color", "red"); - - QCOMPARE(p.styleProperty("cursor", QWebElement::ComputedStyle), QLatin1String("text")); - QCOMPARE(p.styleProperty("color", QWebElement::ComputedStyle), QLatin1String("rgb(255, 0, 0)")); - QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("red")); -} - -void tst_QWebElement::appendAndPrepend() -{ - QString html = "" - "

" - "foo" - "

" - "

" - "bar" - "

" - ""; - - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement().findFirst("body"); - - QCOMPARE(body.findAll("p").count(), 2); - body.appendInside(body.findFirst("p")); - QCOMPARE(body.findAll("p").count(), 2); - QCOMPARE(body.findFirst("p").toPlainText(), QString("bar")); - QCOMPARE(body.findAll("p").last().toPlainText(), QString("foo")); - - body.appendInside(body.findFirst("p").clone()); - QCOMPARE(body.findAll("p").count(), 3); - QCOMPARE(body.findFirst("p").toPlainText(), QString("bar")); - QCOMPARE(body.findAll("p").last().toPlainText(), QString("bar")); - - body.prependInside(body.findAll("p").at(1).clone()); - QCOMPARE(body.findAll("p").count(), 4); - QCOMPARE(body.findFirst("p").toPlainText(), QString("foo")); - - body.findFirst("p").appendInside("
booyakasha
"); - QCOMPARE(body.findAll("p div").count(), 1); - QCOMPARE(body.findFirst("p div").toPlainText(), QString("booyakasha")); - - body.findFirst("div").prependInside("yepp"); - QCOMPARE(body.findAll("p div code").count(), 1); - QCOMPARE(body.findFirst("p div code").toPlainText(), QString("yepp")); - - // Inserting HTML into an img tag is not allowed, but appending/prepending outside is. - body.findFirst("div").appendInside(""); - QCOMPARE(body.findAll("p div img").count(), 1); - - QWebElement img = body.findFirst("img"); - QVERIFY(!img.isNull()); - img.appendInside("

"); - QCOMPARE(body.findAll("p#fail1").count(), 0); - - img.appendOutside("

"); - QCOMPARE(body.findAll("p#success1").count(), 1); - - img.prependInside("

"); - QCOMPARE(body.findAll("p#fail2").count(), 0); - - img.prependOutside("

"); - QCOMPARE(body.findAll("p#success2").count(), 1); - - -} - -void tst_QWebElement::insertBeforeAndAfter() -{ - QString html = "" - "

" - "foo" - "

" - "
" - "yeah" - "
" - "

" - "bar" - "

" - ""; - - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement().findFirst("body"); - QWebElement div = body.findFirst("div"); - - QCOMPARE(body.findAll("p").count(), 2); - QCOMPARE(body.findAll("div").count(), 1); - - div.prependOutside(body.findAll("p").last().clone()); - QCOMPARE(body.findAll("p").count(), 3); - QCOMPARE(body.findAll("p").at(0).toPlainText(), QString("foo")); - QCOMPARE(body.findAll("p").at(1).toPlainText(), QString("bar")); - QCOMPARE(body.findAll("p").at(2).toPlainText(), QString("bar")); - - div.appendOutside(body.findFirst("p").clone()); - QCOMPARE(body.findAll("p").count(), 4); - QCOMPARE(body.findAll("p").at(0).toPlainText(), QString("foo")); - QCOMPARE(body.findAll("p").at(1).toPlainText(), QString("bar")); - QCOMPARE(body.findAll("p").at(2).toPlainText(), QString("foo")); - QCOMPARE(body.findAll("p").at(3).toPlainText(), QString("bar")); - - div.prependOutside("hey"); - QCOMPARE(body.findAll("span").count(), 1); - - div.appendOutside("there"); - QCOMPARE(body.findAll("span").count(), 2); - QCOMPARE(body.findAll("span").at(0).toPlainText(), QString("hey")); - QCOMPARE(body.findAll("span").at(1).toPlainText(), QString("there")); -} - -void tst_QWebElement::remove() -{ - QString html = "" - "

" - "foo" - "

" - "
" - "

yeah

" - "
" - "

" - "bar" - "

" - ""; - - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement().findFirst("body"); - - QCOMPARE(body.findAll("div").count(), 1); - QCOMPARE(body.findAll("p").count(), 3); - - QWebElement div = body.findFirst("div"); - div.takeFromDocument(); - - QCOMPARE(div.isNull(), false); - QCOMPARE(body.findAll("div").count(), 0); - QCOMPARE(body.findAll("p").count(), 2); - - body.appendInside(div); - - QCOMPARE(body.findAll("div").count(), 1); - QCOMPARE(body.findAll("p").count(), 3); -} - -void tst_QWebElement::clear() -{ - QString html = "" - "

" - "foo" - "

" - "
" - "

yeah

" - "
" - "

" - "bar" - "

" - ""; - - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement().findFirst("body"); - - QCOMPARE(body.findAll("div").count(), 1); - QCOMPARE(body.findAll("p").count(), 3); - body.findFirst("div").removeAllChildren(); - QCOMPARE(body.findAll("div").count(), 1); - QCOMPARE(body.findAll("p").count(), 2); -} - - -void tst_QWebElement::replaceWith() -{ - QString html = "" - "

" - "foo" - "

" - "
" - "yeah" - "
" - "

" - "haba" - "

" - ""; - - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement().findFirst("body"); - - QCOMPARE(body.findAll("div").count(), 1); - QCOMPARE(body.findAll("span").count(), 1); - body.findFirst("div").replace(body.findFirst("span").clone()); - QCOMPARE(body.findAll("div").count(), 0); - QCOMPARE(body.findAll("span").count(), 2); - QCOMPARE(body.findAll("p").count(), 2); - - body.findFirst("span").replace("

wow

"); - QCOMPARE(body.findAll("p").count(), 3); - QCOMPARE(body.findAll("p code").count(), 1); - QCOMPARE(body.findFirst("p code").toPlainText(), QString("wow")); -} - -void tst_QWebElement::encloseContentsWith() -{ - QString html = "" - "
" - "" - "yeah" - "" - "" - "hello" - "" - "
" - "

" - "foo" - "bar" - "

" - "" - "" - "hey" - ""; - - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement().findFirst("body"); - - body.findFirst("p").encloseContentsWith(body.findFirst("b")); - QCOMPARE(body.findAll("p b span").count(), 2); - QCOMPARE(body.findFirst("p b span").toPlainText(), QString("foo")); - - body.findFirst("u").encloseContentsWith(""); - QCOMPARE(body.findAll("u i").count(), 1); - QCOMPARE(body.findFirst("u i").toPlainText(), QString()); - - body.findFirst("div").encloseContentsWith(""); - QCOMPARE(body.findAll("div span i").count(), 2); - QCOMPARE(body.findFirst("div span i").toPlainText(), QString("yeah")); - - QString snippet = "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "
"; - - body.findFirst("em").encloseContentsWith(snippet); - QCOMPARE(body.findFirst("em table tbody tr td").toPlainText(), QString("hey")); -} - -void tst_QWebElement::encloseWith() -{ - QString html = "" - "

" - "foo" - "

" - "
" - "yeah" - "
" - "

" - "bar" - "

" - "hey" - "

hello

" - ""; - - m_mainFrame->setHtml(html); - QWebElement body = m_mainFrame->documentElement().findFirst("body"); - - body.findFirst("p").encloseWith("
"); - QCOMPARE(body.findAll("br").count(), 0); - - QCOMPARE(body.findAll("div").count(), 1); - body.findFirst("div").encloseWith(body.findFirst("span").clone()); - QCOMPARE(body.findAll("div").count(), 1); - QCOMPARE(body.findAll("span").count(), 2); - QCOMPARE(body.findAll("p").count(), 2); - - body.findFirst("div").encloseWith(""); - QCOMPARE(body.findAll("code").count(), 1); - QCOMPARE(body.findAll("code div").count(), 1); - QCOMPARE(body.findFirst("code div").toPlainText(), QString("yeah")); - - QString snippet = "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "
"; - - body.findFirst("em").encloseWith(snippet); - QCOMPARE(body.findFirst("table tbody tr td em").toPlainText(), QString("hey")); - - // Enclosing the contents of an img tag is not allowed, but enclosing the img tag itself is. - body.findFirst("td").appendInside(""); - QCOMPARE(body.findAll("img").count(), 1); - - QWebElement img = body.findFirst("img"); - QVERIFY(!img.isNull()); - img.encloseWith("

"); - QCOMPARE(body.findAll("p#success").count(), 1); - - img.encloseContentsWith("

"); - QCOMPARE(body.findAll("p#fail").count(), 0); - -} - -void tst_QWebElement::nullSelect() -{ - m_mainFrame->setHtml("

Test"); - - QWebElementCollection collection = m_mainFrame->findAllElements("invalid{syn(tax;;%#$f223e>>"); - QVERIFY(collection.count() == 0); -} - -void tst_QWebElement::firstChildNextSibling() -{ - m_mainFrame->setHtml("

Test

"); - - QWebElement body = m_mainFrame->findFirstElement("body"); - QVERIFY(!body.isNull()); - QWebElement p = body.firstChild(); - QVERIFY(!p.isNull()); - QCOMPARE(p.tagName(), QString("P")); - QWebElement table = p.nextSibling(); - QVERIFY(!table.isNull()); - QCOMPARE(table.tagName(), QString("TABLE")); - QVERIFY(table.nextSibling().isNull()); -} - -void tst_QWebElement::lastChildPreviousSibling() -{ - m_mainFrame->setHtml("

Test

"); - - QWebElement body = m_mainFrame->findFirstElement("body"); - QVERIFY(!body.isNull()); - QWebElement table = body.lastChild(); - QVERIFY(!table.isNull()); - QCOMPARE(table.tagName(), QString("TABLE")); - QWebElement p = table.previousSibling(); - QVERIFY(!p.isNull()); - QCOMPARE(p.tagName(), QString("P")); - QVERIFY(p.previousSibling().isNull()); -} - -void tst_QWebElement::hasSetFocus() -{ - m_mainFrame->setHtml("" \ - "" \ - "
"\ - "" \ - ""); - - QWebElementCollection inputs = m_mainFrame->documentElement().findAll("input"); - QWebElement input1 = inputs.at(0); - input1.setFocus(); - QVERIFY(input1.hasFocus()); - - QWebElement input2 = inputs.at(1); - input2.setFocus(); - QVERIFY(!input1.hasFocus()); - QVERIFY(input2.hasFocus()); -} - -void tst_QWebElement::render() -{ - QString html( "" - "" - "
" - "" - "" - "" - "" - "
test" - "" - "
" - "" - "" - ); - - QWebPage page; - QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); - page.mainFrame()->setHtml(html); - - waitForSignal(&page, SIGNAL(loadFinished(bool))); - QCOMPARE(loadSpy.count(), 1); - - QSize size = page.mainFrame()->contentsSize(); - page.setViewportSize(size); - - QWebElementCollection imgs = page.mainFrame()->findAllElements("img"); - QCOMPARE(imgs.count(), 1); - - QImage resource(":/image.png"); - QRect imageRect(0, 0, resource.width(), resource.height()); - - QImage testImage(resource.width(), resource.height(), QImage::Format_ARGB32); - QPainter painter0(&testImage); - painter0.fillRect(imageRect, Qt::white); - // render() uses pixmaps internally, and pixmaps might have bit depths - // other than 32, giving different pixel values due to rounding. - QPixmap pix = QPixmap::fromImage(resource); - painter0.drawPixmap(0, 0, pix); - painter0.end(); - - QImage image1(resource.width(), resource.height(), QImage::Format_ARGB32); - QPainter painter1(&image1); - painter1.fillRect(imageRect, Qt::white); - imgs[0].render(&painter1); - painter1.end(); - - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=65243", Continue); - QVERIFY(image1 == testImage); - - // render image 2nd time to make sure that cached rendering works fine - QImage image2(resource.width(), resource.height(), QImage::Format_ARGB32); - QPainter painter2(&image2); - painter2.fillRect(imageRect, Qt::white); - imgs[0].render(&painter2); - painter2.end(); - - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=65243", Continue); - QVERIFY(image2 == testImage); - - // compare table rendered through QWebElement::render to whole page table rendering - QRect tableRect(0, 0, 300, 300); - QWebElementCollection tables = page.mainFrame()->findAllElements("table"); - QCOMPARE(tables.count(), 1); - - QImage image3(300, 300, QImage::Format_ARGB32); - QPainter painter3(&image3); - painter3.fillRect(tableRect, Qt::white); - tables[0].render(&painter3); - painter3.end(); - - QImage image4(300, 300, QImage::Format_ARGB32); - QPainter painter4(&image4); - page.mainFrame()->render(&painter4, tableRect); - painter4.end(); - - QVERIFY(image3 == image4); - - // Chunked render test reuses page rendered in image4 in previous test - const int chunkHeight = tableRect.height(); - const int chunkWidth = tableRect.width() / 3; - QImage chunk(chunkWidth, chunkHeight, QImage::Format_ARGB32); - QRect chunkRect(0, 0, chunkWidth, chunkHeight); - for (int x = 0; x < tableRect.width(); x += chunkWidth) { - QPainter painter(&chunk); - painter.fillRect(chunkRect, Qt::white); - QRect chunkPaintRect(x, 0, chunkWidth, chunkHeight); - tables[0].render(&painter, chunkPaintRect); - painter.end(); - - QVERIFY(chunk == image4.copy(chunkPaintRect)); - } -} - -void tst_QWebElement::addElementToHead() -{ - m_mainFrame->setHtml(""); - QWebElement head = m_mainFrame->findFirstElement("head"); - QVERIFY(!head.isNull()); - QString append = ""; - head.appendInside(append); - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=102234", Continue); - QCOMPARE(head.toInnerXml(), append); -} - -QTEST_MAIN(tst_QWebElement) -#include "tst_qwebelement.moc" diff --git a/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.qrc b/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.qrc deleted file mode 100644 index 7384c76e0..000000000 --- a/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - -resources/style.css -resources/style2.css -resources/image.png - - diff --git a/Source/WebKit/qt/tests/qwebframe/resources/image.png b/Source/WebKit/qt/tests/qwebframe/resources/image.png deleted file mode 100644 index 8d703640c..000000000 Binary files a/Source/WebKit/qt/tests/qwebframe/resources/image.png and /dev/null differ diff --git a/Source/WebKit/qt/tests/qwebframe/resources/style.css b/Source/WebKit/qt/tests/qwebframe/resources/style.css deleted file mode 100644 index c05b747f1..000000000 --- a/Source/WebKit/qt/tests/qwebframe/resources/style.css +++ /dev/null @@ -1 +0,0 @@ -#idP {color: red !important} diff --git a/Source/WebKit/qt/tests/qwebframe/resources/test1.html b/Source/WebKit/qt/tests/qwebframe/resources/test1.html deleted file mode 100644 index b323f966e..000000000 --- a/Source/WebKit/qt/tests/qwebframe/resources/test1.html +++ /dev/null @@ -1 +0,0 @@ -

Some text 1

diff --git a/Source/WebKit/qt/tests/qwebframe/resources/test2.html b/Source/WebKit/qt/tests/qwebframe/resources/test2.html deleted file mode 100644 index 63ac1f6ec..000000000 --- a/Source/WebKit/qt/tests/qwebframe/resources/test2.html +++ /dev/null @@ -1 +0,0 @@ -

Some text 2

diff --git a/Source/WebKit/qt/tests/qwebframe/resources/testiframe.html b/Source/WebKit/qt/tests/qwebframe/resources/testiframe.html deleted file mode 100644 index ee0f64d1b..000000000 --- a/Source/WebKit/qt/tests/qwebframe/resources/testiframe.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - -
You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. -You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. -You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. -You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. -You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. -You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible.
- - - - \ No newline at end of file diff --git a/Source/WebKit/qt/tests/qwebframe/resources/testiframe2.html b/Source/WebKit/qt/tests/qwebframe/resources/testiframe2.html deleted file mode 100644 index 483e94e1d..000000000 --- a/Source/WebKit/qt/tests/qwebframe/resources/testiframe2.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - -
- - \ No newline at end of file diff --git a/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp deleted file mode 100644 index 2068eec3f..000000000 --- a/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ /dev/null @@ -1,1599 +0,0 @@ -/* - Copyright (C) 2008,2009 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef QT_NO_OPENSSL -#include -#endif -#include "../util.h" - -class tst_QWebFrame : public QObject -{ - Q_OBJECT - -public: - bool eventFilter(QObject* watched, QEvent* event); - -public Q_SLOTS: - void init(); - void cleanup(); - -private Q_SLOTS: - void horizontalScrollAfterBack(); - void symmetricUrl(); - void progressSignal(); - void urlChange(); - void requestedUrl(); - void requestedUrlAfterSetAndLoadFailures(); - void javaScriptWindowObjectCleared_data(); - void javaScriptWindowObjectCleared(); - void javaScriptWindowObjectClearedOnEvaluate(); - void setHtml(); - void setHtmlWithImageResource(); - void setHtmlWithStylesheetResource(); - void setHtmlWithBaseURL(); - void setHtmlWithJSAlert(); - void ipv6HostEncoding(); - void metaData(); -#if !defined(QT_NO_COMBOBOX) - void popupFocus(); -#endif - void inputFieldFocus(); - void hitTestContent(); - void baseUrl_data(); - void baseUrl(); - void hasSetFocus(); - void renderGeometry(); - void renderHints(); - void scrollPosition(); - void scrollToAnchor(); - void scrollbarsOff(); - void evaluateWillCauseRepaint(); - void setContent_data(); - void setContent(); - void setCacheLoadControlAttribute(); - void setUrlWithPendingLoads(); - void setUrlWithFragment_data(); - void setUrlWithFragment(); - void setUrlToEmpty(); - void setUrlToInvalid(); - void setUrlHistory(); - void setUrlUsingStateObject(); - void setUrlSameUrl(); - void setUrlThenLoads_data(); - void setUrlThenLoads(); - void loadFinishedAfterNotFoundError(); - void signalsDuringErrorHandling(); - void loadInSignalHandlers_data(); - void loadInSignalHandlers(); - -private: - QWebView* m_view { nullptr }; - QWebPage* m_page { nullptr }; - QWebView* m_inputFieldsTestView { nullptr }; - int m_inputFieldTestPaintCount { 0 }; -}; - -bool tst_QWebFrame::eventFilter(QObject* watched, QEvent* event) -{ - // used on the inputFieldFocus test - if (watched == m_inputFieldsTestView) { - if (event->type() == QEvent::Paint) - m_inputFieldTestPaintCount++; - } - return QObject::eventFilter(watched, event); -} - -void tst_QWebFrame::init() -{ - m_view = new QWebView(); - m_page = m_view->page(); -} - -void tst_QWebFrame::cleanup() -{ - delete m_view; -} - -void tst_QWebFrame::symmetricUrl() -{ - QVERIFY(m_view->url().isEmpty()); - - QCOMPARE(m_view->history()->count(), 0); - - QUrl dataUrl("data:text/html,

Test"); - - m_view->setUrl(dataUrl); - QCOMPARE(m_view->url(), dataUrl); - QCOMPARE(m_view->history()->count(), 0); - - // loading is _not_ immediate, so the text isn't set just yet. - QVERIFY(m_view->page()->mainFrame()->toPlainText().isEmpty()); - - ::waitForSignal(m_view, SIGNAL(loadFinished(bool))); - - QCOMPARE(m_view->history()->count(), 1); - QCOMPARE(m_view->page()->mainFrame()->toPlainText(), QString("Test")); - - QUrl dataUrl2("data:text/html,

Test2"); - QUrl dataUrl3("data:text/html,

Test3"); - - m_view->setUrl(dataUrl2); - m_view->setUrl(dataUrl3); - - QCOMPARE(m_view->url(), dataUrl3); - - ::waitForSignal(m_view, SIGNAL(loadFinished(bool))); - - QCOMPARE(m_view->history()->count(), 2); - - QCOMPARE(m_view->page()->mainFrame()->toPlainText(), QString("Test3")); -} - -void tst_QWebFrame::progressSignal() -{ - QSignalSpy progressSpy(m_view, SIGNAL(loadProgress(int))); - - QUrl dataUrl("data:text/html,

Test"); - m_view->setUrl(dataUrl); - - ::waitForSignal(m_view, SIGNAL(loadFinished(bool))); - - QVERIFY(progressSpy.size() >= 1); - QCOMPARE(progressSpy.last().first().toInt(), 100); -} - -void tst_QWebFrame::urlChange() -{ - QSignalSpy urlSpy(m_page->mainFrame(), SIGNAL(urlChanged(QUrl))); - - QUrl dataUrl("data:text/html,

Test"); - m_view->setUrl(dataUrl); - - ::waitForSignal(m_page->mainFrame(), SIGNAL(urlChanged(QUrl))); - - QCOMPARE(urlSpy.size(), 1); - - QUrl dataUrl2("data:text/html,title

Test"); - m_view->setUrl(dataUrl2); - - ::waitForSignal(m_page->mainFrame(), SIGNAL(urlChanged(QUrl))); - - QCOMPARE(urlSpy.size(), 2); -} - -class FakeReply : public QNetworkReply { - Q_OBJECT - -public: - static const QUrl urlFor404ErrorWithoutContents; - - FakeReply(const QNetworkRequest& request, QObject* parent = 0) - : QNetworkReply(parent) - { - setOperation(QNetworkAccessManager::GetOperation); - setRequest(request); - setUrl(request.url()); - if (request.url() == QUrl("qrc:/test1.html")) { - setHeader(QNetworkRequest::LocationHeader, QString("qrc:/test2.html")); - setAttribute(QNetworkRequest::RedirectionTargetAttribute, QUrl("qrc:/test2.html")); - QTimer::singleShot(0, this, SLOT(continueRedirect())); - } -#ifndef QT_NO_OPENSSL - else if (request.url() == QUrl("qrc:/fake-ssl-error.html")) { - setError(QNetworkReply::SslHandshakeFailedError, tr("Fake error!")); - QTimer::singleShot(0, this, SLOT(continueError())); - } -#endif - else if (request.url().host() == QLatin1String("abcdef.abcdef")) { - setError(QNetworkReply::HostNotFoundError, tr("Invalid URL")); - QTimer::singleShot(0, this, SLOT(continueError())); - } else if (request.url() == FakeReply::urlFor404ErrorWithoutContents) { - setError(QNetworkReply::ContentNotFoundError, "Not found"); - setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 404); - QTimer::singleShot(0, this, SLOT(continueError())); - } - - open(QIODevice::ReadOnly); - } - ~FakeReply() - { - close(); - } - virtual void abort() {} - virtual void close() {} - -protected: - qint64 readData(char*, qint64) - { - return 0; - } - -private Q_SLOTS: - void continueRedirect() - { - emit metaDataChanged(); - emit finished(); - } - - void continueError() - { - emit error(this->error()); - emit finished(); - } -}; - -const QUrl FakeReply::urlFor404ErrorWithoutContents = QUrl("http://this.will/return-http-404-error-without-contents.html"); - -class FakeNetworkManager : public QNetworkAccessManager { - Q_OBJECT - -public: - FakeNetworkManager(QObject* parent) : QNetworkAccessManager(parent) { } - -protected: - virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest& request, QIODevice* outgoingData) - { - QString url = request.url().toString(); - if (op == QNetworkAccessManager::GetOperation) { -#ifndef QT_NO_OPENSSL - if (url == "qrc:/fake-ssl-error.html") { - FakeReply* reply = new FakeReply(request, this); - QList errors; - emit sslErrors(reply, errors << QSslError(QSslError::UnspecifiedError)); - return reply; - } -#endif - if (url == "qrc:/test1.html" || url == "http://abcdef.abcdef/" || request.url() == FakeReply::urlFor404ErrorWithoutContents) - return new FakeReply(request, this); - } - - return QNetworkAccessManager::createRequest(op, request, outgoingData); - } -}; - -void tst_QWebFrame::requestedUrl() -{ - QWebPage page; - QWebFrame* frame = page.mainFrame(); - - // in few seconds, the image should be completely loaded - QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); - FakeNetworkManager* networkManager = new FakeNetworkManager(&page); - page.setNetworkAccessManager(networkManager); - - frame->setUrl(QUrl("qrc:/test1.html")); - waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(spy.count(), 1); - QCOMPARE(frame->requestedUrl(), QUrl("qrc:/test1.html")); - QCOMPARE(frame->url(), QUrl("qrc:/test2.html")); - - frame->setUrl(QUrl("qrc:/non-existent.html")); - waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(spy.count(), 2); - QCOMPARE(frame->requestedUrl(), QUrl("qrc:/non-existent.html")); - QCOMPARE(frame->url(), QUrl("qrc:/non-existent.html")); - - frame->setUrl(QUrl("http://abcdef.abcdef")); - waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(spy.count(), 3); - QCOMPARE(frame->requestedUrl(), QUrl("http://abcdef.abcdef/")); - QCOMPARE(frame->url(), QUrl("http://abcdef.abcdef/")); - -#ifndef QT_NO_OPENSSL - qRegisterMetaType >("QList"); - qRegisterMetaType("QNetworkReply*"); - - QSignalSpy spy2(page.networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*,QList))); - frame->setUrl(QUrl("qrc:/fake-ssl-error.html")); - waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(spy2.count(), 1); - QCOMPARE(frame->requestedUrl(), QUrl("qrc:/fake-ssl-error.html")); - QCOMPARE(frame->url(), QUrl("qrc:/fake-ssl-error.html")); -#endif -} - -void tst_QWebFrame::requestedUrlAfterSetAndLoadFailures() -{ - QWebPage page; - QWebFrame* frame = page.mainFrame(); - - QSignalSpy spy(frame, SIGNAL(loadFinished(bool))); - - const QUrl first("http://abcdef.abcdef/"); - frame->setUrl(first); - ::waitForSignal(frame, SIGNAL(loadFinished(bool))); - QCOMPARE(frame->url(), first); - QCOMPARE(frame->requestedUrl(), first); - QVERIFY(!spy.at(0).first().toBool()); - - const QUrl second("http://abcdef.abcdef/another_page.html"); - QVERIFY(first != second); - - page.settings()->setAttribute(QWebSettings::ErrorPageEnabled, false); - - frame->load(second); - ::waitForSignal(frame, SIGNAL(loadFinished(bool))); - QCOMPARE(frame->url(), first); - QCOMPARE(frame->requestedUrl(), second); - QVERIFY(!spy.at(1).first().toBool()); - - page.settings()->setAttribute(QWebSettings::ErrorPageEnabled, true); - - frame->load(second); - ::waitForSignal(frame, SIGNAL(loadFinished(bool))); - QCOMPARE(frame->url(), second); - QCOMPARE(frame->requestedUrl(), second); - QVERIFY(!spy.at(2).first().toBool()); -} - -void tst_QWebFrame::javaScriptWindowObjectCleared_data() -{ - QTest::addColumn("html"); - QTest::addColumn("signalCount"); - QTest::newRow("with

hello world

" << 1; - // NOTE: Empty scripts no longer cause this signal to be emitted. - QTest::newRow("with empty

hello world

" << 0; - QTest::newRow("without

hello world

"); - MyPage page; - m_view->setPage(&page); - page.mainFrame()->setHtml(html); - QCOMPARE(page.alerts, 1); - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118663", Continue); - QCOMPARE(m_view->page()->mainFrame()->toHtml(), html); -} - -class TestNetworkManager : public QNetworkAccessManager -{ -public: - TestNetworkManager(QObject* parent) : QNetworkAccessManager(parent) {} - - QList requestedUrls; - -protected: - virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest &request, QIODevice* outgoingData) { - requestedUrls.append(request.url()); - QNetworkRequest redirectedRequest = request; - redirectedRequest.setUrl(QUrl("data:text/html,

hello")); - return QNetworkAccessManager::createRequest(op, redirectedRequest, outgoingData); - } -}; - -void tst_QWebFrame::ipv6HostEncoding() -{ - TestNetworkManager* networkManager = new TestNetworkManager(m_page); - m_page->setNetworkAccessManager(networkManager); - networkManager->requestedUrls.clear(); - - QUrl baseUrl = QUrl::fromEncoded("http://[::1]/index.html"); - m_view->setHtml("

Hi", baseUrl); - m_view->page()->mainFrame()->evaluateJavaScript("var r = new XMLHttpRequest();" - "r.open('GET', 'http://[::1]/test.xml', false);" - "r.send(null);" - ); - QCOMPARE(networkManager->requestedUrls.count(), 1); - QCOMPARE(networkManager->requestedUrls.at(0), QUrl::fromEncoded("http://[::1]/test.xml")); -} - -void tst_QWebFrame::metaData() -{ - m_view->setHtml("" - " " - " " - " " - " " - ""); - - QMultiMap metaData = m_view->page()->mainFrame()->metaData(); - - QCOMPARE(metaData.count(), 2); - - QCOMPARE(metaData.value("description"), QString("Test description")); - QCOMPARE(metaData.value("keywords"), QString("HTML, JavaScript, Css")); - QCOMPARE(metaData.value("nonexistant"), QString()); - - m_view->setHtml("" - " " - " " - " " - " " - ""); - - metaData = m_view->page()->mainFrame()->metaData(); - - QCOMPARE(metaData.count(), 2); - - QStringList values = metaData.values("samekey"); - QCOMPARE(values.count(), 2); - - QVERIFY(values.contains("FirstValue")); - QVERIFY(values.contains("SecondValue")); - - QCOMPARE(metaData.value("nonexistant"), QString()); -} - -#if !defined(QT_NO_COMBOBOX) -void tst_QWebFrame::popupFocus() -{ - QWebView view; - view.setHtml("" - " " - " " - " " - " " - " " - ""); - view.resize(400, 100); - // Call setFocus before show to work around http://bugreports.qt.nokia.com/browse/QTBUG-14762 - view.setFocus(); - view.show(); - QTest::qWaitForWindowExposed(&view); - view.activateWindow(); - QTRY_VERIFY(view.hasFocus()); - - // open the popup by clicking. check if focus is on the popup - const QWebElement webCombo = view.page()->mainFrame()->documentElement().findFirst(QLatin1String("select[name=select]")); - QTest::mouseClick(&view, Qt::LeftButton, 0, webCombo.geometry().center()); - - QComboBox* combo = view.findChild(); - QVERIFY(combo != 0); - QTRY_VERIFY(!view.hasFocus() && combo->view()->hasFocus()); // Focus should be on the popup - - // hide the popup and check if focus is on the page - combo->hidePopup(); - QTRY_VERIFY(view.hasFocus()); // Focus should be back on the WebView -} -#endif - -void tst_QWebFrame::inputFieldFocus() -{ - QWebView view; - view.setHtml(""); - view.resize(400, 100); - view.show(); - QTest::qWaitForWindowExposed(&view); - view.activateWindow(); - view.setFocus(); - QTRY_VERIFY(view.hasFocus()); - - // double the flashing time, should at least blink once already - int delay = qApp->cursorFlashTime() * 2; - - // focus the lineedit and check if it blinks - bool autoSipEnabled = qApp->autoSipEnabled(); - qApp->setAutoSipEnabled(false); - const QWebElement inputElement = view.page()->mainFrame()->documentElement().findFirst(QLatin1String("input[type=text]")); - QTest::mouseClick(&view, Qt::LeftButton, 0, inputElement.geometry().center()); - m_inputFieldsTestView = &view; - view.installEventFilter( this ); - QTest::qWait(delay); - QVERIFY2(m_inputFieldTestPaintCount >= 3, - "The input field should have a blinking caret"); - qApp->setAutoSipEnabled(autoSipEnabled); -} - -void tst_QWebFrame::hitTestContent() -{ - QString html("

A paragraph




link text"); - - QWebPage page; - QWebFrame* frame = page.mainFrame(); - frame->setHtml(html); - page.setViewportSize(QSize(200, 0)); //no height so link is not visible - const QWebElement linkElement = frame->documentElement().findFirst(QLatin1String("a#link")); - QWebHitTestResult result = frame->hitTestContent(linkElement.geometry().center()); - QCOMPARE(result.linkText(), QString("link text")); - QWebElement link = result.linkElement(); - QCOMPARE(link.attribute("target"), QString("_foo")); - QCOMPARE(result.element().tagName(), QString("A")); -} - -void tst_QWebFrame::baseUrl_data() -{ - QTest::addColumn("html"); - QTest::addColumn("loadUrl"); - QTest::addColumn("url"); - QTest::addColumn("baseUrl"); - - QTest::newRow("null") << QString() << QUrl() - << QUrl("about:blank") << QUrl("about:blank"); - - QTest::newRow("foo") << QString() << QUrl("http://foobar.baz/") - << QUrl("http://foobar.baz/") << QUrl("http://foobar.baz/"); - - QString html = "" - "" - "" - "" - ""; - QTest::newRow("customBaseUrl") << html << QUrl("http://foobar.baz/") - << QUrl("http://foobar.baz/") << QUrl("http://foobaz.bar/"); -} - -void tst_QWebFrame::baseUrl() -{ - QFETCH(QString, html); - QFETCH(QUrl, loadUrl); - QFETCH(QUrl, url); - QFETCH(QUrl, baseUrl); - - m_page->mainFrame()->setHtml(html, loadUrl); - QCOMPARE(m_page->mainFrame()->url(), url); - QCOMPARE(m_page->mainFrame()->baseUrl(), baseUrl); -} - -void tst_QWebFrame::hasSetFocus() -{ - QString html("

top

" \ - " - - - diff --git a/Source/WebKit/qt/tests/qwebpage/resources/iframe3.html b/Source/WebKit/qt/tests/qwebpage/resources/iframe3.html deleted file mode 100644 index ed6ac5b94..000000000 --- a/Source/WebKit/qt/tests/qwebpage/resources/iframe3.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

inner

- - diff --git a/Source/WebKit/qt/tests/qwebpage/resources/index.html b/Source/WebKit/qt/tests/qwebpage/resources/index.html deleted file mode 100644 index 638df364e..000000000 --- a/Source/WebKit/qt/tests/qwebpage/resources/index.html +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Source/WebKit/qt/tests/qwebpage/resources/script.html b/Source/WebKit/qt/tests/qwebpage/resources/script.html deleted file mode 100644 index ede986415..000000000 --- a/Source/WebKit/qt/tests/qwebpage/resources/script.html +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/Source/WebKit/qt/tests/qwebpage/resources/user.css b/Source/WebKit/qt/tests/qwebpage/resources/user.css deleted file mode 100644 index 4ccb2f0fc..000000000 --- a/Source/WebKit/qt/tests/qwebpage/resources/user.css +++ /dev/null @@ -1,3 +0,0 @@ -p { - background-image: url('http://does.not/exist.png'); -} \ No newline at end of file diff --git a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp deleted file mode 100644 index db4c911e6..000000000 --- a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ /dev/null @@ -1,3501 +0,0 @@ -/* - Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - Copyright (C) 2009 Girish Ramakrishnan - Copyright (C) 2010 Holger Hans Peter Freyther - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "../util.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_QTTESTSUPPORT -#include "../WebCoreSupport/DumpRenderTreeSupportQt.h" -#endif - -static void removeRecursive(const QString& dirname) -{ - QDir dir(dirname); - QFileInfoList entries(dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)); - for (int i = 0; i < entries.count(); ++i) - if (entries[i].isDir()) - removeRecursive(entries[i].filePath()); - else - dir.remove(entries[i].fileName()); - QDir().rmdir(dirname); -} - -class TestInputContext : public QPlatformInputContext -{ -public: - TestInputContext() - : m_visible(false) - { - QInputMethodPrivate* inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = this; - } - - ~TestInputContext() - { - QInputMethodPrivate* inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = 0; - } - - virtual void showInputPanel() - { - m_visible = true; - } - virtual void hideInputPanel() - { - m_visible = false; - } - virtual bool isInputPanelVisible() const - { - return m_visible; - } - - bool m_visible; -}; - -class tst_QWebPage : public QObject -{ - Q_OBJECT - -public: - tst_QWebPage(); - virtual ~tst_QWebPage(); - -public Q_SLOTS: - void init(); - void cleanup(); - void cleanupFiles(); - -private Q_SLOTS: - void initTestCase(); - void cleanupTestCase(); - -#ifdef HAVE_QTTESTSUPPORT - void thirdPartyCookiePolicy(); -#endif - - void contextMenuCopy(); - void contextMenuPopulatedOnce(); - void acceptNavigationRequest(); - void domainSpecificKeyEvent(); - void geolocationRequestJS(); - void loadFinished(); - void actionStates(); - void popupFormSubmission(); - void acceptNavigationRequestWithNewWindow(); - void userStyleSheet(); - void userStyleSheetFromLocalFileUrl(); - void userStyleSheetFromQrcUrl(); - void loadHtml5Video(); - void modified(); - void contextMenuCrash(); - void updatePositionDependentActionsCrash(); - void database(); - void createPluginWithPluginsEnabled(); - void createPluginWithPluginsDisabled(); - void destroyPlugin_data(); - void destroyPlugin(); - void createViewlessPlugin_data(); - void createViewlessPlugin(); - void graphicsWidgetPlugin(); - -#ifdef HAVE_QTTESTSUPPORT - void multiplePageGroupsAndLocalStorage(); -#endif - - void cursorMovements(); - void textSelection(); - void textEditing(); - void backActionUpdate(); - void frameAt(); - void requestCache(); - void loadCachedPage(); - -#ifdef HAVE_QTTESTSUPPORT - void protectBindingsRuntimeObjectsFromCollector(); -#endif - - void localURLSchemes(); - void testOptionalJSObjects(); - void testLocalStorageVisibility(); - void testEnablePersistentStorage(); - void consoleOutput(); - void inputMethods_data(); - void inputMethods(); - void inputMethodsTextFormat_data(); - void inputMethodsTextFormat(); - void defaultTextEncoding(); - void errorPageExtension(); - void errorPageExtensionInIFrames(); - void errorPageExtensionInFrameset(); - void userAgentApplicationName(); - void userAgentNewlineStripping(); - void undoActionHaveCustomText(); - - void viewModes(); - - void crashTests_LazyInitializationOfMainFrame(); - - void screenshot_data(); - void screenshot(); - - void changeVisibilityState(); - -#if defined(ENABLE_WEBGL) && ENABLE_WEBGL - void acceleratedWebGLScreenshotWithoutView(); - void unacceleratedWebGLScreenshotWithoutView(); -#endif - - void originatingObjectInNetworkRequests(); - void networkReplyParentDidntChange(); - void destroyQNAMBeforeAbortDoesntCrash(); - void testJSPrompt(); - void showModalDialog(); - void testStopScheduledPageRefresh(); - void findText(); - void supportedContentType(); - // [Qt] tst_QWebPage::infiniteLoopJS() timeouts with DFG JIT - // https://bugs.webkit.org/show_bug.cgi?id=79040 - // void infiniteLoopJS(); - void navigatorCookieEnabled(); - void deleteQWebViewTwice(); - void renderOnRepaintRequestedShouldNotRecurse(); - void loadSignalsOrder_data(); - void loadSignalsOrder(); - void openWindowDefaultSize(); - void cssMediaTypeGlobalSetting(); - void cssMediaTypePageSetting(); - -#ifdef Q_OS_MACOS - void macCopyUnicodeToClipboard(); -#endif - -private: - QWebView* m_view { nullptr }; - QWebPage* m_page { nullptr }; - QString tmpDirPath() const - { - static QString tmpd = QDir::tempPath() + "/tst_qwebpage-" - + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss")); - return tmpd; - } -}; - -tst_QWebPage::tst_QWebPage() -{ -} - -tst_QWebPage::~tst_QWebPage() -{ -} - -void tst_QWebPage::init() -{ - m_view = new QWebView(); - m_page = m_view->page(); -} - -void tst_QWebPage::cleanup() -{ - delete m_view; -} - -void tst_QWebPage::cleanupFiles() -{ - removeRecursive(tmpDirPath()); -} - -void tst_QWebPage::initTestCase() -{ - cleanupFiles(); // In case there are old files from previous runs -} - -void tst_QWebPage::cleanupTestCase() -{ - cleanupFiles(); // Be nice -} - -class NavigationRequestOverride : public QWebPage -{ -public: - NavigationRequestOverride(QWebView* parent, bool initialValue) : QWebPage(parent), m_acceptNavigationRequest(initialValue) {} - - bool m_acceptNavigationRequest; -protected: - virtual bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, QWebPage::NavigationType type) { - Q_UNUSED(frame); - Q_UNUSED(request); - Q_UNUSED(type); - - return m_acceptNavigationRequest; - } -}; - -void tst_QWebPage::acceptNavigationRequest() -{ - QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool))); - - NavigationRequestOverride* newPage = new NavigationRequestOverride(m_view, false); - m_view->setPage(newPage); - - m_view->setHtml(QString("
" - "
"), QUrl()); - QTRY_COMPARE(loadSpy.count(), 1); - - m_view->page()->mainFrame()->evaluateJavaScript("tstform.submit();"); - - newPage->m_acceptNavigationRequest = true; - m_view->page()->mainFrame()->evaluateJavaScript("tstform.submit();"); - QTRY_COMPARE(loadSpy.count(), 2); - - QCOMPARE(m_view->page()->mainFrame()->toPlainText(), QString("foo?")); - - // Restore default page - m_view->setPage(0); -} - -void tst_QWebPage::domainSpecificKeyEvent() -{ - QWebView webView; - webView.show(); - QTest::qWaitForWindowExposed(&webView); - - webView.setHtml(QLatin1String("" - "test")); - - // Enable settings to use nativeVirtualKey as DOM key value. - webView.page()->setProperty("_q_useNativeVirtualKeyAsDOMKey", true); - // Simulate domain specific keyevent to WebKit by passing it as nativeVirtualKey in QKeyEvent. - // Qt::Key_Pause --> 0x51 - QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); - QApplication::sendEvent(&webView, &keyEvent); - keyEvent = QKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); - QApplication::sendEvent(&webView, &keyEvent); - const QLatin1String expectedReceivedKeyArray1("keydown:81:0,keyup:81:0"); - QString receivedKeyArray = webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray")).toStringList().join(","); - QVERIFY(receivedKeyArray == expectedReceivedKeyArray1); - - // Normal PC keyboard key converstion flow shouldn't be affected when sending nativeVirtual key as 0. - // Qt::Key_Pause --> VK_PAUSE(0x13) - webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray = new Array()")); // Reset - keyEvent = QKeyEvent(QEvent::KeyPress, Qt::Key_Pause, Qt::NoModifier, 0, 0, 0); - QApplication::sendEvent(&webView, &keyEvent); - keyEvent = QKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 0, 0); - QApplication::sendEvent(&webView, &keyEvent); - const QLatin1String expectedReceivedKeyArray2("keydown:19:0,keyup:19:0"); - receivedKeyArray = webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray")).toStringList().join(","); - QVERIFY(receivedKeyArray == expectedReceivedKeyArray2); - - // Negative case. - // Disable settings to use nativeVirtualKey as DOM key value. - webView.page()->setProperty("_q_useNativeVirtualKeyAsDOMKey", false); - // Qt::Key_Pause --> VK_PAUSE(0x13) - webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray = new Array()")); // Reset - keyEvent = QKeyEvent(QEvent::KeyPress, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); - QApplication::sendEvent(&webView, &keyEvent); - keyEvent = QKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); - QApplication::sendEvent(&webView, &keyEvent); - const QLatin1String expectedReceivedKeyArray3("keydown:19:0,keyup:19:0"); - receivedKeyArray = webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray")).toStringList().join(","); - QVERIFY(receivedKeyArray == expectedReceivedKeyArray3); -} - -class JSTestPage : public QWebPage -{ -Q_OBJECT -public: - JSTestPage(QObject* parent = 0) - : QWebPage(parent) {} - - virtual bool shouldInterruptJavaScript() - { - return true; - } -public Q_SLOTS: - void requestPermission(QWebFrame* frame, QWebPage::Feature feature) - { - if (m_allowGeolocation) - setFeaturePermission(frame, feature, PermissionGrantedByUser); - else - setFeaturePermission(frame, feature, PermissionDeniedByUser); - } - -public: - void setGeolocationPermission(bool allow) - { - m_allowGeolocation = allow; - } - -private: - bool m_allowGeolocation { false }; -}; - -// [Qt] tst_QWebPage::infiniteLoopJS() timeouts with DFG JIT -// https://bugs.webkit.org/show_bug.cgi?id=79040 -/* -void tst_QWebPage::infiniteLoopJS() -{ - JSTestPage* newPage = new JSTestPage(m_view); - m_view->setPage(newPage); - m_view->setHtml(QString("test"), QUrl()); - m_view->page()->mainFrame()->evaluateJavaScript("var run = true;var a = 1;while(run){a++;}"); - delete newPage; -} -*/ - -void tst_QWebPage::geolocationRequestJS() -{ - JSTestPage* newPage = new JSTestPage(m_view); - - if (newPage->mainFrame()->evaluateJavaScript(QLatin1String("!navigator.geolocation")).toBool()) { - delete newPage; - W_QSKIP("Geolocation is not supported.", SkipSingle); - } - - connect(newPage, SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), - newPage, SLOT(requestPermission(QWebFrame*, QWebPage::Feature))); - - newPage->setGeolocationPermission(false); - m_view->setPage(newPage); - m_view->setHtml(QString("test"), QUrl()); - m_view->page()->mainFrame()->evaluateJavaScript("var errorCode = 0; function error(err) { errorCode = err.code; } function success(pos) { } navigator.geolocation.getCurrentPosition(success, error)"); - QTest::qWait(2000); - QVariant empty = m_view->page()->mainFrame()->evaluateJavaScript("errorCode"); - - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=102235", Continue); - QVERIFY(empty.type() == QVariant::Double && empty.toInt() != 0); - - newPage->setGeolocationPermission(true); - m_view->page()->mainFrame()->evaluateJavaScript("errorCode = 0; navigator.geolocation.getCurrentPosition(success, error);"); - empty = m_view->page()->mainFrame()->evaluateJavaScript("errorCode"); - - //http://dev.w3.org/geo/api/spec-source.html#position - //PositionError: const unsigned short PERMISSION_DENIED = 1; - QVERIFY(empty.type() == QVariant::Double && empty.toInt() != 1); - delete newPage; -} - -void tst_QWebPage::loadFinished() -{ - qRegisterMetaType("QWebFrame*"); - qRegisterMetaType("QNetworkRequest*"); - QSignalSpy spyLoadStarted(m_view, SIGNAL(loadStarted())); - QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); - - m_view->page()->mainFrame()->load(QUrl("data:text/html,foo \">" - "")); - QTRY_COMPARE(spyLoadFinished.count(), 1); - - QTRY_VERIFY(spyLoadStarted.count() > 1); - QTRY_VERIFY(spyLoadFinished.count() > 1); - - spyLoadFinished.clear(); - - m_view->page()->mainFrame()->load(QUrl("data:text/html,")); - QTRY_COMPARE(spyLoadFinished.count(), 1); - QCOMPARE(spyLoadFinished.count(), 1); -} - -void tst_QWebPage::actionStates() -{ - QWebPage* page = m_view->page(); - - page->mainFrame()->load(QUrl("qrc:///resources/script.html")); - - QAction* reloadAction = page->action(QWebPage::Reload); - QAction* stopAction = page->action(QWebPage::Stop); - - QTRY_VERIFY(reloadAction->isEnabled()); - QTRY_VERIFY(!stopAction->isEnabled()); -} - -class ConsolePage : public QWebPage -{ -public: - ConsolePage(QObject* parent = 0) : QWebPage(parent) {} - - virtual void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) - { - messages.append(message); - lineNumbers.append(lineNumber); - sourceIDs.append(sourceID); - } - - QStringList messages; - QList lineNumbers; - QStringList sourceIDs; -}; - -void tst_QWebPage::consoleOutput() -{ - ConsolePage page; - page.mainFrame()->evaluateJavaScript("this is not valid JavaScript"); - QCOMPARE(page.messages.count(), 1); - QCOMPARE(page.lineNumbers.at(0), 1); -} - -class TestPage : public QWebPage { - Q_OBJECT -public: - TestPage(QObject* parent = 0) : QWebPage(parent) - { - connect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeometryChangeRequested(QRect))); - } - - struct Navigation { - QPointer frame; - QNetworkRequest request; - NavigationType type; - }; - - QList navigations; - QList createdWindows; - QRect requestedGeometry; - - virtual bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type) { - Navigation n; - n.frame = frame; - n.request = request; - n.type = type; - navigations.append(n); - return true; - } - - virtual QWebPage* createWindow(WebWindowType) { - TestPage* page = new TestPage(this); - createdWindows.append(page); - return page; - } - -private Q_SLOTS: - void slotGeometryChangeRequested(const QRect& geom) { - requestedGeometry = geom; - } -}; - -void tst_QWebPage::popupFormSubmission() -{ - TestPage page; - page.settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); - page.mainFrame()->setHtml("
"\ - ""\ - "
"); - page.mainFrame()->evaluateJavaScript("window.open('', 'myNewWin', 'width=500,height=300,toolbar=0')"); - page.mainFrame()->evaluateJavaScript("document.form1.submit();"); - - QTest::qWait(500); - // The number of popup created should be one. - QVERIFY(page.createdWindows.size() == 1); - - QString url = page.createdWindows.takeFirst()->mainFrame()->url().toString(); - // Check if the form submission was OK. - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118597", Continue); - QVERIFY(url.contains("?foo=bar")); -} - -void tst_QWebPage::acceptNavigationRequestWithNewWindow() -{ - TestPage* page = new TestPage(m_view); - page->settings()->setAttribute(QWebSettings::LinksIncludedInFocusChain, true); - m_page = page; - m_view->setPage(m_page); - - m_view->setUrl(QString("data:text/html,Click me")); - QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); - - QFocusEvent fe(QEvent::FocusIn); - m_page->event(&fe); - - QVERIFY(m_page->focusNextPrevChild(/*next*/ true)); - - QKeyEvent keyEnter(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier); - m_page->event(&keyEnter); - - QCOMPARE(page->navigations.count(), 2); - - TestPage::Navigation n = page->navigations.at(1); - QVERIFY(n.frame.isNull()); - QCOMPARE(n.request.url().toString(), QString("data:text/html,Reached")); - QVERIFY(n.type == QWebPage::NavigationTypeLinkClicked); - - QCOMPARE(page->createdWindows.count(), 1); -} - -class TestNetworkManager : public QNetworkAccessManager -{ -public: - TestNetworkManager(QObject* parent) : QNetworkAccessManager(parent) {} - - QList requestedUrls; - QList requests; - -protected: - virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest &request, QIODevice* outgoingData) { - requests.append(request); - requestedUrls.append(request.url()); - return QNetworkAccessManager::createRequest(op, request, outgoingData); - } -}; - -void tst_QWebPage::userStyleSheet() -{ - TestNetworkManager* networkManager = new TestNetworkManager(m_page); - m_page->setNetworkAccessManager(networkManager); - - m_page->settings()->setUserStyleSheetUrl(QUrl(QString::fromLatin1("data:text/css;charset=utf-8;base64," - + QByteArray("p { background-image: url('http://does.not/exist.png');}").toBase64()))); - m_view->setHtml("

hello world

"); - QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); - - QVERIFY(networkManager->requestedUrls.count() >= 1); - QCOMPARE(networkManager->requestedUrls.at(0), QUrl("http://does.not/exist.png")); -} - -void tst_QWebPage::userStyleSheetFromLocalFileUrl() -{ - TestNetworkManager* networkManager = new TestNetworkManager(m_page); - m_page->setNetworkAccessManager(networkManager); - - QUrl styleSheetUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebpage/resources/user.css")); - m_page->settings()->setUserStyleSheetUrl(styleSheetUrl); - m_view->setHtml("

hello world

"); - QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); - - QVERIFY(networkManager->requestedUrls.count() >= 1); - QCOMPARE(networkManager->requestedUrls.at(0), QUrl("http://does.not/exist.png")); -} - -void tst_QWebPage::userStyleSheetFromQrcUrl() -{ - TestNetworkManager* networkManager = new TestNetworkManager(m_page); - m_page->setNetworkAccessManager(networkManager); - - m_page->settings()->setUserStyleSheetUrl(QUrl("qrc:///resources/user.css")); - m_view->setHtml("

hello world

"); - QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); - - QVERIFY(networkManager->requestedUrls.count() >= 1); - QCOMPARE(networkManager->requestedUrls.at(0), QUrl("http://does.not/exist.png")); -} - -void tst_QWebPage::loadHtml5Video() -{ -#if defined(USE_QT_MULTIMEDIA) && USE_QT_MULTIMEDIA - QByteArray url("http://does.not/exist?a=1%2Cb=2"); - m_view->setHtml("

"); - QTest::qWait(2000); - QUrl mUrl = DumpRenderTreeSupportQt::mediaContentUrlByElementId(m_page->mainFrame()->handle(), "video"); - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=65452", Continue); - QCOMPARE(mUrl.toEncoded(), url); -#else - W_QSKIP("This test requires Qt Multimedia", SkipAll); -#endif -} - -void tst_QWebPage::viewModes() -{ - m_view->setHtml(""); - m_page->setProperty("_q_viewMode", "minimized"); - - QVariant empty = m_page->mainFrame()->evaluateJavaScript("window.styleMedia.matchMedium(\"(-webkit-view-mode)\")"); - QVERIFY(empty.type() == QVariant::Bool && empty.toBool()); - - QVariant minimized = m_page->mainFrame()->evaluateJavaScript("window.styleMedia.matchMedium(\"(-webkit-view-mode: minimized)\")"); - QVERIFY(minimized.type() == QVariant::Bool && minimized.toBool()); - - QVariant maximized = m_page->mainFrame()->evaluateJavaScript("window.styleMedia.matchMedium(\"(-webkit-view-mode: maximized)\")"); - QVERIFY(maximized.type() == QVariant::Bool && !maximized.toBool()); -} - -void tst_QWebPage::modified() -{ - m_page->mainFrame()->setUrl(QUrl("data:text/html,blub")); - QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); - - m_page->mainFrame()->setUrl(QUrl("data:text/html,blah")); - QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); - - QVERIFY(!m_page->isModified()); - -// m_page->mainFrame()->evaluateJavaScript("alert(document.getElementById('foo'))"); - m_page->mainFrame()->evaluateJavaScript("document.getElementById('foo').focus()"); - m_page->mainFrame()->evaluateJavaScript("document.execCommand('InsertText', true, 'Test');"); - - QVERIFY(m_page->isModified()); - - m_page->mainFrame()->evaluateJavaScript("document.execCommand('Undo', true);"); - - QVERIFY(!m_page->isModified()); - - m_page->mainFrame()->evaluateJavaScript("document.execCommand('Redo', true);"); - - QVERIFY(m_page->isModified()); - - QVERIFY(m_page->history()->canGoBack()); - QVERIFY(!m_page->history()->canGoForward()); - QCOMPARE(m_page->history()->count(), 2); - QVERIFY(m_page->history()->backItem().isValid()); - QVERIFY(!m_page->history()->forwardItem().isValid()); - - m_page->history()->back(); - QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); - - QVERIFY(!m_page->history()->canGoBack()); - QVERIFY(m_page->history()->canGoForward()); - - QVERIFY(!m_page->isModified()); - - QVERIFY(m_page->history()->currentItemIndex() == 0); - - m_page->history()->setMaximumItemCount(3); - QVERIFY(m_page->history()->maximumItemCount() == 3); - - QVariant variant("string test"); - m_page->history()->currentItem().setUserData(variant); - QVERIFY(m_page->history()->currentItem().userData().toString() == "string test"); - - m_page->mainFrame()->setUrl(QUrl("data:text/html,This is second page")); - m_page->mainFrame()->setUrl(QUrl("data:text/html,This is third page")); - QVERIFY(m_page->history()->count() == 2); - m_page->mainFrame()->setUrl(QUrl("data:text/html,This is fourth page")); - QVERIFY(m_page->history()->count() == 2); - m_page->mainFrame()->setUrl(QUrl("data:text/html,This is fifth page")); - QVERIFY(::waitForSignal(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*,QWebHistoryItem*)))); -} - -// https://bugs.webkit.org/show_bug.cgi?id=51331 -void tst_QWebPage::updatePositionDependentActionsCrash() -{ - QWebView view; - view.setHtml("

test"); - QPoint pos(0, 0); - view.page()->updatePositionDependentActions(pos); - QMenu* contextMenu = 0; - foreach (QObject* child, view.children()) { - contextMenu = qobject_cast(child); - if (contextMenu) - break; - } - QVERIFY(!contextMenu); -} - -// https://bugs.webkit.org/show_bug.cgi?id=20357 -void tst_QWebPage::contextMenuCrash() -{ - QWebView view; - view.setHtml("

test"); - QPoint pos(0, 0); - QContextMenuEvent event(QContextMenuEvent::Mouse, pos); - view.page()->swallowContextMenuEvent(&event); - view.page()->updatePositionDependentActions(pos); - QMenu* contextMenu = 0; - foreach (QObject* child, view.children()) { - contextMenu = qobject_cast(child); - if (contextMenu) - break; - } - QVERIFY(contextMenu); - delete contextMenu; -} - -void tst_QWebPage::database() -{ - QString path = tmpDirPath(); - m_page->settings()->setOfflineStoragePath(path); - QVERIFY(m_page->settings()->offlineStoragePath() == path); - - QWebSettings::setOfflineStorageDefaultQuota(1024 * 1024); - QVERIFY(QWebSettings::offlineStorageDefaultQuota() == 1024 * 1024); - - m_page->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); - m_page->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); - - QString dbFileName = path + "Databases.db"; - - if (QFile::exists(dbFileName)) - QFile::remove(dbFileName); - - qRegisterMetaType("QWebFrame*"); - QSignalSpy spy(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString))); - m_view->setHtml(QString("

"), QUrl("http://www.myexample.com")); - QTRY_COMPARE(spy.count(), 1); - m_page->mainFrame()->evaluateJavaScript("var db2; db2=openDatabase('testdb', '1.0', 'test database API', 50000);"); - QTRY_COMPARE(spy.count(),1); - - m_page->mainFrame()->evaluateJavaScript("localStorage.test='This is a test for local storage';"); - m_view->setHtml(QString("text"), QUrl("http://www.myexample.com")); - - QVariant s1 = m_page->mainFrame()->evaluateJavaScript("localStorage.test"); - QCOMPARE(s1.toString(), QString("This is a test for local storage")); - - m_page->mainFrame()->evaluateJavaScript("sessionStorage.test='This is a test for session storage';"); - m_view->setHtml(QString("text"), QUrl("http://www.myexample.com")); - QVariant s2 = m_page->mainFrame()->evaluateJavaScript("sessionStorage.test"); - QCOMPARE(s2.toString(), QString("This is a test for session storage")); - - m_view->setHtml(QString("
"), QUrl("http://www.myexample.com")); - m_page->mainFrame()->evaluateJavaScript("var db3; db3=openDatabase('testdb', '1.0', 'test database API', 50000);db3.transaction(function(tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS Test (text TEXT)', []); }, function(tx, result) { }, function(tx, error) { });"); - QTest::qWait(200); - - // Remove all databases. - QWebSecurityOrigin origin = m_page->mainFrame()->securityOrigin(); - QList dbs = origin.databases(); - for (int i = 0; i < dbs.count(); i++) { - QString fileName = dbs[i].fileName(); - QVERIFY(QFile::exists(fileName)); - QWebDatabase::removeDatabase(dbs[i]); - QVERIFY(!QFile::exists(fileName)); - } - QVERIFY(!origin.databases().size()); - // Remove removed test :-) - QWebDatabase::removeAllDatabases(); - QVERIFY(!origin.databases().size()); -} - -class PluginPage : public QWebPage -{ -public: - PluginPage(QObject *parent = 0) - : QWebPage(parent) {} - - struct CallInfo - { - CallInfo(const QString &c, const QUrl &u, - const QStringList &pn, const QStringList &pv, - QObject *r) - : classid(c), url(u), paramNames(pn), - paramValues(pv), returnValue(r) - {} - QString classid; - QUrl url; - QStringList paramNames; - QStringList paramValues; - QObject *returnValue; - }; - - QList calls; - -protected: - virtual QObject *createPlugin(const QString &classid, const QUrl &url, - const QStringList ¶mNames, - const QStringList ¶mValues) - { - QObject *result = 0; - if (classid == "pushbutton") - result = new QPushButton(); -#ifndef QT_NO_INPUTDIALOG - else if (classid == "lineedit") - result = new QLineEdit(); -#endif - else if (classid == "graphicswidget") - result = new QGraphicsWidget(); - if (result) - result->setObjectName(classid); - calls.append(CallInfo(classid, url, paramNames, paramValues, result)); - return result; - } -}; - -static void createPlugin(QWebView *view) -{ - QSignalSpy loadSpy(view, SIGNAL(loadFinished(bool))); - - PluginPage* newPage = new PluginPage(view); - view->setPage(newPage); - - // type has to be application/x-qt-plugin - view->setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 1); - QCOMPARE(newPage->calls.count(), 0); - - view->setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 2); - QCOMPARE(newPage->calls.count(), 1); - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("pushbutton")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("pushbutton")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mybutton")); - QVERIFY(ci.returnValue != 0); - QVERIFY(ci.returnValue->inherits("QPushButton")); - } - // test JS bindings - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("document.getElementById('mybutton').toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mybutton.toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mybutton.objectName").toString(), - QString::fromLatin1("string")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mybutton.objectName").toString(), - QString::fromLatin1("pushbutton")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mybutton.clicked").toString(), - QString::fromLatin1("function")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mybutton.clicked.toString()").toString(), - QString::fromLatin1("function clicked() {\n [native code]\n}")); - - view->setHtml(QString("" - "" - "" - "
"), QUrl("http://foo.bar.baz")); - QTRY_COMPARE(loadSpy.count(), 3); - QCOMPARE(newPage->calls.count(), 2); - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("lineedit")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("lineedit")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("myedit")); - QVERIFY(ci.returnValue != 0); - QVERIFY(ci.returnValue->inherits("QLineEdit")); - } - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("pushbutton")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("pushbutton")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mybutton")); - QVERIFY(ci.returnValue != 0); - QVERIFY(ci.returnValue->inherits("QPushButton")); - } -} - -void tst_QWebPage::graphicsWidgetPlugin() -{ - m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - QGraphicsWebView webView; - - QSignalSpy loadSpy(&webView, SIGNAL(loadFinished(bool))); - - PluginPage* newPage = new PluginPage(&webView); - webView.setPage(newPage); - - // type has to be application/x-qt-plugin - webView.setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 1); - QCOMPARE(newPage->calls.count(), 0); - - webView.setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 2); - QCOMPARE(newPage->calls.count(), 1); - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("graphicswidget")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("graphicswidget")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mygraphicswidget")); - QVERIFY(ci.returnValue); - QVERIFY(ci.returnValue->inherits("QGraphicsWidget")); - } - // test JS bindings - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("document.getElementById('mygraphicswidget').toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mygraphicswidget.toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mygraphicswidget.objectName").toString(), - QString::fromLatin1("string")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mygraphicswidget.objectName").toString(), - QString::fromLatin1("graphicswidget")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mygraphicswidget.geometryChanged").toString(), - QString::fromLatin1("function")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mygraphicswidget.geometryChanged.toString()").toString(), - QString::fromLatin1("function geometryChanged() {\n [native code]\n}")); -} - -void tst_QWebPage::createPluginWithPluginsEnabled() -{ - m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - createPlugin(m_view); -} - -void tst_QWebPage::createPluginWithPluginsDisabled() -{ - // Qt Plugins should be loaded by QtWebKit even when PluginsEnabled is - // false. The client decides whether a Qt plugin is enabled or not when - // it decides whether or not to instantiate it. - m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, false); - createPlugin(m_view); -} - -// Standard base class for template PluginTracerPage. In tests it is used as interface. -class PluginCounterPage : public QWebPage { -public: - int m_count; - QPointer m_widget; - QObject* m_pluginParent; - PluginCounterPage(QObject* parent = 0) - : QWebPage(parent) - , m_count(0) - , m_pluginParent(0) - { - settings()->setAttribute(QWebSettings::PluginsEnabled, true); - } - ~PluginCounterPage() - { - if (m_pluginParent) - m_pluginParent->deleteLater(); - } -}; - -template -class PluginTracerPage : public PluginCounterPage { -public: - PluginTracerPage(QObject* parent = 0) - : PluginCounterPage(parent) - { - // this is a dummy parent object for the created plugin - m_pluginParent = new T; - } - virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) - { - m_count++; - m_widget = new T; - // need a cast to the specific type, as QObject::setParent cannot be called, - // because it is not virtual. Instead it is necesary to call QWidget::setParent, - // which also takes a QWidget* instead of a QObject*. Therefore we need to - // upcast to T*, which is a QWidget. - static_cast(m_widget.data())->setParent(static_cast(m_pluginParent)); - return m_widget.data(); - } -}; - -class PluginFactory { -public: - enum FactoredType {QWidgetType, QGraphicsWidgetType}; - static PluginCounterPage* create(FactoredType type, QObject* parent = 0) - { - PluginCounterPage* result = 0; - switch (type) { - case QWidgetType: - result = new PluginTracerPage(parent); - break; - case QGraphicsWidgetType: - result = new PluginTracerPage(parent); - break; - default: {/*Oops*/}; - } - return result; - } - - static void prepareTestData() - { - QTest::addColumn("type"); - QTest::newRow("QWidget") << (int)PluginFactory::QWidgetType; - QTest::newRow("QGraphicsWidget") << (int)PluginFactory::QGraphicsWidgetType; - } -}; - -void tst_QWebPage::destroyPlugin_data() -{ - PluginFactory::prepareTestData(); -} - -void tst_QWebPage::destroyPlugin() -{ - QFETCH(int, type); - PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type, m_view); - m_view->setPage(page); - - // we create the plugin, so the widget should be constructed - QString content(""); - m_view->setHtml(content); - QVERIFY(page->m_widget); - QCOMPARE(page->m_count, 1); - - // navigate away, the plugin widget should be destructed - m_view->setHtml("Hi"); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(!page->m_widget); -} - -void tst_QWebPage::createViewlessPlugin_data() -{ - PluginFactory::prepareTestData(); -} - -void tst_QWebPage::createViewlessPlugin() -{ - QFETCH(int, type); - PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type); - QString content(""); - page->mainFrame()->setHtml(content); - QCOMPARE(page->m_count, 1); - QVERIFY(page->m_widget); - QVERIFY(page->m_pluginParent); - QVERIFY(page->m_widget.data()->parent() == page->m_pluginParent); - delete page; - -} - -#ifdef HAVE_QTTESTSUPPORT -void tst_QWebPage::multiplePageGroupsAndLocalStorage() -{ - QDir dir(tmpDirPath()); - dir.mkdir("path1"); - dir.mkdir("path2"); - - QWebView view1; - QWebView view2; - - view1.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); - view1.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path1")); - DumpRenderTreeSupportQt::webPageSetGroupName(view1.page()->handle(), "group1"); - view2.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); - view2.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path2")); - DumpRenderTreeSupportQt::webPageSetGroupName(view2.page()->handle(), "group2"); - QCOMPARE(DumpRenderTreeSupportQt::webPageGroupName(view1.page()->handle()), QString("group1")); - QCOMPARE(DumpRenderTreeSupportQt::webPageGroupName(view2.page()->handle()), QString("group2")); - - - view1.setHtml(QString(" "), QUrl("http://www.myexample.com")); - view2.setHtml(QString(" "), QUrl("http://www.myexample.com")); - - view1.page()->mainFrame()->evaluateJavaScript("localStorage.test='value1';"); - view2.page()->mainFrame()->evaluateJavaScript("localStorage.test='value2';"); - - view1.setHtml(QString(" "), QUrl("http://www.myexample.com")); - view2.setHtml(QString(" "), QUrl("http://www.myexample.com")); - - QVariant s1 = view1.page()->mainFrame()->evaluateJavaScript("localStorage.test"); - QCOMPARE(s1.toString(), QString("value1")); - - QVariant s2 = view2.page()->mainFrame()->evaluateJavaScript("localStorage.test"); - QCOMPARE(s2.toString(), QString("value2")); - - QTest::qWait(1000); - - QFile::remove(QDir::toNativeSeparators(tmpDirPath() + "/path1/http_www.myexample.com_0.localstorage")); - QFile::remove(QDir::toNativeSeparators(tmpDirPath() + "/path2/http_www.myexample.com_0.localstorage")); - dir.rmdir(QDir::toNativeSeparators("./path1")); - dir.rmdir(QDir::toNativeSeparators("./path2")); -} -#endif - -class CursorTrackedPage : public QWebPage -{ -public: - - CursorTrackedPage(QWidget *parent = 0): QWebPage(parent) { - setViewportSize(QSize(1024, 768)); // big space - } - - QString selectedText() { - return mainFrame()->evaluateJavaScript("window.getSelection().toString()").toString(); - } - - int selectionStartOffset() { - return mainFrame()->evaluateJavaScript("window.getSelection().getRangeAt(0).startOffset").toInt(); - } - - int selectionEndOffset() { - return mainFrame()->evaluateJavaScript("window.getSelection().getRangeAt(0).endOffset").toInt(); - } - - // true if start offset == end offset, i.e. no selected text - int isSelectionCollapsed() { - return mainFrame()->evaluateJavaScript("window.getSelection().getRangeAt(0).collapsed").toBool(); - } -}; - -void tst_QWebPage::cursorMovements() -{ - CursorTrackedPage* page = new CursorTrackedPage; - QString content("

The quick brown fox

jumps over the lazy dog

May the source
be with you!

"); - page->mainFrame()->setHtml(content); - - // this will select the first paragraph - QString script = "var range = document.createRange(); " \ - "var node = document.getElementById(\"one\"); " \ - "range.selectNode(node); " \ - "getSelection().addRange(range);"; - page->mainFrame()->evaluateJavaScript(script); - QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox")); - - QRegExp regExp(" style=\".*\""); - regExp.setMinimal(true); - QCOMPARE(page->selectedHtml().trimmed().replace(regExp, ""), QString::fromLatin1("

The quick brown fox

")); - - // these actions must exist - QVERIFY(page->action(QWebPage::MoveToNextChar) != 0); - QVERIFY(page->action(QWebPage::MoveToPreviousChar) != 0); - QVERIFY(page->action(QWebPage::MoveToNextWord) != 0); - QVERIFY(page->action(QWebPage::MoveToPreviousWord) != 0); - QVERIFY(page->action(QWebPage::MoveToNextLine) != 0); - QVERIFY(page->action(QWebPage::MoveToPreviousLine) != 0); - QVERIFY(page->action(QWebPage::MoveToStartOfLine) != 0); - QVERIFY(page->action(QWebPage::MoveToEndOfLine) != 0); - QVERIFY(page->action(QWebPage::MoveToStartOfBlock) != 0); - QVERIFY(page->action(QWebPage::MoveToEndOfBlock) != 0); - QVERIFY(page->action(QWebPage::MoveToStartOfDocument) != 0); - QVERIFY(page->action(QWebPage::MoveToEndOfDocument) != 0); - - // right now they are disabled because contentEditable is false - QCOMPARE(page->action(QWebPage::MoveToNextChar)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::MoveToPreviousChar)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::MoveToNextWord)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::MoveToPreviousWord)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::MoveToNextLine)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::MoveToPreviousLine)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::MoveToStartOfLine)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::MoveToEndOfLine)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::MoveToStartOfBlock)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::MoveToEndOfBlock)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::MoveToStartOfDocument)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::MoveToEndOfDocument)->isEnabled(), false); - - // make it editable before navigating the cursor - page->setContentEditable(true); - - // here the actions are enabled after contentEditable is true - QCOMPARE(page->action(QWebPage::MoveToNextChar)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::MoveToPreviousChar)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::MoveToNextWord)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::MoveToPreviousWord)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::MoveToNextLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::MoveToPreviousLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::MoveToStartOfLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::MoveToEndOfLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::MoveToStartOfBlock)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::MoveToEndOfBlock)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::MoveToStartOfDocument)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::MoveToEndOfDocument)->isEnabled(), true); - - // cursor will be before the word "jump" - page->triggerAction(QWebPage::MoveToNextChar); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 0); - - // cursor will be between 'j' and 'u' in the word "jump" - page->triggerAction(QWebPage::MoveToNextChar); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 1); - - // cursor will be between 'u' and 'm' in the word "jump" - page->triggerAction(QWebPage::MoveToNextChar); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 2); - - // cursor will be after the word "jump" - page->triggerAction(QWebPage::MoveToNextWord); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 5); - - // cursor will be after the word "lazy" - page->triggerAction(QWebPage::MoveToNextWord); - page->triggerAction(QWebPage::MoveToNextWord); - page->triggerAction(QWebPage::MoveToNextWord); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 19); - - // cursor will be between 'z' and 'y' in "lazy" - page->triggerAction(QWebPage::MoveToPreviousChar); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 18); - - // cursor will be between 'a' and 'z' in "lazy" - page->triggerAction(QWebPage::MoveToPreviousChar); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 17); - - // cursor will be before the word "lazy" - page->triggerAction(QWebPage::MoveToPreviousWord); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 15); - - // cursor will be before the word "quick" - page->triggerAction(QWebPage::MoveToPreviousWord); - page->triggerAction(QWebPage::MoveToPreviousWord); - page->triggerAction(QWebPage::MoveToPreviousWord); - page->triggerAction(QWebPage::MoveToPreviousWord); - page->triggerAction(QWebPage::MoveToPreviousWord); - page->triggerAction(QWebPage::MoveToPreviousWord); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 4); - - // cursor will be between 'p' and 's' in the word "jumps" - page->triggerAction(QWebPage::MoveToNextWord); - page->triggerAction(QWebPage::MoveToNextWord); - page->triggerAction(QWebPage::MoveToNextWord); - page->triggerAction(QWebPage::MoveToNextChar); - page->triggerAction(QWebPage::MoveToNextChar); - page->triggerAction(QWebPage::MoveToNextChar); - page->triggerAction(QWebPage::MoveToNextChar); - page->triggerAction(QWebPage::MoveToNextChar); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 4); - - // cursor will be before the word "jumps" - page->triggerAction(QWebPage::MoveToStartOfLine); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 0); - - // cursor will be after the word "dog" - page->triggerAction(QWebPage::MoveToEndOfLine); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 23); - - // cursor will be between 'w' and 'n' in "brown" - page->triggerAction(QWebPage::MoveToStartOfLine); - page->triggerAction(QWebPage::MoveToPreviousWord); - page->triggerAction(QWebPage::MoveToPreviousWord); - page->triggerAction(QWebPage::MoveToNextChar); - page->triggerAction(QWebPage::MoveToNextChar); - page->triggerAction(QWebPage::MoveToNextChar); - page->triggerAction(QWebPage::MoveToNextChar); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 14); - - // cursor will be after the word "fox" - page->triggerAction(QWebPage::MoveToEndOfLine); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 19); - - // cursor will be before the word "The" - page->triggerAction(QWebPage::MoveToStartOfDocument); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 0); - - // cursor will be after the word "you!" - page->triggerAction(QWebPage::MoveToEndOfDocument); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 12); - - // cursor will be before the word "be" - page->triggerAction(QWebPage::MoveToStartOfBlock); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 0); - - // cursor will be after the word "you!" - page->triggerAction(QWebPage::MoveToEndOfBlock); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 12); - - // try to move before the document start - page->triggerAction(QWebPage::MoveToStartOfDocument); - page->triggerAction(QWebPage::MoveToPreviousChar); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 0); - page->triggerAction(QWebPage::MoveToStartOfDocument); - page->triggerAction(QWebPage::MoveToPreviousWord); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 0); - - // try to move past the document end - page->triggerAction(QWebPage::MoveToEndOfDocument); - page->triggerAction(QWebPage::MoveToNextChar); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 12); - page->triggerAction(QWebPage::MoveToEndOfDocument); - page->triggerAction(QWebPage::MoveToNextWord); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 12); - - delete page; -} - -void tst_QWebPage::textSelection() -{ - CursorTrackedPage* page = new CursorTrackedPage; - QString content("

The quick brown fox

" \ - "

jumps over the lazy dog

" \ - "

May the source
be with you!

"); - page->mainFrame()->setHtml(content); - - // these actions must exist - QVERIFY(page->action(QWebPage::SelectAll) != 0); - QVERIFY(page->action(QWebPage::SelectNextChar) != 0); - QVERIFY(page->action(QWebPage::SelectPreviousChar) != 0); - QVERIFY(page->action(QWebPage::SelectNextWord) != 0); - QVERIFY(page->action(QWebPage::SelectPreviousWord) != 0); - QVERIFY(page->action(QWebPage::SelectNextLine) != 0); - QVERIFY(page->action(QWebPage::SelectPreviousLine) != 0); - QVERIFY(page->action(QWebPage::SelectStartOfLine) != 0); - QVERIFY(page->action(QWebPage::SelectEndOfLine) != 0); - QVERIFY(page->action(QWebPage::SelectStartOfBlock) != 0); - QVERIFY(page->action(QWebPage::SelectEndOfBlock) != 0); - QVERIFY(page->action(QWebPage::SelectStartOfDocument) != 0); - QVERIFY(page->action(QWebPage::SelectEndOfDocument) != 0); - - // right now they are disabled because contentEditable is false and - // there isn't an existing selection to modify - QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SelectPreviousWord)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SelectNextLine)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SelectPreviousLine)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SelectStartOfLine)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SelectEndOfLine)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SelectStartOfBlock)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SelectEndOfBlock)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SelectStartOfDocument)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SelectEndOfDocument)->isEnabled(), false); - - // ..but SelectAll is awalys enabled - QCOMPARE(page->action(QWebPage::SelectAll)->isEnabled(), true); - - // Verify hasSelection returns false since there is no selection yet... - QCOMPARE(page->hasSelection(), false); - - // this will select the first paragraph - QString selectScript = "var range = document.createRange(); " \ - "var node = document.getElementById(\"one\"); " \ - "range.selectNode(node); " \ - "getSelection().addRange(range);"; - page->mainFrame()->evaluateJavaScript(selectScript); - QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox")); - QRegExp regExp(" style=\".*\""); - regExp.setMinimal(true); - QCOMPARE(page->selectedHtml().trimmed().replace(regExp, ""), QString::fromLatin1("

The quick brown fox

")); - - // Make sure hasSelection returns true, since there is selected text now... - QCOMPARE(page->hasSelection(), true); - - // here the actions are enabled after a selection has been created - QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectPreviousWord)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectNextLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectPreviousLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectStartOfLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectEndOfLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectStartOfBlock)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectEndOfBlock)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectStartOfDocument)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectEndOfDocument)->isEnabled(), true); - - // make it editable before navigating the cursor - page->setContentEditable(true); - - // cursor will be before the word "The", this makes sure there is a charet - page->triggerAction(QWebPage::MoveToStartOfDocument); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 0); - - // here the actions are enabled after contentEditable is true - QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectPreviousWord)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectNextLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectPreviousLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectStartOfLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectEndOfLine)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectStartOfBlock)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectEndOfBlock)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectStartOfDocument)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SelectEndOfDocument)->isEnabled(), true); - - delete page; -} - -void tst_QWebPage::textEditing() -{ - CursorTrackedPage* page = new CursorTrackedPage; - QString content("

The quick brown fox

" \ - "

jumps over the lazy dog

" \ - "

May the source
be with you!

"); - page->mainFrame()->setHtml(content); - - // these actions must exist - QVERIFY(page->action(QWebPage::Cut) != 0); - QVERIFY(page->action(QWebPage::Copy) != 0); - QVERIFY(page->action(QWebPage::Paste) != 0); - QVERIFY(page->action(QWebPage::DeleteStartOfWord) != 0); - QVERIFY(page->action(QWebPage::DeleteEndOfWord) != 0); - QVERIFY(page->action(QWebPage::SetTextDirectionDefault) != 0); - QVERIFY(page->action(QWebPage::SetTextDirectionLeftToRight) != 0); - QVERIFY(page->action(QWebPage::SetTextDirectionRightToLeft) != 0); - QVERIFY(page->action(QWebPage::ToggleBold) != 0); - QVERIFY(page->action(QWebPage::ToggleItalic) != 0); - QVERIFY(page->action(QWebPage::ToggleUnderline) != 0); - QVERIFY(page->action(QWebPage::InsertParagraphSeparator) != 0); - QVERIFY(page->action(QWebPage::InsertLineSeparator) != 0); - QVERIFY(page->action(QWebPage::PasteAndMatchStyle) != 0); - QVERIFY(page->action(QWebPage::RemoveFormat) != 0); - QVERIFY(page->action(QWebPage::ToggleStrikethrough) != 0); - QVERIFY(page->action(QWebPage::ToggleSubscript) != 0); - QVERIFY(page->action(QWebPage::ToggleSuperscript) != 0); - QVERIFY(page->action(QWebPage::InsertUnorderedList) != 0); - QVERIFY(page->action(QWebPage::InsertOrderedList) != 0); - QVERIFY(page->action(QWebPage::Indent) != 0); - QVERIFY(page->action(QWebPage::Outdent) != 0); - QVERIFY(page->action(QWebPage::AlignCenter) != 0); - QVERIFY(page->action(QWebPage::AlignJustified) != 0); - QVERIFY(page->action(QWebPage::AlignLeft) != 0); - QVERIFY(page->action(QWebPage::AlignRight) != 0); - - // right now they are disabled because contentEditable is false - QCOMPARE(page->action(QWebPage::Cut)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::Paste)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::DeleteStartOfWord)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::DeleteEndOfWord)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SetTextDirectionDefault)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SetTextDirectionLeftToRight)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::SetTextDirectionRightToLeft)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::ToggleBold)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::ToggleItalic)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::ToggleUnderline)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::InsertParagraphSeparator)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::InsertLineSeparator)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::PasteAndMatchStyle)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::RemoveFormat)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::ToggleStrikethrough)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::ToggleSubscript)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::ToggleSuperscript)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::InsertUnorderedList)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::InsertOrderedList)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::Indent)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::Outdent)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::AlignCenter)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::AlignJustified)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::AlignLeft)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::AlignRight)->isEnabled(), false); - - // Select everything - page->triggerAction(QWebPage::SelectAll); - - // make sure it is enabled since there is a selection - QCOMPARE(page->action(QWebPage::Copy)->isEnabled(), true); - - // make it editable before navigating the cursor - page->setContentEditable(true); - - // clear the selection - page->triggerAction(QWebPage::MoveToStartOfDocument); - QVERIFY(page->isSelectionCollapsed()); - QCOMPARE(page->selectionStartOffset(), 0); - - // make sure it is disabled since there isn't a selection - QCOMPARE(page->action(QWebPage::Copy)->isEnabled(), false); - - // here the actions are enabled after contentEditable is true - QCOMPARE(page->action(QWebPage::Paste)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::DeleteStartOfWord)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::DeleteEndOfWord)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SetTextDirectionDefault)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SetTextDirectionLeftToRight)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::SetTextDirectionRightToLeft)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::ToggleBold)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::ToggleItalic)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::ToggleUnderline)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::InsertParagraphSeparator)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::InsertLineSeparator)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::PasteAndMatchStyle)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::ToggleStrikethrough)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::ToggleSubscript)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::ToggleSuperscript)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::InsertUnorderedList)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::InsertOrderedList)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::Indent)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::Outdent)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::AlignCenter)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::AlignJustified)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::AlignLeft)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::AlignRight)->isEnabled(), true); - - // make sure these are disabled since there isn't a selection - QCOMPARE(page->action(QWebPage::Cut)->isEnabled(), false); - QCOMPARE(page->action(QWebPage::RemoveFormat)->isEnabled(), false); - - // make sure everything is selected - page->triggerAction(QWebPage::SelectAll); - - // this is only true if there is an editable selection - QCOMPARE(page->action(QWebPage::Cut)->isEnabled(), true); - QCOMPARE(page->action(QWebPage::RemoveFormat)->isEnabled(), true); - - delete page; -} - -void tst_QWebPage::requestCache() -{ - TestPage page; - QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); - - page.mainFrame()->setUrl(QString("data:text/html,Click me")); - QTRY_COMPARE(loadSpy.count(), 1); - QTRY_COMPARE(page.navigations.count(), 1); - - page.mainFrame()->setUrl(QString("data:text/html,Click me2")); - QTRY_COMPARE(loadSpy.count(), 2); - QTRY_COMPARE(page.navigations.count(), 2); - - page.triggerAction(QWebPage::Stop); - QVERIFY(page.history()->canGoBack()); - page.triggerAction(QWebPage::Back); - - QTRY_COMPARE(loadSpy.count(), 3); - QTRY_COMPARE(page.navigations.count(), 3); - QCOMPARE(page.navigations.at(0).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(), - (int)QNetworkRequest::PreferNetwork); - QCOMPARE(page.navigations.at(1).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(), - (int)QNetworkRequest::PreferNetwork); - QCOMPARE(page.navigations.at(2).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(), - (int)QNetworkRequest::PreferCache); -} - -void tst_QWebPage::loadCachedPage() -{ - TestPage page; - QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); - page.settings()->setMaximumPagesInCache(3); - - page.mainFrame()->load(QUrl("data:text/html,This is first page")); - - QTRY_COMPARE(loadSpy.count(), 1); - QTRY_COMPARE(page.navigations.count(), 1); - - QUrl firstPageUrl = page.mainFrame()->url(); - page.mainFrame()->load(QUrl("data:text/html,This is second page")); - - QTRY_COMPARE(loadSpy.count(), 2); - QTRY_COMPARE(page.navigations.count(), 2); - - page.triggerAction(QWebPage::Stop); - QVERIFY(page.history()->canGoBack()); - - QSignalSpy urlSpy(page.mainFrame(), SIGNAL(urlChanged(QUrl))); - QVERIFY(urlSpy.isValid()); - - page.triggerAction(QWebPage::Back); - ::waitForSignal(page.mainFrame(), SIGNAL(urlChanged(QUrl))); - QCOMPARE(urlSpy.size(), 1); - - QList arguments1 = urlSpy.takeFirst(); - QCOMPARE(arguments1.at(0).toUrl(), firstPageUrl); - -} -void tst_QWebPage::backActionUpdate() -{ - QWebView view; - QWebPage *page = view.page(); - QAction *action = page->action(QWebPage::Back); - QVERIFY(!action->isEnabled()); - QSignalSpy loadSpy(page, SIGNAL(loadFinished(bool))); - QUrl url = QUrl("qrc:///resources/framedindex.html"); - page->mainFrame()->load(url); - QTRY_COMPARE(loadSpy.count(), 1); - QVERIFY(!action->isEnabled()); - QTest::mouseClick(&view, Qt::LeftButton, 0, QPoint(10, 10)); - QTRY_COMPARE(loadSpy.count(), 2); - - QVERIFY(action->isEnabled()); -} - -void frameAtHelper(QWebPage* webPage, QWebFrame* webFrame, QPoint framePosition) -{ - if (!webFrame) - return; - - framePosition += QPoint(webFrame->pos()); - QList children = webFrame->childFrames(); - for (int i = 0; i < children.size(); ++i) { - if (children.at(i)->childFrames().size() > 0) - frameAtHelper(webPage, children.at(i), framePosition); - - QRect frameRect(children.at(i)->pos() + framePosition, children.at(i)->geometry().size()); - QVERIFY(children.at(i) == webPage->frameAt(frameRect.topLeft())); - } -} - -void tst_QWebPage::frameAt() -{ - QWebView webView; - QWebPage* webPage = webView.page(); - QSignalSpy loadSpy(webPage, SIGNAL(loadFinished(bool))); - QUrl url = QUrl("qrc:///resources/iframe.html"); - webPage->mainFrame()->load(url); - QTRY_COMPARE(loadSpy.count(), 1); - frameAtHelper(webPage, webPage->mainFrame(), webPage->mainFrame()->pos()); -} - -void tst_QWebPage::inputMethods_data() -{ - QTest::addColumn("viewType"); - QTest::newRow("QWebView") << "QWebView"; - QTest::newRow("QGraphicsWebView") << "QGraphicsWebView"; -} - -static Qt::InputMethodHints inputMethodHints(QObject* object) -{ - if (QGraphicsObject* o = qobject_cast(object)) - return o->inputMethodHints(); - if (QWidget* w = qobject_cast(object)) - return w->inputMethodHints(); - return Qt::InputMethodHints(); -} - -static bool inputMethodEnabled(QObject* object) -{ - if (QGraphicsObject* o = qobject_cast(object)) - return o->flags() & QGraphicsItem::ItemAcceptsInputMethod; - if (QWidget* w = qobject_cast(object)) - return w->testAttribute(Qt::WA_InputMethodEnabled); - return false; -} - -static void clickOnPage(QWebPage* page, const QPoint& position) -{ - QMouseEvent evpres(QEvent::MouseButtonPress, position, Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - page->event(&evpres); - QMouseEvent evrel(QEvent::MouseButtonRelease, position, Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - page->event(&evrel); -} - -void tst_QWebPage::inputMethods() -{ - QFETCH(QString, viewType); - QWebPage* page = new QWebPage; - QObject* view = 0; - QObject* container = 0; - if (viewType == "QWebView") { - QWebView* wv = new QWebView; - wv->setPage(page); - view = wv; - container = view; - } else if (viewType == "QGraphicsWebView") { - QGraphicsWebView* wv = new QGraphicsWebView; - wv->setPage(page); - view = wv; - - QGraphicsView* gv = new QGraphicsView; - QGraphicsScene* scene = new QGraphicsScene(gv); - gv->setScene(scene); - scene->addItem(wv); - wv->setGeometry(QRect(0, 0, 500, 500)); - - container = gv; - } else - QVERIFY2(false, "Unknown view type"); - - page->settings()->setFontFamily(QWebSettings::SerifFont, page->settings()->fontFamily(QWebSettings::FixedFont)); - page->mainFrame()->setHtml("" \ - "
" \ - "" \ - ""); - page->mainFrame()->setFocus(); - - TestInputContext testContext; - - QWebElementCollection inputs = page->mainFrame()->documentElement().findAll("input"); - QPoint textInputCenter = inputs.at(0).geometry().center(); - - clickOnPage(page, textInputCenter); - - // This part of the test checks if the SIP (Software Input Panel) is triggered, - // which normally happens on mobile platforms, when a user input form receives - // a mouse click. - int inputPanel = 0; - if (viewType == "QWebView") { - if (QWebView* wv = qobject_cast(view)) - inputPanel = wv->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel); - } else if (viewType == "QGraphicsWebView") { - if (QGraphicsWebView* wv = qobject_cast(view)) - inputPanel = wv->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel); - } - - // For non-mobile platforms RequestSoftwareInputPanel event is not called - // because there is no SIP (Software Input Panel) triggered. In the case of a - // mobile platform, an input panel, e.g. virtual keyboard, is usually invoked - // and the RequestSoftwareInputPanel event is called. For these two situations - // this part of the test can verified as the checks below. - if (inputPanel) - QVERIFY(testContext.isInputPanelVisible()); - else - QVERIFY(!testContext.isInputPanelVisible()); - testContext.hideInputPanel(); - - clickOnPage(page, textInputCenter); - QVERIFY(testContext.isInputPanelVisible()); - - //ImMicroFocus - QVariant variant = page->inputMethodQuery(Qt::ImMicroFocus); - QVERIFY(inputs.at(0).geometry().contains(variant.toRect().topLeft())); - - // We assigned the serif font famility to be the same as the fixef font family. - // Then test ImFont on a serif styled element, we should get our fixef font family. - variant = page->inputMethodQuery(Qt::ImFont); - QFont font = variant.value(); - QCOMPARE(page->settings()->fontFamily(QWebSettings::FixedFont), font.family()); - - QList inputAttributes; - - //Insert text. - { - QInputMethodEvent eventText("QtWebKit", inputAttributes); - QSignalSpy signalSpy(page, SIGNAL(microFocusChanged())); - page->event(&eventText); - QCOMPARE(signalSpy.count(), 0); - } - - { - QInputMethodEvent eventText("", inputAttributes); - eventText.setCommitString(QString("QtWebKit"), 0, 0); - page->event(&eventText); - } - - //ImMaximumTextLength - variant = page->inputMethodQuery(Qt::ImMaximumTextLength); - QCOMPARE(20, variant.toInt()); - - //Set selection - inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 3, 2, QVariant()); - QInputMethodEvent eventSelection("",inputAttributes); - page->event(&eventSelection); - - //ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - int anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 3); - - //ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - int cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 5); - - //ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - QString selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("eb")); - - //Set selection with negative length - inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 6, -5, QVariant()); - QInputMethodEvent eventSelection3("",inputAttributes); - page->event(&eventSelection3); - - //ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 1); - - //ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 6); - - //ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("tWebK")); - - //ImSurroundingText - variant = page->inputMethodQuery(Qt::ImSurroundingText); - QString value = variant.value(); - QCOMPARE(value, QString("QtWebKit")); - - { - QList attributes; - // Clear the selection, so the next test does not clear any contents. - QInputMethodEvent::Attribute newSelection(QInputMethodEvent::Selection, 0, 0, QVariant()); - attributes.append(newSelection); - QInputMethodEvent event("composition", attributes); - page->event(&event); - } - - // A ongoing composition should not change the surrounding text before it is committed. - variant = page->inputMethodQuery(Qt::ImSurroundingText); - value = variant.value(); - QCOMPARE(value, QString("QtWebKit")); - - // Cancel current composition first - inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant()); - QInputMethodEvent eventSelection4("", inputAttributes); - page->event(&eventSelection4); - - // START - Tests for Selection when the Editor is NOT in Composition mode - - // LEFT to RIGHT selection - // Deselect the selection by sending MouseButtonPress events - // This moves the current cursor to the end of the text - clickOnPage(page, textInputCenter); - - { - QList attributes; - QInputMethodEvent event(QString(), attributes); - event.setCommitString("XXX", 0, 0); - page->event(&event); - event.setCommitString(QString(), -2, 2); // Erase two characters. - page->event(&event); - event.setCommitString(QString(), -1, 1); // Erase one character. - page->event(&event); - variant = page->inputMethodQuery(Qt::ImSurroundingText); - value = variant.value(); - QCOMPARE(value, QString("QtWebKit")); - } - - //Move to the start of the line - page->triggerAction(QWebPage::MoveToStartOfLine); - - QKeyEvent keyRightEventPress(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier); - QKeyEvent keyRightEventRelease(QEvent::KeyRelease, Qt::Key_Right, Qt::NoModifier); - - //Move 2 characters RIGHT - for (int j = 0; j < 2; ++j) { - page->event(&keyRightEventPress); - page->event(&keyRightEventRelease); - } - - //Select to the end of the line - page->triggerAction(QWebPage::SelectEndOfLine); - - //ImAnchorPosition QtWebKit - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 2); - - //ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 8); - - //ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("WebKit")); - - //RIGHT to LEFT selection - //Deselect the selection (this moves the current cursor to the end of the text) - clickOnPage(page, textInputCenter); - - //ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 8); - - //ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 8); - - //ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("")); - - QKeyEvent keyLeftEventPress(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); - QKeyEvent keyLeftEventRelease(QEvent::KeyRelease, Qt::Key_Left, Qt::NoModifier); - - //Move 2 characters LEFT - for (int i = 0; i < 2; ++i) { - page->event(&keyLeftEventPress); - page->event(&keyLeftEventRelease); - } - - //Select to the start of the line - page->triggerAction(QWebPage::SelectStartOfLine); - - //ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 6); - - //ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 0); - - //ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("QtWebK")); - - //END - Tests for Selection when the Editor is not in Composition mode - - //ImhHiddenText - QPoint passwordInputCenter = inputs.at(1).geometry().center(); - clickOnPage(page, passwordInputCenter); - - QVERIFY(inputMethodEnabled(view)); - QVERIFY(inputMethodHints(view) & Qt::ImhHiddenText); - - clickOnPage(page, textInputCenter); - QVERIFY(!(inputMethodHints(view) & Qt::ImhHiddenText)); - - page->mainFrame()->setHtml("

nothing to input here"); - testContext.hideInputPanel(); - - QWebElement para = page->mainFrame()->findFirstElement("p"); - clickOnPage(page, para.geometry().center()); - - QVERIFY(!testContext.isInputPanelVisible()); - - //START - Test for sending empty QInputMethodEvent - page->mainFrame()->setHtml("" \ - "" \ - ""); - page->mainFrame()->evaluateJavaScript("var inputEle = document.getElementById('input3'); inputEle.focus(); inputEle.select();"); - - //Send empty QInputMethodEvent - QInputMethodEvent emptyEvent; - page->event(&emptyEvent); - - QString inputValue = page->mainFrame()->evaluateJavaScript("document.getElementById('input3').value").toString(); - QCOMPARE(inputValue, QString("QtWebKit2")); - //END - Test for sending empty QInputMethodEvent - - page->mainFrame()->setHtml("" \ - "" \ - ""); - page->mainFrame()->evaluateJavaScript("var inputEle = document.getElementById('input4'); inputEle.focus(); inputEle.select();"); - - // Clear the selection, also cancel the ongoing composition if there is one. - { - QList attributes; - QInputMethodEvent::Attribute newSelection(QInputMethodEvent::Selection, 0, 0, QVariant()); - attributes.append(newSelection); - QInputMethodEvent event("", attributes); - page->event(&event); - } - - // ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("")); - - variant = page->inputMethodQuery(Qt::ImSurroundingText); - QString surroundingValue = variant.value(); - QCOMPARE(surroundingValue, QString("QtWebKit inputMethod")); - - // ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 0); - - // ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 0); - - // 1. Insert a character to the begining of the line. - // Send temporary text, which makes the editor has composition 'm'. - { - QList attributes; - QInputMethodEvent event("m", attributes); - page->event(&event); - } - - // ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("")); - - // ImSurroundingText - variant = page->inputMethodQuery(Qt::ImSurroundingText); - surroundingValue = variant.value(); - QCOMPARE(surroundingValue, QString("QtWebKit inputMethod")); - - // ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 0); - - // ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 0); - - // Send temporary text, which makes the editor has composition 'n'. - { - QList attributes; - QInputMethodEvent event("n", attributes); - page->event(&event); - } - - // ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("")); - - // ImSurroundingText - variant = page->inputMethodQuery(Qt::ImSurroundingText); - surroundingValue = variant.value(); - QCOMPARE(surroundingValue, QString("QtWebKit inputMethod")); - - // ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 0); - - // ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 0); - - // Send commit text, which makes the editor conforms composition. - { - QList attributes; - QInputMethodEvent event("", attributes); - event.setCommitString("o"); - page->event(&event); - } - - // ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("")); - - // ImSurroundingText - variant = page->inputMethodQuery(Qt::ImSurroundingText); - surroundingValue = variant.value(); - QCOMPARE(surroundingValue, QString("oQtWebKit inputMethod")); - - // ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 1); - - // ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 1); - - // 2. insert a character to the middle of the line. - // Send temporary text, which makes the editor has composition 'd'. - { - QList attributes; - QInputMethodEvent event("d", attributes); - page->event(&event); - } - - // ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("")); - - // ImSurroundingText - variant = page->inputMethodQuery(Qt::ImSurroundingText); - surroundingValue = variant.value(); - QCOMPARE(surroundingValue, QString("oQtWebKit inputMethod")); - - // ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 1); - - // ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 1); - - // Send commit text, which makes the editor conforms composition. - { - QList attributes; - QInputMethodEvent event("", attributes); - event.setCommitString("e"); - page->event(&event); - } - - // ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("")); - - // ImSurroundingText - variant = page->inputMethodQuery(Qt::ImSurroundingText); - surroundingValue = variant.value(); - QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethod")); - - // ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 2); - - // ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 2); - - // 3. Insert a character to the end of the line. - page->triggerAction(QWebPage::MoveToEndOfLine); - - // Send temporary text, which makes the editor has composition 't'. - { - QList attributes; - QInputMethodEvent event("t", attributes); - page->event(&event); - } - - // ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("")); - - // ImSurroundingText - variant = page->inputMethodQuery(Qt::ImSurroundingText); - surroundingValue = variant.value(); - QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethod")); - - // ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 22); - - // ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 22); - - // Send commit text, which makes the editor conforms composition. - { - QList attributes; - QInputMethodEvent event("", attributes); - event.setCommitString("t"); - page->event(&event); - } - - // ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("")); - - // ImSurroundingText - variant = page->inputMethodQuery(Qt::ImSurroundingText); - surroundingValue = variant.value(); - QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethodt")); - - // ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 23); - - // ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 23); - - // 4. Replace the selection. - page->triggerAction(QWebPage::SelectPreviousWord); - - // ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("inputMethodt")); - - // ImSurroundingText - variant = page->inputMethodQuery(Qt::ImSurroundingText); - surroundingValue = variant.value(); - QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethodt")); - - // ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 11); - - // ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 23); - - // Send temporary text, which makes the editor has composition 'w'. - { - QList attributes; - QInputMethodEvent event("w", attributes); - page->event(&event); - } - - // ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("")); - - // ImSurroundingText - variant = page->inputMethodQuery(Qt::ImSurroundingText); - surroundingValue = variant.value(); - QCOMPARE(surroundingValue, QString("oeQtWebKit ")); - - // ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 11); - - // ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 11); - - // Send commit text, which makes the editor conforms composition. - { - QList attributes; - QInputMethodEvent event("", attributes); - event.setCommitString("2"); - page->event(&event); - } - - // ImCurrentSelection - variant = page->inputMethodQuery(Qt::ImCurrentSelection); - selectionValue = variant.value(); - QCOMPARE(selectionValue, QString("")); - - // ImSurroundingText - variant = page->inputMethodQuery(Qt::ImSurroundingText); - surroundingValue = variant.value(); - QCOMPARE(surroundingValue, QString("oeQtWebKit 2")); - - // ImCursorPosition - variant = page->inputMethodQuery(Qt::ImCursorPosition); - cursorPosition = variant.toInt(); - QCOMPARE(cursorPosition, 12); - - // ImAnchorPosition - variant = page->inputMethodQuery(Qt::ImAnchorPosition); - anchorPosition = variant.toInt(); - QCOMPARE(anchorPosition, 12); - - // Check sending RequestSoftwareInputPanel event - page->mainFrame()->setHtml("" \ - "" \ - "

abc
"\ - ""); - QWebElement inputElement = page->mainFrame()->findFirstElement("div"); - clickOnPage(page, inputElement.geometry().center()); - - QVERIFY(!testContext.isInputPanelVisible()); - - // START - Newline test for textarea - qApp->processEvents(); - page->mainFrame()->setHtml("" \ - "
- diff --git a/Source/WebKit/qt/tests/qwebview/resources/scrolltest_page.html b/Source/WebKit/qt/tests/qwebview/resources/scrolltest_page.html deleted file mode 100644 index 18fcbbebe..000000000 --- a/Source/WebKit/qt/tests/qwebview/resources/scrolltest_page.html +++ /dev/null @@ -1,6 +0,0 @@ - -Scrolling test - -
- - diff --git a/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp deleted file mode 100644 index f4db608d4..000000000 --- a/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp +++ /dev/null @@ -1,546 +0,0 @@ -/* - Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) - Copyright (C) 2009 Torch Mobile Inc. - Copyright (C) 2009 Girish Ramakrishnan - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include "../util.h" - -#include -#include -#include -#include -#include -#include -#include - -#define VERIFY_INPUTMETHOD_HINTS(actual, expect) \ - QVERIFY(actual == expect); - -class tst_QWebView : public QObject -{ - Q_OBJECT - -public Q_SLOTS: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private Q_SLOTS: - void renderingAfterMaxAndBack(); - void renderHints(); - void getWebKitVersion(); - - void reusePage_data(); - void reusePage(); - void microFocusCoordinates(); - void focusInputTypes(); - void horizontalScrollbarTest(); - - void crashTests(); -#if !(defined(USE_QT_MOBILE_THEME) && USE_QT_MOBILE_THEME) - void setPalette_data(); - void setPalette(); -#endif - void innerOuterRect(); -}; - -// This will be called before the first test function is executed. -// It is only called once. -void tst_QWebView::initTestCase() -{ -} - -// This will be called after the last test function is executed. -// It is only called once. -void tst_QWebView::cleanupTestCase() -{ -} - -// This will be called before each test function is executed. -void tst_QWebView::init() -{ -} - -// This will be called after every test function. -void tst_QWebView::cleanup() -{ -} - -void tst_QWebView::renderHints() -{ - QWebView webView; - - // default is only text antialiasing + smooth pixmap transform - QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); - QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); - QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); - - webView.setRenderHint(QPainter::Antialiasing, true); - QVERIFY(webView.renderHints() & QPainter::Antialiasing); - QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); - QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); - - webView.setRenderHint(QPainter::Antialiasing, false); - QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); - QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); - QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); - - webView.setRenderHint(QPainter::SmoothPixmapTransform, true); - QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); - QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); - QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); - - webView.setRenderHint(QPainter::SmoothPixmapTransform, false); - QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); - QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform)); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); -} - -void tst_QWebView::getWebKitVersion() -{ - QVERIFY(qWebKitVersion().toDouble() > 0); -} - -void tst_QWebView::reusePage_data() -{ - QTest::addColumn("html"); - QTest::newRow("WithoutPlugin") << "text"; - QTest::newRow("WindowedPlugin") << QString("text"); - QTest::newRow("WindowlessPlugin") << QString("text"); -} - -void tst_QWebView::reusePage() -{ - if (!QDir(TESTS_SOURCE_DIR).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll); - - QDir::setCurrent(TESTS_SOURCE_DIR); - - QFETCH(QString, html); - QWebView* view1 = new QWebView; - QPointer page = new QWebPage; - view1->setPage(page.data()); - page.data()->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - QWebFrame* mainFrame = page.data()->mainFrame(); - mainFrame->setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR)); - if (html.contains("")) { - // some reasonable time for the PluginStream to feed test.swf to flash and start painting - waitForSignal(view1, SIGNAL(loadFinished(bool)), 2000); - } - - view1->show(); - QTest::qWaitForWindowExposed(view1); - delete view1; - QVERIFY(page != 0); // deleting view must not have deleted the page, since it's not a child of view - - QWebView *view2 = new QWebView; - view2->setPage(page.data()); - view2->show(); // in Windowless mode, you should still be able to see the plugin here - QTest::qWaitForWindowExposed(view2); - delete view2; - - delete page.data(); // must not crash - - QDir::setCurrent(QApplication::applicationDirPath()); -} - -// Class used in crashTests -class WebViewCrashTest : public QObject { - Q_OBJECT - QWebView* m_view; -public: - bool m_executed; - - - WebViewCrashTest(QWebView* view) - : m_view(view) - , m_executed(false) - { - view->connect(view, SIGNAL(loadProgress(int)), this, SLOT(loading(int))); - } - -private Q_SLOTS: - void loading(int progress) - { - if (progress >= 20 && progress < 90) { - QVERIFY(!m_executed); - m_view->stop(); - m_executed = true; - } - } -}; - - -// Should not crash. -void tst_QWebView::crashTests() -{ - // Test if loading can be stopped in loadProgress handler without crash. - // Test page should have frames. - QWebView view; - WebViewCrashTest tester(&view); - QUrl url("qrc:///resources/index.html"); - view.load(url); - QTRY_VERIFY(tester.m_executed); // If fail it means that the test wasn't executed. -} - -void tst_QWebView::microFocusCoordinates() -{ - QWebPage* page = new QWebPage; - QWebView* webView = new QWebView; - webView->setPage( page ); - - page->mainFrame()->setHtml("" \ - "
" \ - "" \ - "
" \ - "" \ - ""); - - page->mainFrame()->setFocus(); - - QVariant initialMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); - QVERIFY(initialMicroFocus.isValid()); - - page->mainFrame()->scroll(0,50); - - QVariant currentMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); - QVERIFY(currentMicroFocus.isValid()); - - QCOMPARE(initialMicroFocus.toRect().translated(QPoint(0,-50)), currentMicroFocus.toRect()); -} - -void tst_QWebView::focusInputTypes() -{ - QWebView webView; - webView.show(); - QTest::qWaitForWindowExposed(&webView); - - QUrl url("qrc:///resources/input_types.html"); - QWebFrame* const mainFrame = webView.page()->mainFrame(); - mainFrame->load(url); - mainFrame->setFocus(); - - QVERIFY(waitForSignal(&webView, SIGNAL(loadFinished(bool)))); - - // 'text' type - QWebElement inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=text]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); - QVERIFY(webView.inputMethodHints() == Qt::ImhNone); - QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); - - // 'password' field - inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); - VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhHiddenText); - QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); - - // 'tel' field - inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=tel]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); - VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhDialableCharactersOnly); - QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); - - // 'number' field - inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=number]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); - VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhDigitsOnly); - QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); - - // 'email' field - inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=email]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); - VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhEmailCharactersOnly); - QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); - - // 'url' field - inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=url]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); - VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhUrlCharactersOnly); - QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); - - // 'password' field - inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); - VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhHiddenText); - QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); - - // 'text' type - inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=text]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); - QVERIFY(webView.inputMethodHints() == Qt::ImhNone); - QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); - - // 'password' field - inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); - VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhHiddenText); - QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); - - // 'text area' field - inputElement = mainFrame->documentElement().findFirst(QLatin1String("textarea")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); - QVERIFY(webView.inputMethodHints() == Qt::ImhNone); - QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); -} - -void tst_QWebView::horizontalScrollbarTest() -{ - QWebView webView; - webView.resize(600, 600); - webView.show(); - QTest::qWaitForWindowExposed(&webView); - - QUrl url("qrc:///resources/scrolltest_page.html"); - QWebFrame* const mainFrame = webView.page()->mainFrame(); - mainFrame->load(url); - mainFrame->setFocus(); - - QVERIFY(waitForSignal(&webView, SIGNAL(loadFinished(bool)))); - - QVERIFY(webView.page()->mainFrame()->scrollPosition() == QPoint(0, 0)); - - // Note: The test below assumes that the layout direction is Qt::LeftToRight. - QTest::mouseClick(&webView, Qt::LeftButton, 0, QPoint(550, 595)); - QVERIFY(webView.page()->mainFrame()->scrollPosition().x() > 0); - - // Note: The test below assumes that the layout direction is Qt::LeftToRight. - QTest::mouseClick(&webView, Qt::LeftButton, 0, QPoint(20, 595)); - QVERIFY(webView.page()->mainFrame()->scrollPosition() == QPoint(0, 0)); -} - - -#if !(defined(USE_QT_MOBILE_THEME) && USE_QT_MOBILE_THEME) -void tst_QWebView::setPalette_data() -{ - QTest::addColumn("active"); - QTest::addColumn("background"); - QTest::newRow("activeBG") << true << true; - QTest::newRow("activeFG") << true << false; - QTest::newRow("inactiveBG") << false << true; - QTest::newRow("inactiveFG") << false << false; -} - -// Render a QWebView to a QImage twice, each time with a different palette set, -// verify that images rendered are not the same, confirming WebCore usage of -// custom palette on selections. -void tst_QWebView::setPalette() -{ - QString html = "" - "" - "Some text here" - "" - ""; - - QFETCH(bool, active); - QFETCH(bool, background); - - QWidget* activeView = 0; - - // Use controlView to manage active/inactive state of test views by raising - // or lowering their position in the window stack. - QWebView controlView; - controlView.setHtml(html); - - QWebView view1; - - QPalette palette1; - QBrush brush1(Qt::red); - brush1.setStyle(Qt::SolidPattern); - if (active && background) { - // Rendered image must have red background on an active QWebView. - palette1.setBrush(QPalette::Active, QPalette::Highlight, brush1); - } else if (active && !background) { - // Rendered image must have red foreground on an active QWebView. - palette1.setBrush(QPalette::Active, QPalette::HighlightedText, brush1); - } else if (!active && background) { - // Rendered image must have red background on an inactive QWebView. - palette1.setBrush(QPalette::Inactive, QPalette::Highlight, brush1); - } else if (!active && !background) { - // Rendered image must have red foreground on an inactive QWebView. - palette1.setBrush(QPalette::Inactive, QPalette::HighlightedText, brush1); - } - - view1.setPalette(palette1); - view1.setHtml(html); - view1.page()->setViewportSize(view1.page()->currentFrame()->contentsSize()); - view1.show(); - - QTest::qWaitForWindowExposed(&view1); - - if (!active) { - controlView.show(); - QTest::qWaitForWindowExposed(&controlView); - activeView = &controlView; - controlView.activateWindow(); - } else { - view1.activateWindow(); - activeView = &view1; - } - - QTRY_COMPARE(QApplication::activeWindow(), activeView); - - view1.page()->triggerAction(QWebPage::SelectAll); - - QImage img1(view1.page()->viewportSize(), QImage::Format_ARGB32); - QPainter painter1(&img1); - view1.page()->currentFrame()->render(&painter1); - painter1.end(); - view1.close(); - controlView.close(); - - QWebView view2; - - QPalette palette2; - QBrush brush2(Qt::blue); - brush2.setStyle(Qt::SolidPattern); - if (active && background) { - // Rendered image must have blue background on an active QWebView. - palette2.setBrush(QPalette::Active, QPalette::Highlight, brush2); - } else if (active && !background) { - // Rendered image must have blue foreground on an active QWebView. - palette2.setBrush(QPalette::Active, QPalette::HighlightedText, brush2); - } else if (!active && background) { - // Rendered image must have blue background on an inactive QWebView. - palette2.setBrush(QPalette::Inactive, QPalette::Highlight, brush2); - } else if (!active && !background) { - // Rendered image must have blue foreground on an inactive QWebView. - palette2.setBrush(QPalette::Inactive, QPalette::HighlightedText, brush2); - } - - view2.setPalette(palette2); - view2.setHtml(html); - view2.page()->setViewportSize(view2.page()->currentFrame()->contentsSize()); - view2.show(); - - QTest::qWaitForWindowExposed(&view2); - - if (!active) { - controlView.show(); - QTest::qWaitForWindowExposed(&controlView); - activeView = &controlView; - controlView.activateWindow(); - } else { - view2.activateWindow(); - activeView = &view2; - } - - QTRY_COMPARE(QApplication::activeWindow(), activeView); - - view2.page()->triggerAction(QWebPage::SelectAll); - - QImage img2(view2.page()->viewportSize(), QImage::Format_ARGB32); - QPainter painter2(&img2); - view2.page()->currentFrame()->render(&painter2); - painter2.end(); - - view2.close(); - controlView.close(); - - QVERIFY(img1 != img2); -} -#endif - -void tst_QWebView::renderingAfterMaxAndBack() -{ - QUrl url = QUrl("data:text/html," - "" - "" - ""); - - QWebView view; - view.page()->mainFrame()->load(url); - QVERIFY(waitForSignal(&view, SIGNAL(loadFinished(bool)))); - view.show(); - - view.page()->settings()->setMaximumPagesInCache(3); - - QTest::qWaitForWindowExposed(&view); - - QPixmap reference(view.page()->viewportSize()); - reference.fill(Qt::red); - - QPixmap image(view.page()->viewportSize()); - QPainter painter(&image); - view.page()->currentFrame()->render(&painter); - - QCOMPARE(image, reference); - - QUrl url2 = QUrl("data:text/html," - "" - "" - ""); - view.page()->mainFrame()->load(url2); - - QVERIFY(waitForSignal(&view, SIGNAL(loadFinished(bool)))); - - view.showMaximized(); - - QTest::qWaitForWindowExposed(&view); - - QPixmap reference2(view.page()->viewportSize()); - reference2.fill(Qt::blue); - - QPixmap image2(view.page()->viewportSize()); - QPainter painter2(&image2); - view.page()->currentFrame()->render(&painter2); - - QCOMPARE(image2, reference2); - - view.back(); - - QPixmap reference3(view.page()->viewportSize()); - reference3.fill(Qt::red); - QPixmap image3(view.page()->viewportSize()); - QPainter painter3(&image3); - view.page()->currentFrame()->render(&painter3); - - QCOMPARE(image3, reference3); -} - -void tst_QWebView::innerOuterRect() -{ - QUrl url = QUrl("data:text/html," - "" - "" - ""); - QWebView view; - view.page()->mainFrame()->load(url); - QVERIFY(waitForSignal(&view, SIGNAL(loadFinished(bool)))); - view.showMaximized(); - const QRect frameGeometry = view.frameGeometry(); - const QRect geometry = view.geometry(); - QVariant outerWidth = view.page()->mainFrame()->evaluateJavaScript("window.outerWidth;"); - QCOMPARE(outerWidth.toInt(), frameGeometry.width()); - QVariant innerWidth = view.page()->mainFrame()->evaluateJavaScript("window.innerWidth;"); - QCOMPARE(innerWidth.toInt(), geometry.width()); - QVariant outerHeight = view.page()->mainFrame()->evaluateJavaScript("window.outerHeight;"); - QCOMPARE(outerHeight.toInt(), frameGeometry.height()); - QVariant innerHeight = view.page()->mainFrame()->evaluateJavaScript("window.innerHeight;"); - QCOMPARE(innerHeight.toInt(), geometry.height()); -} - -QTEST_MAIN(tst_QWebView) -#include "tst_qwebview.moc" - diff --git a/Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc b/Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc deleted file mode 100644 index e4b9ad776..000000000 --- a/Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc +++ /dev/null @@ -1,9 +0,0 @@ - - - resources/index.html - resources/frame_a.html - resources/input_types.html - resources/scrolltest_page.html - - - diff --git a/Source/WebKit/qt/tests/resources/image2.png b/Source/WebKit/qt/tests/resources/image2.png deleted file mode 100644 index 8d703640c..000000000 Binary files a/Source/WebKit/qt/tests/resources/image2.png and /dev/null differ diff --git a/Source/WebKit/qt/tests/util.h b/Source/WebKit/qt/tests/util.h deleted file mode 100644 index 4925aa4c7..000000000 --- a/Source/WebKit/qt/tests/util.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -// Functions and macros that really need to be in QTestLib - -#if 0 -#pragma qt_no_master_include -#endif - -#include -#include -#include - -#if !defined(TESTS_SOURCE_DIR) -#define TESTS_SOURCE_DIR "" -#endif - -/** - * Starts an event loop that runs until the given signal is received. - * Optionally the event loop - * can return earlier on a timeout. - * - * \return \p true if the requested signal was received - * \p false on timeout - */ -static inline bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) -{ - QEventLoop loop; - QObject::connect(obj, signal, &loop, SLOT(quit())); - QTimer timer; - QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); - if (timeout > 0) { - QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - timer.setSingleShot(true); - timer.start(timeout); - } - loop.exec(); - return timeoutSpy.isEmpty(); -} - -/** - * Just like QSignalSpy but facilitates sync and async - * signal emission. For example if you want to verify that - * page->foo() emitted a signal, it could be that the - * implementation decides to emit the signal asynchronously - * - in which case we want to spin a local event loop until - * emission - or that the call to foo() emits it right away. - */ -class SignalBarrier : private QSignalSpy -{ -public: - SignalBarrier(const QObject* obj, const char* aSignal) - : QSignalSpy(obj, aSignal) - { } - - bool ensureSignalEmitted() - { - bool result = count() > 0; - if (!result) - result = wait(); - clear(); - return result; - } -}; - -#define W_QSKIP(a, b) QSKIP(a) diff --git a/Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro b/Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro new file mode 100644 index 000000000..4a8d86f80 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro @@ -0,0 +1,4 @@ +include(../tests.pri) +SOURCES += $${TARGET}.cpp +QT += webkit-private +DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" diff --git a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro new file mode 100644 index 000000000..02dc197c7 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro @@ -0,0 +1,3 @@ +include(../tests.pri) +SOURCES += $${TARGET}.cpp +QT += webkit-private diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro new file mode 100644 index 000000000..e8ac901f1 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro @@ -0,0 +1,18 @@ +include(../tests.pri) +SOURCES += tst_qmltests.cpp +TARGET = tst_qmltests_DesktopBehavior +OBJECTS_DIR = .obj_DesktopBehavior + +QT += webkit-private +CONFIG += testcase + +QT += qmltest + +DEFINES += DISABLE_FLICKABLE_VIEWPORT=1 +# Test the QML files under DesktopBehavior in the source repository. +DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD$${QMAKE_DIR_SEP}DesktopBehavior\\\"\" +DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" + +OTHER_FILES += \ + DesktopBehavior/* \ + common/* diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro new file mode 100644 index 000000000..6c67da96e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro @@ -0,0 +1,19 @@ +include(../tests.pri) +SOURCES += tst_qmltests.cpp +TARGET = tst_qmltests_WebView +OBJECTS_DIR = .obj_WebView + +QT += webkit-private +CONFIG += testcase + +QT += qmltest + +# Test the QML files under WebView in the source repository. +DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD$${QMAKE_DIR_SEP}WebView\\\"\" +DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" + +OTHER_FILES += \ + WebView/* \ + common/* + +RESOURCES = resources.qrc diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro new file mode 100644 index 000000000..8ddc4484e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS += DesktopBehavior.pro WebView.pro diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro new file mode 100644 index 000000000..4a8d86f80 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro @@ -0,0 +1,4 @@ +include(../tests.pri) +SOURCES += $${TARGET}.cpp +QT += webkit-private +DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro new file mode 100644 index 000000000..02dc197c7 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro @@ -0,0 +1,3 @@ +include(../tests.pri) +SOURCES += $${TARGET}.cpp +QT += webkit-private diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri new file mode 100644 index 000000000..a1133530d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri @@ -0,0 +1,20 @@ +TEMPLATE = app + +VPATH += $$_PRO_FILE_PWD_ +TARGET = tst_$$TARGET + +INCLUDEPATH += $$PWD +SOURCES += ../util.cpp + +QT += testlib webkit +have?(QTQUICK) { + QT += qml quick quick-private + HEADERS += ../bytearraytestdata.h \ + ../util.h + + SOURCES += ../bytearraytestdata.cpp +} +WEBKIT += wtf # For platform macros + +DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD\\\" \ + QWP_PATH=\\\"$${ROOT_BUILD_DIR}/bin\\\" diff --git a/Tools/qt/manifest.txt b/Tools/qt/manifest.txt index 39414cc5f..364b7d464 100644 --- a/Tools/qt/manifest.txt +++ b/Tools/qt/manifest.txt @@ -157,3 +157,5 @@ file Tools/Scripts/webkitperl/FeatureList.pm file Tools/jhbuild/jhbuildutils.py file WebKit.pro file .qmake.conf + +directory tests diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..306095ae0 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(webkitwidgets) diff --git a/tests/tests.pro b/tests/tests.pro new file mode 100644 index 000000000..483a6691b --- /dev/null +++ b/tests/tests.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += webkitwidgets diff --git a/tests/webkitwidgets/CMakeLists.txt b/tests/webkitwidgets/CMakeLists.txt new file mode 100644 index 000000000..42d636573 --- /dev/null +++ b/tests/webkitwidgets/CMakeLists.txt @@ -0,0 +1,66 @@ +remove_definitions(-DQT_ASCII_CAST_WARNINGS) + +include_directories( + "${CMAKE_SOURCE_DIR}/Source" + "${FORWARDING_HEADERS_DIR}" + "${WEBKIT_DIR}/qt/Api" + "${WEBKIT_DIR}/qt/WidgetApi" +) + +include_directories(SYSTEM + ${ICU_INCLUDE_DIRS} + ${Qt5Gui_PRIVATE_INCLUDE_DIRS} + ${Qt5Widgets_INCLUDE_DIRS} + ${Qt5Test_INCLUDE_DIRS} +) + +add_definitions(-DTESTS_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/") + +if (ENABLE_TEST_SUPPORT) + add_definitions(-DHAVE_QTTESTSUPPORT) +endif () + +set(QtWK1ApiTests_LIBRARIES + ${Qt5Gui_LIBRARIES} + ${Qt5Network_LIBRARIES} + ${Qt5Test_LIBRARIES} + ${Qt5Widgets_LIBRARIES} + WebKitWidgets +) + +# Inspired by EFL WK2 tests +set(QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY + ${CMAKE_BINARY_DIR}/tests +) + +set(QtWK1ApiTests + hybridPixmap + qgraphicswebview + qobjectbridge + qwebelement + qwebframe + qwebhistory + qwebhistoryinterface + qwebinspector + qwebpage + qwebsecurityorigin + qwebview +) + +set(tst_hybridPixmap_SOURCES hybridPixmap/widget.cpp) +qt5_wrap_ui(tst_hybridPixmap_SOURCES hybridPixmap/widget.ui) + +foreach (testName ${QtWK1ApiTests}) + list(APPEND tst_${testName}_SOURCES ${testName}/tst_${testName}.cpp) + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${testName}/tst_${testName}.qrc") + qt5_add_resources(tst_${testName}_SOURCES ${testName}/tst_${testName}.qrc) + endif () + + add_executable(tst_${testName} ${tst_${testName}_SOURCES}) + target_include_directories(tst_${testName} PRIVATE ${testName}) + target_link_libraries(tst_${testName} ${QtWK1ApiTests_LIBRARIES}) + set_target_properties(tst_${testName} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY} AUTOMOC ON) + + add_test(${testName} "${QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY}/tst_${testName}") + set_tests_properties(${testName} PROPERTIES TIMEOUT 60) +endforeach () diff --git a/tests/webkitwidgets/MIMESniffing/TestData.h b/tests/webkitwidgets/MIMESniffing/TestData.h new file mode 100644 index 000000000..c04bd6b89 --- /dev/null +++ b/tests/webkitwidgets/MIMESniffing/TestData.h @@ -0,0 +1,984 @@ +/* + Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef TestData_h +#define TestData_h + +typedef struct _TestData { + const char* file; + const char* advertisedType; + bool isImage; + const char* sniffedType; +} TestData; + +static const TestData testList[] = { + {":/application_atom+xml", "text/plain", false, "text/plain"}, + {":/application_atom+xml", "text/plain", true, "text/plain"}, + {":/application_atom+xml", "unknown/unknown", false, "text/xml"}, + {":/application_atom+xml", "unknown/unknown", true, "text/xml"}, + {":/application_atom+xml", "application/unknown", false, "text/xml"}, + {":/application_atom+xml", "application/unknown", true, "text/xml"}, + {":/application_atom+xml", "*/*", false, "text/xml"}, + {":/application_atom+xml", "*/*", true, "text/xml"}, + {":/application_atom+xml", "text/xml", false, 0}, + {":/application_atom+xml", "text/xml", true, 0}, + {":/application_atom+xml", "application/xml", false, 0}, + {":/application_atom+xml", "application/xml", true, 0}, + {":/application_atom+xml", "text/html", false, "application/atom+xml"}, + {":/application_atom+xml", "text/html", true, 0}, + {":/application_atom+xml", "text/xml", false, 0}, + {":/application_atom+xml", "text/xml", true, 0}, + {":/application_atom+xml", "application/pdf", false, 0}, + {":/application_atom+xml", "application/pdf", true, 0}, + {":/application_atom+xml", "application/postscript", false, 0}, + {":/application_atom+xml", "application/postscript", true, 0}, + {":/application_atom+xml", "application/ogg", false, 0}, + {":/application_atom+xml", "application/ogg", true, 0}, + {":/application_atom+xml", "video/webm", false, 0}, + {":/application_atom+xml", "video/webm", true, 0}, + {":/application_atom+xml", "application/x-rar-compressed", false, 0}, + {":/application_atom+xml", "application/x-rar-compressed", true, 0}, + {":/application_atom+xml", "application/zip", false, 0}, + {":/application_atom+xml", "application/zip", true, 0}, + {":/application_atom+xml", "application/x-gzip", false, 0}, + {":/application_atom+xml", "application/x-gzip", true, 0}, + {":/application_atom+xml", "audio/x-wave", false, 0}, + {":/application_atom+xml", "audio/x-wave", true, 0}, + {":/application_atom+xml", "image/webp", false, 0}, + {":/application_atom+xml", "image/webp", true, 0}, + {":/application_atom+xml", "image/gif", false, 0}, + {":/application_atom+xml", "image/gif", true, 0}, + {":/application_atom+xml", "image/png", false, 0}, + {":/application_atom+xml", "image/png", true, 0}, + {":/application_atom+xml", "image/jpeg", false, 0}, + {":/application_atom+xml", "image/jpeg", true, 0}, + {":/application_atom+xml", "image/bmp", false, 0}, + {":/application_atom+xml", "image/bmp", true, 0}, + {":/application_atom+xml", "image/vnd.microsoft.icon", false, 0}, + {":/application_atom+xml", "image/vnd.microsoft.icon", true, 0}, + {":/application_atom+xml", "application/rdf+xml", false, 0}, + {":/application_atom+xml", "application/rdf+xml", true, 0}, + {":/application_atom+xml", "application/rss+xml", false, 0}, + {":/application_atom+xml", "application/rss+xml", true, 0}, + {":/application_atom+xml", "application/atom+xml", false, 0}, + {":/application_atom+xml", "application/atom+xml", true, 0}, + {":/application_ogg", "text/plain", false, "application/ogg"}, + {":/application_ogg", "text/plain", true, "application/ogg"}, + {":/application_ogg", "unknown/unknown", false, "application/ogg"}, + {":/application_ogg", "unknown/unknown", true, "application/ogg"}, + {":/application_ogg", "application/unknown", false, "application/ogg"}, + {":/application_ogg", "application/unknown", true, "application/ogg"}, + {":/application_ogg", "*/*", false, "application/ogg"}, + {":/application_ogg", "*/*", true, "application/ogg"}, + {":/application_ogg", "text/xml", false, 0}, + {":/application_ogg", "text/xml", true, 0}, + {":/application_ogg", "application/xml", false, 0}, + {":/application_ogg", "application/xml", true, 0}, + {":/application_ogg", "text/html", false, 0}, + {":/application_ogg", "text/html", true, 0}, + {":/application_ogg", "text/xml", false, 0}, + {":/application_ogg", "text/xml", true, 0}, + {":/application_ogg", "application/pdf", false, 0}, + {":/application_ogg", "application/pdf", true, 0}, + {":/application_ogg", "application/postscript", false, 0}, + {":/application_ogg", "application/postscript", true, 0}, + {":/application_ogg", "application/ogg", false, 0}, + {":/application_ogg", "application/ogg", true, 0}, + {":/application_ogg", "video/webm", false, 0}, + {":/application_ogg", "video/webm", true, 0}, + {":/application_ogg", "application/x-rar-compressed", false, 0}, + {":/application_ogg", "application/x-rar-compressed", true, 0}, + {":/application_ogg", "application/zip", false, 0}, + {":/application_ogg", "application/zip", true, 0}, + {":/application_ogg", "application/x-gzip", false, 0}, + {":/application_ogg", "application/x-gzip", true, 0}, + {":/application_ogg", "audio/x-wave", false, 0}, + {":/application_ogg", "audio/x-wave", true, 0}, + {":/application_ogg", "image/webp", false, 0}, + {":/application_ogg", "image/webp", true, 0}, + {":/application_ogg", "image/gif", false, 0}, + {":/application_ogg", "image/gif", true, 0}, + {":/application_ogg", "image/png", false, 0}, + {":/application_ogg", "image/png", true, 0}, + {":/application_ogg", "image/jpeg", false, 0}, + {":/application_ogg", "image/jpeg", true, 0}, + {":/application_ogg", "image/bmp", false, 0}, + {":/application_ogg", "image/bmp", true, 0}, + {":/application_ogg", "image/vnd.microsoft.icon", false, 0}, + {":/application_ogg", "image/vnd.microsoft.icon", true, 0}, + {":/application_ogg", "application/rdf+xml", false, 0}, + {":/application_ogg", "application/rdf+xml", true, 0}, + {":/application_ogg", "application/rss+xml", false, 0}, + {":/application_ogg", "application/rss+xml", true, 0}, + {":/application_ogg", "application/atom+xml", false, 0}, + {":/application_ogg", "application/atom+xml", true, 0}, + {":/application_pdf", "text/plain", false, "application/octet-stream"}, + {":/application_pdf", "text/plain", true, "application/octet-stream"}, + {":/application_pdf", "unknown/unknown", false, "application/pdf"}, + {":/application_pdf", "unknown/unknown", true, "application/pdf"}, + {":/application_pdf", "application/unknown", false, "application/pdf"}, + {":/application_pdf", "application/unknown", true, "application/pdf"}, + {":/application_pdf", "*/*", false, "application/pdf"}, + {":/application_pdf", "*/*", true, "application/pdf"}, + {":/application_pdf", "text/xml", false, 0}, + {":/application_pdf", "text/xml", true, 0}, + {":/application_pdf", "application/xml", false, 0}, + {":/application_pdf", "application/xml", true, 0}, + {":/application_pdf", "text/html", false, 0}, + {":/application_pdf", "text/html", true, 0}, + {":/application_pdf", "text/xml", false, 0}, + {":/application_pdf", "text/xml", true, 0}, + {":/application_pdf", "application/pdf", false, 0}, + {":/application_pdf", "application/pdf", true, 0}, + {":/application_pdf", "application/postscript", false, 0}, + {":/application_pdf", "application/postscript", true, 0}, + {":/application_pdf", "application/ogg", false, 0}, + {":/application_pdf", "application/ogg", true, 0}, + {":/application_pdf", "video/webm", false, 0}, + {":/application_pdf", "video/webm", true, 0}, + {":/application_pdf", "application/x-rar-compressed", false, 0}, + {":/application_pdf", "application/x-rar-compressed", true, 0}, + {":/application_pdf", "application/zip", false, 0}, + {":/application_pdf", "application/zip", true, 0}, + {":/application_pdf", "application/x-gzip", false, 0}, + {":/application_pdf", "application/x-gzip", true, 0}, + {":/application_pdf", "audio/x-wave", false, 0}, + {":/application_pdf", "audio/x-wave", true, 0}, + {":/application_pdf", "image/webp", false, 0}, + {":/application_pdf", "image/webp", true, 0}, + {":/application_pdf", "image/gif", false, 0}, + {":/application_pdf", "image/gif", true, 0}, + {":/application_pdf", "image/png", false, 0}, + {":/application_pdf", "image/png", true, 0}, + {":/application_pdf", "image/jpeg", false, 0}, + {":/application_pdf", "image/jpeg", true, 0}, + {":/application_pdf", "image/bmp", false, 0}, + {":/application_pdf", "image/bmp", true, 0}, + {":/application_pdf", "image/vnd.microsoft.icon", false, 0}, + {":/application_pdf", "image/vnd.microsoft.icon", true, 0}, + {":/application_pdf", "application/rdf+xml", false, 0}, + {":/application_pdf", "application/rdf+xml", true, 0}, + {":/application_pdf", "application/rss+xml", false, 0}, + {":/application_pdf", "application/rss+xml", true, 0}, + {":/application_pdf", "application/atom+xml", false, 0}, + {":/application_pdf", "application/atom+xml", true, 0}, + {":/application_postscript", "text/plain", false, "text/plain"}, + {":/application_postscript", "text/plain", true, "text/plain"}, + {":/application_postscript", "unknown/unknown", false, "application/postscript"}, + {":/application_postscript", "unknown/unknown", true, "application/postscript"}, + {":/application_postscript", "application/unknown", false, "application/postscript"}, + {":/application_postscript", "application/unknown", true, "application/postscript"}, + {":/application_postscript", "*/*", false, "application/postscript"}, + {":/application_postscript", "*/*", true, "application/postscript"}, + {":/application_postscript", "text/xml", false, 0}, + {":/application_postscript", "text/xml", true, 0}, + {":/application_postscript", "application/xml", false, 0}, + {":/application_postscript", "application/xml", true, 0}, + {":/application_postscript", "text/html", false, 0}, + {":/application_postscript", "text/html", true, 0}, + {":/application_postscript", "text/xml", false, 0}, + {":/application_postscript", "text/xml", true, 0}, + {":/application_postscript", "application/pdf", false, 0}, + {":/application_postscript", "application/pdf", true, 0}, + {":/application_postscript", "application/postscript", false, 0}, + {":/application_postscript", "application/postscript", true, 0}, + {":/application_postscript", "application/ogg", false, 0}, + {":/application_postscript", "application/ogg", true, 0}, + {":/application_postscript", "video/webm", false, 0}, + {":/application_postscript", "video/webm", true, 0}, + {":/application_postscript", "application/x-rar-compressed", false, 0}, + {":/application_postscript", "application/x-rar-compressed", true, 0}, + {":/application_postscript", "application/zip", false, 0}, + {":/application_postscript", "application/zip", true, 0}, + {":/application_postscript", "application/x-gzip", false, 0}, + {":/application_postscript", "application/x-gzip", true, 0}, + {":/application_postscript", "audio/x-wave", false, 0}, + {":/application_postscript", "audio/x-wave", true, 0}, + {":/application_postscript", "image/webp", false, 0}, + {":/application_postscript", "image/webp", true, 0}, + {":/application_postscript", "image/gif", false, 0}, + {":/application_postscript", "image/gif", true, 0}, + {":/application_postscript", "image/png", false, 0}, + {":/application_postscript", "image/png", true, 0}, + {":/application_postscript", "image/jpeg", false, 0}, + {":/application_postscript", "image/jpeg", true, 0}, + {":/application_postscript", "image/bmp", false, 0}, + {":/application_postscript", "image/bmp", true, 0}, + {":/application_postscript", "image/vnd.microsoft.icon", false, 0}, + {":/application_postscript", "image/vnd.microsoft.icon", true, 0}, + {":/application_postscript", "application/rdf+xml", false, 0}, + {":/application_postscript", "application/rdf+xml", true, 0}, + {":/application_postscript", "application/rss+xml", false, 0}, + {":/application_postscript", "application/rss+xml", true, 0}, + {":/application_postscript", "application/atom+xml", false, 0}, + {":/application_postscript", "application/atom+xml", true, 0}, + {":/application_rdf+xml", "text/plain", false, "text/plain"}, + {":/application_rdf+xml", "text/plain", true, "text/plain"}, + {":/application_rdf+xml", "unknown/unknown", false, "text/xml"}, + {":/application_rdf+xml", "unknown/unknown", true, "text/xml"}, + {":/application_rdf+xml", "application/unknown", false, "text/xml"}, + {":/application_rdf+xml", "application/unknown", true, "text/xml"}, + {":/application_rdf+xml", "*/*", false, "text/xml"}, + {":/application_rdf+xml", "*/*", true, "text/xml"}, + {":/application_rdf+xml", "text/xml", false, 0}, + {":/application_rdf+xml", "text/xml", true, 0}, + {":/application_rdf+xml", "application/xml", false, 0}, + {":/application_rdf+xml", "application/xml", true, 0}, + {":/application_rdf+xml", "text/html", false, "application/rdf+xml"}, + {":/application_rdf+xml", "text/html", true, 0}, + {":/application_rdf+xml", "text/xml", false, 0}, + {":/application_rdf+xml", "text/xml", true, 0}, + {":/application_rdf+xml", "application/pdf", false, 0}, + {":/application_rdf+xml", "application/pdf", true, 0}, + {":/application_rdf+xml", "application/postscript", false, 0}, + {":/application_rdf+xml", "application/postscript", true, 0}, + {":/application_rdf+xml", "application/ogg", false, 0}, + {":/application_rdf+xml", "application/ogg", true, 0}, + {":/application_rdf+xml", "video/webm", false, 0}, + {":/application_rdf+xml", "video/webm", true, 0}, + {":/application_rdf+xml", "application/x-rar-compressed", false, 0}, + {":/application_rdf+xml", "application/x-rar-compressed", true, 0}, + {":/application_rdf+xml", "application/zip", false, 0}, + {":/application_rdf+xml", "application/zip", true, 0}, + {":/application_rdf+xml", "application/x-gzip", false, 0}, + {":/application_rdf+xml", "application/x-gzip", true, 0}, + {":/application_rdf+xml", "audio/x-wave", false, 0}, + {":/application_rdf+xml", "audio/x-wave", true, 0}, + {":/application_rdf+xml", "image/webp", false, 0}, + {":/application_rdf+xml", "image/webp", true, 0}, + {":/application_rdf+xml", "image/gif", false, 0}, + {":/application_rdf+xml", "image/gif", true, 0}, + {":/application_rdf+xml", "image/png", false, 0}, + {":/application_rdf+xml", "image/png", true, 0}, + {":/application_rdf+xml", "image/jpeg", false, 0}, + {":/application_rdf+xml", "image/jpeg", true, 0}, + {":/application_rdf+xml", "image/bmp", false, 0}, + {":/application_rdf+xml", "image/bmp", true, 0}, + {":/application_rdf+xml", "image/vnd.microsoft.icon", false, 0}, + {":/application_rdf+xml", "image/vnd.microsoft.icon", true, 0}, + {":/application_rdf+xml", "application/rdf+xml", false, 0}, + {":/application_rdf+xml", "application/rdf+xml", true, 0}, + {":/application_rdf+xml", "application/rss+xml", false, 0}, + {":/application_rdf+xml", "application/rss+xml", true, 0}, + {":/application_rdf+xml", "application/atom+xml", false, 0}, + {":/application_rdf+xml", "application/atom+xml", true, 0}, + {":/application_rss+xml", "text/plain", false, "text/plain"}, + {":/application_rss+xml", "text/plain", true, "text/plain"}, + {":/application_rss+xml", "unknown/unknown", false, "text/xml"}, + {":/application_rss+xml", "unknown/unknown", true, "text/xml"}, + {":/application_rss+xml", "application/unknown", false, "text/xml"}, + {":/application_rss+xml", "application/unknown", true, "text/xml"}, + {":/application_rss+xml", "*/*", false, "text/xml"}, + {":/application_rss+xml", "*/*", true, "text/xml"}, + {":/application_rss+xml", "text/xml", false, 0}, + {":/application_rss+xml", "text/xml", true, 0}, + {":/application_rss+xml", "application/xml", false, 0}, + {":/application_rss+xml", "application/xml", true, 0}, + {":/application_rss+xml", "text/html", false, "application/rss+xml"}, + {":/application_rss+xml", "text/html", true, 0}, + {":/application_rss+xml", "text/xml", false, 0}, + {":/application_rss+xml", "text/xml", true, 0}, + {":/application_rss+xml", "application/pdf", false, 0}, + {":/application_rss+xml", "application/pdf", true, 0}, + {":/application_rss+xml", "application/postscript", false, 0}, + {":/application_rss+xml", "application/postscript", true, 0}, + {":/application_rss+xml", "application/ogg", false, 0}, + {":/application_rss+xml", "application/ogg", true, 0}, + {":/application_rss+xml", "video/webm", false, 0}, + {":/application_rss+xml", "video/webm", true, 0}, + {":/application_rss+xml", "application/x-rar-compressed", false, 0}, + {":/application_rss+xml", "application/x-rar-compressed", true, 0}, + {":/application_rss+xml", "application/zip", false, 0}, + {":/application_rss+xml", "application/zip", true, 0}, + {":/application_rss+xml", "application/x-gzip", false, 0}, + {":/application_rss+xml", "application/x-gzip", true, 0}, + {":/application_rss+xml", "audio/x-wave", false, 0}, + {":/application_rss+xml", "audio/x-wave", true, 0}, + {":/application_rss+xml", "image/webp", false, 0}, + {":/application_rss+xml", "image/webp", true, 0}, + {":/application_rss+xml", "image/gif", false, 0}, + {":/application_rss+xml", "image/gif", true, 0}, + {":/application_rss+xml", "image/png", false, 0}, + {":/application_rss+xml", "image/png", true, 0}, + {":/application_rss+xml", "image/jpeg", false, 0}, + {":/application_rss+xml", "image/jpeg", true, 0}, + {":/application_rss+xml", "image/bmp", false, 0}, + {":/application_rss+xml", "image/bmp", true, 0}, + {":/application_rss+xml", "image/vnd.microsoft.icon", false, 0}, + {":/application_rss+xml", "image/vnd.microsoft.icon", true, 0}, + {":/application_rss+xml", "application/rdf+xml", false, 0}, + {":/application_rss+xml", "application/rdf+xml", true, 0}, + {":/application_rss+xml", "application/rss+xml", false, 0}, + {":/application_rss+xml", "application/rss+xml", true, 0}, + {":/application_rss+xml", "application/atom+xml", false, 0}, + {":/application_rss+xml", "application/atom+xml", true, 0}, + {":/application_x-gzip", "text/plain", false, "application/x-gzip"}, + {":/application_x-gzip", "text/plain", true, "application/x-gzip"}, + {":/application_x-gzip", "unknown/unknown", false, "application/x-gzip"}, + {":/application_x-gzip", "unknown/unknown", true, "application/x-gzip"}, + {":/application_x-gzip", "application/unknown", false, "application/x-gzip"}, + {":/application_x-gzip", "application/unknown", true, "application/x-gzip"}, + {":/application_x-gzip", "*/*", false, "application/x-gzip"}, + {":/application_x-gzip", "*/*", true, "application/x-gzip"}, + {":/application_x-gzip", "text/xml", false, 0}, + {":/application_x-gzip", "text/xml", true, 0}, + {":/application_x-gzip", "application/xml", false, 0}, + {":/application_x-gzip", "application/xml", true, 0}, + {":/application_x-gzip", "text/html", false, 0}, + {":/application_x-gzip", "text/html", true, 0}, + {":/application_x-gzip", "text/xml", false, 0}, + {":/application_x-gzip", "text/xml", true, 0}, + {":/application_x-gzip", "application/pdf", false, 0}, + {":/application_x-gzip", "application/pdf", true, 0}, + {":/application_x-gzip", "application/postscript", false, 0}, + {":/application_x-gzip", "application/postscript", true, 0}, + {":/application_x-gzip", "application/ogg", false, 0}, + {":/application_x-gzip", "application/ogg", true, 0}, + {":/application_x-gzip", "video/webm", false, 0}, + {":/application_x-gzip", "video/webm", true, 0}, + {":/application_x-gzip", "application/x-rar-compressed", false, 0}, + {":/application_x-gzip", "application/x-rar-compressed", true, 0}, + {":/application_x-gzip", "application/zip", false, 0}, + {":/application_x-gzip", "application/zip", true, 0}, + {":/application_x-gzip", "application/x-gzip", false, 0}, + {":/application_x-gzip", "application/x-gzip", true, 0}, + {":/application_x-gzip", "audio/x-wave", false, 0}, + {":/application_x-gzip", "audio/x-wave", true, 0}, + {":/application_x-gzip", "image/webp", false, 0}, + {":/application_x-gzip", "image/webp", true, 0}, + {":/application_x-gzip", "image/gif", false, 0}, + {":/application_x-gzip", "image/gif", true, 0}, + {":/application_x-gzip", "image/png", false, 0}, + {":/application_x-gzip", "image/png", true, 0}, + {":/application_x-gzip", "image/jpeg", false, 0}, + {":/application_x-gzip", "image/jpeg", true, 0}, + {":/application_x-gzip", "image/bmp", false, 0}, + {":/application_x-gzip", "image/bmp", true, 0}, + {":/application_x-gzip", "image/vnd.microsoft.icon", false, 0}, + {":/application_x-gzip", "image/vnd.microsoft.icon", true, 0}, + {":/application_x-gzip", "application/rdf+xml", false, 0}, + {":/application_x-gzip", "application/rdf+xml", true, 0}, + {":/application_x-gzip", "application/rss+xml", false, 0}, + {":/application_x-gzip", "application/rss+xml", true, 0}, + {":/application_x-gzip", "application/atom+xml", false, 0}, + {":/application_x-gzip", "application/atom+xml", true, 0}, + {":/application_x-rar-compressed", "text/plain", false, "application/x-rar-compressed"}, + {":/application_x-rar-compressed", "text/plain", true, "application/x-rar-compressed"}, + {":/application_x-rar-compressed", "unknown/unknown", false, "application/x-rar-compressed"}, + {":/application_x-rar-compressed", "unknown/unknown", true, "application/x-rar-compressed"}, + {":/application_x-rar-compressed", "application/unknown", false, "application/x-rar-compressed"}, + {":/application_x-rar-compressed", "application/unknown", true, "application/x-rar-compressed"}, + {":/application_x-rar-compressed", "*/*", false, "application/x-rar-compressed"}, + {":/application_x-rar-compressed", "*/*", true, "application/x-rar-compressed"}, + {":/application_x-rar-compressed", "text/xml", false, 0}, + {":/application_x-rar-compressed", "text/xml", true, 0}, + {":/application_x-rar-compressed", "application/xml", false, 0}, + {":/application_x-rar-compressed", "application/xml", true, 0}, + {":/application_x-rar-compressed", "text/html", false, 0}, + {":/application_x-rar-compressed", "text/html", true, 0}, + {":/application_x-rar-compressed", "text/xml", false, 0}, + {":/application_x-rar-compressed", "text/xml", true, 0}, + {":/application_x-rar-compressed", "application/pdf", false, 0}, + {":/application_x-rar-compressed", "application/pdf", true, 0}, + {":/application_x-rar-compressed", "application/postscript", false, 0}, + {":/application_x-rar-compressed", "application/postscript", true, 0}, + {":/application_x-rar-compressed", "application/ogg", false, 0}, + {":/application_x-rar-compressed", "application/ogg", true, 0}, + {":/application_x-rar-compressed", "video/webm", false, 0}, + {":/application_x-rar-compressed", "video/webm", true, 0}, + {":/application_x-rar-compressed", "application/x-rar-compressed", false, 0}, + {":/application_x-rar-compressed", "application/x-rar-compressed", true, 0}, + {":/application_x-rar-compressed", "application/zip", false, 0}, + {":/application_x-rar-compressed", "application/zip", true, 0}, + {":/application_x-rar-compressed", "application/x-gzip", false, 0}, + {":/application_x-rar-compressed", "application/x-gzip", true, 0}, + {":/application_x-rar-compressed", "audio/x-wave", false, 0}, + {":/application_x-rar-compressed", "audio/x-wave", true, 0}, + {":/application_x-rar-compressed", "image/webp", false, 0}, + {":/application_x-rar-compressed", "image/webp", true, 0}, + {":/application_x-rar-compressed", "image/gif", false, 0}, + {":/application_x-rar-compressed", "image/gif", true, 0}, + {":/application_x-rar-compressed", "image/png", false, 0}, + {":/application_x-rar-compressed", "image/png", true, 0}, + {":/application_x-rar-compressed", "image/jpeg", false, 0}, + {":/application_x-rar-compressed", "image/jpeg", true, 0}, + {":/application_x-rar-compressed", "image/bmp", false, 0}, + {":/application_x-rar-compressed", "image/bmp", true, 0}, + {":/application_x-rar-compressed", "image/vnd.microsoft.icon", false, 0}, + {":/application_x-rar-compressed", "image/vnd.microsoft.icon", true, 0}, + {":/application_x-rar-compressed", "application/rdf+xml", false, 0}, + {":/application_x-rar-compressed", "application/rdf+xml", true, 0}, + {":/application_x-rar-compressed", "application/rss+xml", false, 0}, + {":/application_x-rar-compressed", "application/rss+xml", true, 0}, + {":/application_x-rar-compressed", "application/atom+xml", false, 0}, + {":/application_x-rar-compressed", "application/atom+xml", true, 0}, + {":/application_zip", "text/plain", false, "application/zip"}, + {":/application_zip", "text/plain", true, "application/zip"}, + {":/application_zip", "unknown/unknown", false, "application/zip"}, + {":/application_zip", "unknown/unknown", true, "application/zip"}, + {":/application_zip", "application/unknown", false, "application/zip"}, + {":/application_zip", "application/unknown", true, "application/zip"}, + {":/application_zip", "*/*", false, "application/zip"}, + {":/application_zip", "*/*", true, "application/zip"}, + {":/application_zip", "text/xml", false, 0}, + {":/application_zip", "text/xml", true, 0}, + {":/application_zip", "application/xml", false, 0}, + {":/application_zip", "application/xml", true, 0}, + {":/application_zip", "text/html", false, 0}, + {":/application_zip", "text/html", true, 0}, + {":/application_zip", "text/xml", false, 0}, + {":/application_zip", "text/xml", true, 0}, + {":/application_zip", "application/pdf", false, 0}, + {":/application_zip", "application/pdf", true, 0}, + {":/application_zip", "application/postscript", false, 0}, + {":/application_zip", "application/postscript", true, 0}, + {":/application_zip", "application/ogg", false, 0}, + {":/application_zip", "application/ogg", true, 0}, + {":/application_zip", "video/webm", false, 0}, + {":/application_zip", "video/webm", true, 0}, + {":/application_zip", "application/x-rar-compressed", false, 0}, + {":/application_zip", "application/x-rar-compressed", true, 0}, + {":/application_zip", "application/zip", false, 0}, + {":/application_zip", "application/zip", true, 0}, + {":/application_zip", "application/x-gzip", false, 0}, + {":/application_zip", "application/x-gzip", true, 0}, + {":/application_zip", "audio/x-wave", false, 0}, + {":/application_zip", "audio/x-wave", true, 0}, + {":/application_zip", "image/webp", false, 0}, + {":/application_zip", "image/webp", true, 0}, + {":/application_zip", "image/gif", false, 0}, + {":/application_zip", "image/gif", true, 0}, + {":/application_zip", "image/png", false, 0}, + {":/application_zip", "image/png", true, 0}, + {":/application_zip", "image/jpeg", false, 0}, + {":/application_zip", "image/jpeg", true, 0}, + {":/application_zip", "image/bmp", false, 0}, + {":/application_zip", "image/bmp", true, 0}, + {":/application_zip", "image/vnd.microsoft.icon", false, 0}, + {":/application_zip", "image/vnd.microsoft.icon", true, 0}, + {":/application_zip", "application/rdf+xml", false, 0}, + {":/application_zip", "application/rdf+xml", true, 0}, + {":/application_zip", "application/rss+xml", false, 0}, + {":/application_zip", "application/rss+xml", true, 0}, + {":/application_zip", "application/atom+xml", false, 0}, + {":/application_zip", "application/atom+xml", true, 0}, + {":/audio_x-wave", "text/plain", false, "audio/x-wave"}, + {":/audio_x-wave", "text/plain", true, "audio/x-wave"}, + {":/audio_x-wave", "unknown/unknown", false, "audio/x-wave"}, + {":/audio_x-wave", "unknown/unknown", true, "audio/x-wave"}, + {":/audio_x-wave", "application/unknown", false, "audio/x-wave"}, + {":/audio_x-wave", "application/unknown", true, "audio/x-wave"}, + {":/audio_x-wave", "*/*", false, "audio/x-wave"}, + {":/audio_x-wave", "*/*", true, "audio/x-wave"}, + {":/audio_x-wave", "text/xml", false, 0}, + {":/audio_x-wave", "text/xml", true, 0}, + {":/audio_x-wave", "application/xml", false, 0}, + {":/audio_x-wave", "application/xml", true, 0}, + {":/audio_x-wave", "text/html", false, 0}, + {":/audio_x-wave", "text/html", true, 0}, + {":/audio_x-wave", "text/xml", false, 0}, + {":/audio_x-wave", "text/xml", true, 0}, + {":/audio_x-wave", "application/pdf", false, 0}, + {":/audio_x-wave", "application/pdf", true, 0}, + {":/audio_x-wave", "application/postscript", false, 0}, + {":/audio_x-wave", "application/postscript", true, 0}, + {":/audio_x-wave", "application/ogg", false, 0}, + {":/audio_x-wave", "application/ogg", true, 0}, + {":/audio_x-wave", "video/webm", false, 0}, + {":/audio_x-wave", "video/webm", true, 0}, + {":/audio_x-wave", "application/x-rar-compressed", false, 0}, + {":/audio_x-wave", "application/x-rar-compressed", true, 0}, + {":/audio_x-wave", "application/zip", false, 0}, + {":/audio_x-wave", "application/zip", true, 0}, + {":/audio_x-wave", "application/x-gzip", false, 0}, + {":/audio_x-wave", "application/x-gzip", true, 0}, + {":/audio_x-wave", "audio/x-wave", false, 0}, + {":/audio_x-wave", "audio/x-wave", true, 0}, + {":/audio_x-wave", "image/webp", false, 0}, + {":/audio_x-wave", "image/webp", true, 0}, + {":/audio_x-wave", "image/gif", false, 0}, + {":/audio_x-wave", "image/gif", true, 0}, + {":/audio_x-wave", "image/png", false, 0}, + {":/audio_x-wave", "image/png", true, 0}, + {":/audio_x-wave", "image/jpeg", false, 0}, + {":/audio_x-wave", "image/jpeg", true, 0}, + {":/audio_x-wave", "image/bmp", false, 0}, + {":/audio_x-wave", "image/bmp", true, 0}, + {":/audio_x-wave", "image/vnd.microsoft.icon", false, 0}, + {":/audio_x-wave", "image/vnd.microsoft.icon", true, 0}, + {":/audio_x-wave", "application/rdf+xml", false, 0}, + {":/audio_x-wave", "application/rdf+xml", true, 0}, + {":/audio_x-wave", "application/rss+xml", false, 0}, + {":/audio_x-wave", "application/rss+xml", true, 0}, + {":/audio_x-wave", "application/atom+xml", false, 0}, + {":/audio_x-wave", "application/atom+xml", true, 0}, + {":/image_bmp", "text/plain", false, "image/bmp"}, + {":/image_bmp", "text/plain", true, "image/bmp"}, + {":/image_bmp", "unknown/unknown", false, "image/bmp"}, + {":/image_bmp", "unknown/unknown", true, "image/bmp"}, + {":/image_bmp", "application/unknown", false, "image/bmp"}, + {":/image_bmp", "application/unknown", true, "image/bmp"}, + {":/image_bmp", "*/*", false, "image/bmp"}, + {":/image_bmp", "*/*", true, "image/bmp"}, + {":/image_bmp", "text/xml", false, 0}, + {":/image_bmp", "text/xml", true, 0}, + {":/image_bmp", "application/xml", false, 0}, + {":/image_bmp", "application/xml", true, 0}, + {":/image_bmp", "text/html", false, 0}, + {":/image_bmp", "text/html", true, "image/bmp"}, + {":/image_bmp", "text/xml", false, 0}, + {":/image_bmp", "text/xml", true, 0}, + {":/image_bmp", "application/pdf", false, 0}, + {":/image_bmp", "application/pdf", true, "image/bmp"}, + {":/image_bmp", "application/postscript", false, 0}, + {":/image_bmp", "application/postscript", true, "image/bmp"}, + {":/image_bmp", "application/ogg", false, 0}, + {":/image_bmp", "application/ogg", true, "image/bmp"}, + {":/image_bmp", "video/webm", false, 0}, + {":/image_bmp", "video/webm", true, "image/bmp"}, + {":/image_bmp", "application/x-rar-compressed", false, 0}, + {":/image_bmp", "application/x-rar-compressed", true, "image/bmp"}, + {":/image_bmp", "application/zip", false, 0}, + {":/image_bmp", "application/zip", true, "image/bmp"}, + {":/image_bmp", "application/x-gzip", false, 0}, + {":/image_bmp", "application/x-gzip", true, "image/bmp"}, + {":/image_bmp", "audio/x-wave", false, 0}, + {":/image_bmp", "audio/x-wave", true, "image/bmp"}, + {":/image_bmp", "image/webp", false, 0}, + {":/image_bmp", "image/webp", true, "image/bmp"}, + {":/image_bmp", "image/gif", false, 0}, + {":/image_bmp", "image/gif", true, "image/bmp"}, + {":/image_bmp", "image/png", false, 0}, + {":/image_bmp", "image/png", true, "image/bmp"}, + {":/image_bmp", "image/jpeg", false, 0}, + {":/image_bmp", "image/jpeg", true, "image/bmp"}, + {":/image_bmp", "image/bmp", false, 0}, + {":/image_bmp", "image/bmp", true, "image/bmp"}, + {":/image_bmp", "image/vnd.microsoft.icon", false, 0}, + {":/image_bmp", "image/vnd.microsoft.icon", true, "image/bmp"}, + {":/image_bmp", "application/rdf+xml", false, 0}, + {":/image_bmp", "application/rdf+xml", true, 0}, + {":/image_bmp", "application/rss+xml", false, 0}, + {":/image_bmp", "application/rss+xml", true, 0}, + {":/image_bmp", "application/atom+xml", false, 0}, + {":/image_bmp", "application/atom+xml", true, 0}, + {":/image_gif", "text/plain", false, "image/gif"}, + {":/image_gif", "text/plain", true, "image/gif"}, + {":/image_gif", "unknown/unknown", false, "image/gif"}, + {":/image_gif", "unknown/unknown", true, "image/gif"}, + {":/image_gif", "application/unknown", false, "image/gif"}, + {":/image_gif", "application/unknown", true, "image/gif"}, + {":/image_gif", "*/*", false, "image/gif"}, + {":/image_gif", "*/*", true, "image/gif"}, + {":/image_gif", "text/xml", false, 0}, + {":/image_gif", "text/xml", true, 0}, + {":/image_gif", "application/xml", false, 0}, + {":/image_gif", "application/xml", true, 0}, + {":/image_gif", "text/html", false, 0}, + {":/image_gif", "text/html", true, "image/gif"}, + {":/image_gif", "text/xml", false, 0}, + {":/image_gif", "text/xml", true, 0}, + {":/image_gif", "application/pdf", false, 0}, + {":/image_gif", "application/pdf", true, "image/gif"}, + {":/image_gif", "application/postscript", false, 0}, + {":/image_gif", "application/postscript", true, "image/gif"}, + {":/image_gif", "application/ogg", false, 0}, + {":/image_gif", "application/ogg", true, "image/gif"}, + {":/image_gif", "video/webm", false, 0}, + {":/image_gif", "video/webm", true, "image/gif"}, + {":/image_gif", "application/x-rar-compressed", false, 0}, + {":/image_gif", "application/x-rar-compressed", true, "image/gif"}, + {":/image_gif", "application/zip", false, 0}, + {":/image_gif", "application/zip", true, "image/gif"}, + {":/image_gif", "application/x-gzip", false, 0}, + {":/image_gif", "application/x-gzip", true, "image/gif"}, + {":/image_gif", "audio/x-wave", false, 0}, + {":/image_gif", "audio/x-wave", true, "image/gif"}, + {":/image_gif", "image/webp", false, 0}, + {":/image_gif", "image/webp", true, "image/gif"}, + {":/image_gif", "image/gif", false, 0}, + {":/image_gif", "image/gif", true, "image/gif"}, + {":/image_gif", "image/png", false, 0}, + {":/image_gif", "image/png", true, "image/gif"}, + {":/image_gif", "image/jpeg", false, 0}, + {":/image_gif", "image/jpeg", true, "image/gif"}, + {":/image_gif", "image/bmp", false, 0}, + {":/image_gif", "image/bmp", true, "image/gif"}, + {":/image_gif", "image/vnd.microsoft.icon", false, 0}, + {":/image_gif", "image/vnd.microsoft.icon", true, "image/gif"}, + {":/image_gif", "application/rdf+xml", false, 0}, + {":/image_gif", "application/rdf+xml", true, 0}, + {":/image_gif", "application/rss+xml", false, 0}, + {":/image_gif", "application/rss+xml", true, 0}, + {":/image_gif", "application/atom+xml", false, 0}, + {":/image_gif", "application/atom+xml", true, 0}, + {":/image_jpeg", "text/plain", false, "image/jpeg"}, + {":/image_jpeg", "text/plain", true, "image/jpeg"}, + {":/image_jpeg", "unknown/unknown", false, "image/jpeg"}, + {":/image_jpeg", "unknown/unknown", true, "image/jpeg"}, + {":/image_jpeg", "application/unknown", false, "image/jpeg"}, + {":/image_jpeg", "application/unknown", true, "image/jpeg"}, + {":/image_jpeg", "*/*", false, "image/jpeg"}, + {":/image_jpeg", "*/*", true, "image/jpeg"}, + {":/image_jpeg", "text/xml", false, 0}, + {":/image_jpeg", "text/xml", true, 0}, + {":/image_jpeg", "application/xml", false, 0}, + {":/image_jpeg", "application/xml", true, 0}, + {":/image_jpeg", "text/html", false, 0}, + {":/image_jpeg", "text/html", true, "image/jpeg"}, + {":/image_jpeg", "text/xml", false, 0}, + {":/image_jpeg", "text/xml", true, 0}, + {":/image_jpeg", "application/pdf", false, 0}, + {":/image_jpeg", "application/pdf", true, "image/jpeg"}, + {":/image_jpeg", "application/postscript", false, 0}, + {":/image_jpeg", "application/postscript", true, "image/jpeg"}, + {":/image_jpeg", "application/ogg", false, 0}, + {":/image_jpeg", "application/ogg", true, "image/jpeg"}, + {":/image_jpeg", "video/webm", false, 0}, + {":/image_jpeg", "video/webm", true, "image/jpeg"}, + {":/image_jpeg", "application/x-rar-compressed", false, 0}, + {":/image_jpeg", "application/x-rar-compressed", true, "image/jpeg"}, + {":/image_jpeg", "application/zip", false, 0}, + {":/image_jpeg", "application/zip", true, "image/jpeg"}, + {":/image_jpeg", "application/x-gzip", false, 0}, + {":/image_jpeg", "application/x-gzip", true, "image/jpeg"}, + {":/image_jpeg", "audio/x-wave", false, 0}, + {":/image_jpeg", "audio/x-wave", true, "image/jpeg"}, + {":/image_jpeg", "image/webp", false, 0}, + {":/image_jpeg", "image/webp", true, "image/jpeg"}, + {":/image_jpeg", "image/gif", false, 0}, + {":/image_jpeg", "image/gif", true, "image/jpeg"}, + {":/image_jpeg", "image/png", false, 0}, + {":/image_jpeg", "image/png", true, "image/jpeg"}, + {":/image_jpeg", "image/jpeg", false, 0}, + {":/image_jpeg", "image/jpeg", true, "image/jpeg"}, + {":/image_jpeg", "image/bmp", false, 0}, + {":/image_jpeg", "image/bmp", true, "image/jpeg"}, + {":/image_jpeg", "image/vnd.microsoft.icon", false, 0}, + {":/image_jpeg", "image/vnd.microsoft.icon", true, "image/jpeg"}, + {":/image_jpeg", "application/rdf+xml", false, 0}, + {":/image_jpeg", "application/rdf+xml", true, 0}, + {":/image_jpeg", "application/rss+xml", false, 0}, + {":/image_jpeg", "application/rss+xml", true, 0}, + {":/image_jpeg", "application/atom+xml", false, 0}, + {":/image_jpeg", "application/atom+xml", true, 0}, + {":/image_png", "text/plain", false, "image/png"}, + {":/image_png", "text/plain", true, "image/png"}, + {":/image_png", "unknown/unknown", false, "image/png"}, + {":/image_png", "unknown/unknown", true, "image/png"}, + {":/image_png", "application/unknown", false, "image/png"}, + {":/image_png", "application/unknown", true, "image/png"}, + {":/image_png", "*/*", false, "image/png"}, + {":/image_png", "*/*", true, "image/png"}, + {":/image_png", "text/xml", false, 0}, + {":/image_png", "text/xml", true, 0}, + {":/image_png", "application/xml", false, 0}, + {":/image_png", "application/xml", true, 0}, + {":/image_png", "text/html", false, 0}, + {":/image_png", "text/html", true, "image/png"}, + {":/image_png", "text/xml", false, 0}, + {":/image_png", "text/xml", true, 0}, + {":/image_png", "application/pdf", false, 0}, + {":/image_png", "application/pdf", true, "image/png"}, + {":/image_png", "application/postscript", false, 0}, + {":/image_png", "application/postscript", true, "image/png"}, + {":/image_png", "application/ogg", false, 0}, + {":/image_png", "application/ogg", true, "image/png"}, + {":/image_png", "video/webm", false, 0}, + {":/image_png", "video/webm", true, "image/png"}, + {":/image_png", "application/x-rar-compressed", false, 0}, + {":/image_png", "application/x-rar-compressed", true, "image/png"}, + {":/image_png", "application/zip", false, 0}, + {":/image_png", "application/zip", true, "image/png"}, + {":/image_png", "application/x-gzip", false, 0}, + {":/image_png", "application/x-gzip", true, "image/png"}, + {":/image_png", "audio/x-wave", false, 0}, + {":/image_png", "audio/x-wave", true, "image/png"}, + {":/image_png", "image/webp", false, 0}, + {":/image_png", "image/webp", true, "image/png"}, + {":/image_png", "image/gif", false, 0}, + {":/image_png", "image/gif", true, "image/png"}, + {":/image_png", "image/png", false, 0}, + {":/image_png", "image/png", true, "image/png"}, + {":/image_png", "image/jpeg", false, 0}, + {":/image_png", "image/jpeg", true, "image/png"}, + {":/image_png", "image/bmp", false, 0}, + {":/image_png", "image/bmp", true, "image/png"}, + {":/image_png", "image/vnd.microsoft.icon", false, 0}, + {":/image_png", "image/vnd.microsoft.icon", true, "image/png"}, + {":/image_png", "application/rdf+xml", false, 0}, + {":/image_png", "application/rdf+xml", true, 0}, + {":/image_png", "application/rss+xml", false, 0}, + {":/image_png", "application/rss+xml", true, 0}, + {":/image_png", "application/atom+xml", false, 0}, + {":/image_png", "application/atom+xml", true, 0}, + {":/image_vnd.microsoft.icon", "text/plain", false, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "text/plain", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "unknown/unknown", false, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "unknown/unknown", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "application/unknown", false, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "application/unknown", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "*/*", false, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "*/*", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "text/xml", false, 0}, + {":/image_vnd.microsoft.icon", "text/xml", true, 0}, + {":/image_vnd.microsoft.icon", "application/xml", false, 0}, + {":/image_vnd.microsoft.icon", "application/xml", true, 0}, + {":/image_vnd.microsoft.icon", "text/html", false, 0}, + {":/image_vnd.microsoft.icon", "text/html", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "text/xml", false, 0}, + {":/image_vnd.microsoft.icon", "text/xml", true, 0}, + {":/image_vnd.microsoft.icon", "application/pdf", false, 0}, + {":/image_vnd.microsoft.icon", "application/pdf", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "application/postscript", false, 0}, + {":/image_vnd.microsoft.icon", "application/postscript", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "application/ogg", false, 0}, + {":/image_vnd.microsoft.icon", "application/ogg", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "video/webm", false, 0}, + {":/image_vnd.microsoft.icon", "video/webm", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "application/x-rar-compressed", false, 0}, + {":/image_vnd.microsoft.icon", "application/x-rar-compressed", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "application/zip", false, 0}, + {":/image_vnd.microsoft.icon", "application/zip", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "application/x-gzip", false, 0}, + {":/image_vnd.microsoft.icon", "application/x-gzip", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "audio/x-wave", false, 0}, + {":/image_vnd.microsoft.icon", "audio/x-wave", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "image/webp", false, 0}, + {":/image_vnd.microsoft.icon", "image/webp", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "image/gif", false, 0}, + {":/image_vnd.microsoft.icon", "image/gif", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "image/png", false, 0}, + {":/image_vnd.microsoft.icon", "image/png", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "image/jpeg", false, 0}, + {":/image_vnd.microsoft.icon", "image/jpeg", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "image/bmp", false, 0}, + {":/image_vnd.microsoft.icon", "image/bmp", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "image/vnd.microsoft.icon", false, 0}, + {":/image_vnd.microsoft.icon", "image/vnd.microsoft.icon", true, "image/vnd.microsoft.icon"}, + {":/image_vnd.microsoft.icon", "application/rdf+xml", false, 0}, + {":/image_vnd.microsoft.icon", "application/rdf+xml", true, 0}, + {":/image_vnd.microsoft.icon", "application/rss+xml", false, 0}, + {":/image_vnd.microsoft.icon", "application/rss+xml", true, 0}, + {":/image_vnd.microsoft.icon", "application/atom+xml", false, 0}, + {":/image_vnd.microsoft.icon", "application/atom+xml", true, 0}, + {":/image_webp", "text/plain", false, "image/webp"}, + {":/image_webp", "text/plain", true, "image/webp"}, + {":/image_webp", "unknown/unknown", false, "image/webp"}, + {":/image_webp", "unknown/unknown", true, "image/webp"}, + {":/image_webp", "application/unknown", false, "image/webp"}, + {":/image_webp", "application/unknown", true, "image/webp"}, + {":/image_webp", "*/*", false, "image/webp"}, + {":/image_webp", "*/*", true, "image/webp"}, + {":/image_webp", "text/xml", false, 0}, + {":/image_webp", "text/xml", true, 0}, + {":/image_webp", "application/xml", false, 0}, + {":/image_webp", "application/xml", true, 0}, + {":/image_webp", "text/html", false, 0}, + {":/image_webp", "text/html", true, "image/webp"}, + {":/image_webp", "text/xml", false, 0}, + {":/image_webp", "text/xml", true, 0}, + {":/image_webp", "application/pdf", false, 0}, + {":/image_webp", "application/pdf", true, "image/webp"}, + {":/image_webp", "application/postscript", false, 0}, + {":/image_webp", "application/postscript", true, "image/webp"}, + {":/image_webp", "application/ogg", false, 0}, + {":/image_webp", "application/ogg", true, "image/webp"}, + {":/image_webp", "video/webm", false, 0}, + {":/image_webp", "video/webm", true, "image/webp"}, + {":/image_webp", "application/x-rar-compressed", false, 0}, + {":/image_webp", "application/x-rar-compressed", true, "image/webp"}, + {":/image_webp", "application/zip", false, 0}, + {":/image_webp", "application/zip", true, "image/webp"}, + {":/image_webp", "application/x-gzip", false, 0}, + {":/image_webp", "application/x-gzip", true, "image/webp"}, + {":/image_webp", "audio/x-wave", false, 0}, + {":/image_webp", "audio/x-wave", true, "image/webp"}, + {":/image_webp", "image/webp", false, 0}, + {":/image_webp", "image/webp", true, "image/webp"}, + {":/image_webp", "image/gif", false, 0}, + {":/image_webp", "image/gif", true, "image/webp"}, + {":/image_webp", "image/png", false, 0}, + {":/image_webp", "image/png", true, "image/webp"}, + {":/image_webp", "image/jpeg", false, 0}, + {":/image_webp", "image/jpeg", true, "image/webp"}, + {":/image_webp", "image/bmp", false, 0}, + {":/image_webp", "image/bmp", true, "image/webp"}, + {":/image_webp", "image/vnd.microsoft.icon", false, 0}, + {":/image_webp", "image/vnd.microsoft.icon", true, "image/webp"}, + {":/image_webp", "application/rdf+xml", false, 0}, + {":/image_webp", "application/rdf+xml", true, 0}, + {":/image_webp", "application/rss+xml", false, 0}, + {":/image_webp", "application/rss+xml", true, 0}, + {":/image_webp", "application/atom+xml", false, 0}, + {":/image_webp", "application/atom+xml", true, 0}, + {":/text_html", "text/plain", false, "text/plain"}, + {":/text_html", "text/plain", true, "text/plain"}, + {":/text_html", "unknown/unknown", false, "text/html"}, + {":/text_html", "unknown/unknown", true, "text/html"}, + {":/text_html", "application/unknown", false, "text/html"}, + {":/text_html", "application/unknown", true, "text/html"}, + {":/text_html", "*/*", false, "text/html"}, + {":/text_html", "*/*", true, "text/html"}, + {":/text_html", "text/xml", false, 0}, + {":/text_html", "text/xml", true, 0}, + {":/text_html", "application/xml", false, 0}, + {":/text_html", "application/xml", true, 0}, + {":/text_html", "text/html", false, 0}, + {":/text_html", "text/html", true, 0}, + {":/text_html", "text/xml", false, 0}, + {":/text_html", "text/xml", true, 0}, + {":/text_html", "application/pdf", false, 0}, + {":/text_html", "application/pdf", true, 0}, + {":/text_html", "application/postscript", false, 0}, + {":/text_html", "application/postscript", true, 0}, + {":/text_html", "application/ogg", false, 0}, + {":/text_html", "application/ogg", true, 0}, + {":/text_html", "video/webm", false, 0}, + {":/text_html", "video/webm", true, 0}, + {":/text_html", "application/x-rar-compressed", false, 0}, + {":/text_html", "application/x-rar-compressed", true, 0}, + {":/text_html", "application/zip", false, 0}, + {":/text_html", "application/zip", true, 0}, + {":/text_html", "application/x-gzip", false, 0}, + {":/text_html", "application/x-gzip", true, 0}, + {":/text_html", "audio/x-wave", false, 0}, + {":/text_html", "audio/x-wave", true, 0}, + {":/text_html", "image/webp", false, 0}, + {":/text_html", "image/webp", true, 0}, + {":/text_html", "image/gif", false, 0}, + {":/text_html", "image/gif", true, 0}, + {":/text_html", "image/png", false, 0}, + {":/text_html", "image/png", true, 0}, + {":/text_html", "image/jpeg", false, 0}, + {":/text_html", "image/jpeg", true, 0}, + {":/text_html", "image/bmp", false, 0}, + {":/text_html", "image/bmp", true, 0}, + {":/text_html", "image/vnd.microsoft.icon", false, 0}, + {":/text_html", "image/vnd.microsoft.icon", true, 0}, + {":/text_html", "application/rdf+xml", false, 0}, + {":/text_html", "application/rdf+xml", true, 0}, + {":/text_html", "application/rss+xml", false, 0}, + {":/text_html", "application/rss+xml", true, 0}, + {":/text_html", "application/atom+xml", false, 0}, + {":/text_html", "application/atom+xml", true, 0}, + {":/text_xml", "text/plain", false, "text/plain"}, + {":/text_xml", "text/plain", true, "text/plain"}, + {":/text_xml", "unknown/unknown", false, "text/xml"}, + {":/text_xml", "unknown/unknown", true, "text/xml"}, + {":/text_xml", "application/unknown", false, "text/xml"}, + {":/text_xml", "application/unknown", true, "text/xml"}, + {":/text_xml", "*/*", false, "text/xml"}, + {":/text_xml", "*/*", true, "text/xml"}, + {":/text_xml", "text/xml", false, 0}, + {":/text_xml", "text/xml", true, 0}, + {":/text_xml", "application/xml", false, 0}, + {":/text_xml", "application/xml", true, 0}, + {":/text_xml", "text/html", false, 0}, + {":/text_xml", "text/html", true, 0}, + {":/text_xml", "text/xml", false, 0}, + {":/text_xml", "text/xml", true, 0}, + {":/text_xml", "application/pdf", false, 0}, + {":/text_xml", "application/pdf", true, 0}, + {":/text_xml", "application/postscript", false, 0}, + {":/text_xml", "application/postscript", true, 0}, + {":/text_xml", "application/ogg", false, 0}, + {":/text_xml", "application/ogg", true, 0}, + {":/text_xml", "video/webm", false, 0}, + {":/text_xml", "video/webm", true, 0}, + {":/text_xml", "application/x-rar-compressed", false, 0}, + {":/text_xml", "application/x-rar-compressed", true, 0}, + {":/text_xml", "application/zip", false, 0}, + {":/text_xml", "application/zip", true, 0}, + {":/text_xml", "application/x-gzip", false, 0}, + {":/text_xml", "application/x-gzip", true, 0}, + {":/text_xml", "audio/x-wave", false, 0}, + {":/text_xml", "audio/x-wave", true, 0}, + {":/text_xml", "image/webp", false, 0}, + {":/text_xml", "image/webp", true, 0}, + {":/text_xml", "image/gif", false, 0}, + {":/text_xml", "image/gif", true, 0}, + {":/text_xml", "image/png", false, 0}, + {":/text_xml", "image/png", true, 0}, + {":/text_xml", "image/jpeg", false, 0}, + {":/text_xml", "image/jpeg", true, 0}, + {":/text_xml", "image/bmp", false, 0}, + {":/text_xml", "image/bmp", true, 0}, + {":/text_xml", "image/vnd.microsoft.icon", false, 0}, + {":/text_xml", "image/vnd.microsoft.icon", true, 0}, + {":/text_xml", "application/rdf+xml", false, 0}, + {":/text_xml", "application/rdf+xml", true, 0}, + {":/text_xml", "application/rss+xml", false, 0}, + {":/text_xml", "application/rss+xml", true, 0}, + {":/text_xml", "application/atom+xml", false, 0}, + {":/text_xml", "application/atom+xml", true, 0}, + {":/video_webm", "text/plain", false, "video/webm"}, + {":/video_webm", "text/plain", true, "video/webm"}, + {":/video_webm", "unknown/unknown", false, "video/webm"}, + {":/video_webm", "unknown/unknown", true, "video/webm"}, + {":/video_webm", "application/unknown", false, "video/webm"}, + {":/video_webm", "application/unknown", true, "video/webm"}, + {":/video_webm", "*/*", false, "video/webm"}, + {":/video_webm", "*/*", true, "video/webm"}, + {":/video_webm", "text/xml", false, 0}, + {":/video_webm", "text/xml", true, 0}, + {":/video_webm", "application/xml", false, 0}, + {":/video_webm", "application/xml", true, 0}, + {":/video_webm", "text/html", false, 0}, + {":/video_webm", "text/html", true, 0}, + {":/video_webm", "text/xml", false, 0}, + {":/video_webm", "text/xml", true, 0}, + {":/video_webm", "application/pdf", false, 0}, + {":/video_webm", "application/pdf", true, 0}, + {":/video_webm", "application/postscript", false, 0}, + {":/video_webm", "application/postscript", true, 0}, + {":/video_webm", "application/ogg", false, 0}, + {":/video_webm", "application/ogg", true, 0}, + {":/video_webm", "video/webm", false, 0}, + {":/video_webm", "video/webm", true, 0}, + {":/video_webm", "application/x-rar-compressed", false, 0}, + {":/video_webm", "application/x-rar-compressed", true, 0}, + {":/video_webm", "application/zip", false, 0}, + {":/video_webm", "application/zip", true, 0}, + {":/video_webm", "application/x-gzip", false, 0}, + {":/video_webm", "application/x-gzip", true, 0}, + {":/video_webm", "audio/x-wave", false, 0}, + {":/video_webm", "audio/x-wave", true, 0}, + {":/video_webm", "image/webp", false, 0}, + {":/video_webm", "image/webp", true, 0}, + {":/video_webm", "image/gif", false, 0}, + {":/video_webm", "image/gif", true, 0}, + {":/video_webm", "image/png", false, 0}, + {":/video_webm", "image/png", true, 0}, + {":/video_webm", "image/jpeg", false, 0}, + {":/video_webm", "image/jpeg", true, 0}, + {":/video_webm", "image/bmp", false, 0}, + {":/video_webm", "image/bmp", true, 0}, + {":/video_webm", "image/vnd.microsoft.icon", false, 0}, + {":/video_webm", "image/vnd.microsoft.icon", true, 0}, + {":/video_webm", "application/rdf+xml", false, 0}, + {":/video_webm", "application/rdf+xml", true, 0}, + {":/video_webm", "application/rss+xml", false, 0}, + {":/video_webm", "application/rss+xml", true, 0}, + {":/video_webm", "application/atom+xml", false, 0}, + {":/video_webm", "application/atom+xml", true, 0} +}; +static const size_t testListSize = sizeof(testList) / sizeof(testList[0]); + +#endif // TestData_h diff --git a/tests/webkitwidgets/MIMESniffing/resources.qrc b/tests/webkitwidgets/MIMESniffing/resources.qrc new file mode 100644 index 000000000..b4afb321e --- /dev/null +++ b/tests/webkitwidgets/MIMESniffing/resources.qrc @@ -0,0 +1,23 @@ + + + resources/application_atom+xml + resources/application_ogg + resources/application_pdf + resources/application_postscript + resources/application_rdf+xml + resources/application_rss+xml + resources/application_x-gzip + resources/application_x-rar-compressed + resources/application_zip + resources/audio_x-wave + resources/image_bmp + resources/image_gif + resources/image_jpeg + resources/image_png + resources/image_vnd.microsoft.icon + resources/image_webp + resources/text_html + resources/text_xml + resources/video_webm + + diff --git a/tests/webkitwidgets/MIMESniffing/resources/application_atom+xml b/tests/webkitwidgets/MIMESniffing/resources/application_atom+xml new file mode 100644 index 000000000..54086a7be --- /dev/null +++ b/tests/webkitwidgets/MIMESniffing/resources/application_atom+xml @@ -0,0 +1,17 @@ + + + Example Feed + + 2003-12-13T18:30:02Z + + John Doe + + urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 + + Atom-Powered Robots Run Amok + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + 2003-12-13T18:30:02Z + Some text. + + diff --git a/tests/webkitwidgets/MIMESniffing/resources/application_ogg b/tests/webkitwidgets/MIMESniffing/resources/application_ogg new file mode 100644 index 000000000..b9cc1b291 Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/application_ogg differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/application_pdf b/tests/webkitwidgets/MIMESniffing/resources/application_pdf new file mode 100644 index 000000000..7f8996f6a Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/application_pdf differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/application_postscript b/tests/webkitwidgets/MIMESniffing/resources/application_postscript new file mode 100644 index 000000000..c4b9ae6cb --- /dev/null +++ b/tests/webkitwidgets/MIMESniffing/resources/application_postscript @@ -0,0 +1,137 @@ +%!PS-Adobe-2.0 EPSF-1.2 +%%Creator: HiJaak 2.1 +%%CreationDate: 12/29/93 13:52:08 +%%BoundingBox:126 216 486 576 +%%EndComments +/ld {load def} bind def +/s /stroke ld /f /fill ld /m /moveto ld /l /lineto ld /c /curveto ld /rgb {255 div 3 1 roll 255 div 3 1 roll 255 div 3 1 roll setrgbcolor} def +126 216 translate +360.0000 360.0000 scale +/picstr 124 string def +124 124 8 [124 0 0 -124 0 124] {currentfile picstr readhexstring pop} image +65656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565ADADADADADADADADADADADADADADADADADADADADADADADADADADADADADADAD1B1B1B1B1B1B1B1B1B1BFF +65656565656565656565656565656565656565656565656565656565656565006565656565006565656500656565656565000000656565656565656565656565656565656565656565656565656565656565ADADAD00ADADAD000000ADAD00ADADADADAD00AD00ADADADAD00ADADADAD00000000001B1B001B1B1BFF +65656565656565656565656565656565656565656565656565656565656565000065656500006565650065006565656500656565006565656565656565656565656565656565656565656565656565656565ADADAD00ADAD00ADADAD00ADAD00ADADAD00ADAD0000ADADAD00ADADADAD001B1B1B1B001B001B1B1BFF +65656565656565656565656565656565656565656565656565656565656565000065656500006565650065006565650065656565650065656565656565656565656565656565656565656565656565656565ADADAD00AD00ADADADADADADAD00ADADAD00ADAD00AD00ADAD00ADADADAD001B1B1B1B001B001B1B1BFF +65656565656565656565656565656565656565656565656565656565656565006500650065006565650065006565650065656565656565656565656565656565656565656565656565656565656565656565ADADAD00AD00ADADADADADADADAD00AD00ADADAD00AD00ADAD00ADADADAD00000000001B1B001B1B1BFF +65656565656565656565656565656565656565656565656565656565656565006500650065006565006565650065650065656500000065656565656565656565656565656565656565656565656565656565ADADAD00AD00ADADADADADADADADAD00ADADADAD00ADAD00AD00ADADADAD001B1B1B1B001B001B1B1BFF +65656565656565656565656565656565656565656565656565656565656565006500650065006565000000000065650065656565650065656565656565656565656565656565656565656565656565656565ADADAD00AD00ADADADADADADADADAD00ADADADAD00ADAD00AD00ADADADAD001B1B1B1B001B001B1B1BFF +65656565656565656565656565656565656565656565656565656565656565006565006565006500656565656500656500656565006565656565656565656565656565656565656565656565656565656565ADADAD00ADAD00ADADAD00ADADADAD00ADADADAD00ADADAD0000ADADADAD001B1B1B1B001B001B1B1BFF +65656565656565656565656565656565656565656565656565656565656565006565006565006500656565656500656565000000656565656565656565656565656565656565656565656565656565656565ADADAD00ADADAD000000ADADADADAD00ADADADAD00ADADADAD00ADADADAD00000000001B1B00000000FF +65656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565ADADAD00ADADADADADADADADADADADADADADADADADADADADADADADADADADAD1B1B1B1B1B1B1B1B1B1BFF +65656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565ADADAD00ADADADADADADADADADADADADADADADADADADADADADADADADADADAD1B1B1B1B1B1B1B1B1B1BFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDC0000DC0000000000DC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292000000009292000000000092920000929200009292929292ADADADAD00000000ADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDC0000DC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929200009292000092000092920000920000929200009292929292ADADAD0000ADAD0000ADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC00DCDC00DCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292920000929292929292000092920000920000009200009292929292ADAD0000ADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC00000000DCDC0000000000DC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292920000929292929292000092920000920000009200009292929292ADAD0000ADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292920000929200000092000000000092920000920000009292929292ADAD0000ADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292920000929292000092000092000092920000920000009292929292ADAD0000ADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929200009292000092000092920000920000929200009292929292ADADAD0000ADAD0000ADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC0000DCDCDC0000000000DC000000000000DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292000000009292000092929200000000929200009292929292ADADADAD00000000ADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC92929292929292929292929292929292929292929292929292929292929292ADADADADADADADADADADFF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00000000004A4A00000000004A00000000004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDC0000DCDC0000DC0000000000DC0000DCDCDCDCDCDCDCDCDCDCDC00000065656500000065FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A4A00004A00004A4A4A4A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDC0000DCDC0000DC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDC00000065656500000065FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A4A00004A00004A4A4A4A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDC00DCDC00DCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDC00000000650000000065FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A4A00004A00000000004A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDC00000000DCDC0000000000DC0000DCDCDCDCDCDCDCDCDCDCDC00000000650000000065FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00000000004A4A00004A4A4A4A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDC00006500650065000065FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A00004A4A00004A4A4A4A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDC00006500000065000065FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A4A00004A00004A4A4A4A00004A4A00004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDC0000DCDCDC0000DCDCDCDC0000DCDCDCDCDCDCDCDCDCDCDC00006500000065000065FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A00004A4A4A000000000000004A00000000004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDC0000DCDCDC0000000000DC000000000000DCDCDCDCDCDCDC00006565006565000065FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A00000000004A4A4A4A0000004A4A4A00000000004A4A4A4A004A4A4A4A4A00000000004A00000000004A00000000004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A004A4A4A4A004A4A004A4A4A004A4A4A4A004A4A4A4A4A4A004A4A4A4A4A004A4A4A4A4A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A004A4A4A4A004A004A4A4A4A4A004A4A4A004A4A4A4A4A4A004A4A4A4A4A004A4A4A4A4A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A00000000004A4A004A4A4A4A4A004A4A4A004A4A4A4A4A4A004A4A4A4A4A00000000004A000000004A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A004A4A4A4A004A004A4A4A4A4A004A4A4A004A4A4A4A4A4A004A4A4A4A4A004A4A4A4A4A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A004A4A4A4A004A004A4A4A4A4A004A4A4A004A4A4A4A4A4A004A4A4A4A4A004A4A4A4A4A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A004A4A4A4A004A4A004A4A4A004A4A4A4A004A4A4A4A4A4A004A4A4A4A4A004A4A4A4A4A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A00000000004A4A4A4A0000004A4A4A4A4A004A4A4A4A4A4A00000000004A00000000004A004A4A4A4A4A4A4A004A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4ADCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC65656565656565656565FF +showpage + \ No newline at end of file diff --git a/tests/webkitwidgets/MIMESniffing/resources/application_rdf+xml b/tests/webkitwidgets/MIMESniffing/resources/application_rdf+xml new file mode 100644 index 000000000..e21414543 --- /dev/null +++ b/tests/webkitwidgets/MIMESniffing/resources/application_rdf+xml @@ -0,0 +1,50 @@ + + + + + + XML.com + http://xml.com/pub + + XML.com features a rich mix of information and services + for the XML community. + + + + + + + + + + + + + + + XML.com + http://www.xml.com + http://xml.com/universal/images/xml_tiny.gif + + + + Processing Inclusions with XSLT + http://xml.com/pub/2000/08/09/xslt/xslt.html + + Processing document inclusions with general XML tools can be + problematic. This article proposes a way of preserving inclusion + information through SAX-based processing. + + + + + Putting RDF to Work + http://xml.com/pub/2000/08/09/rdfdb/index.html + + Tool and API support for the Resource Description Framework + is slowly coming of age. Edd Dumbill takes a look at RDFDB, + one of the most exciting new RDF toolkits. + + + + diff --git a/tests/webkitwidgets/MIMESniffing/resources/application_rss+xml b/tests/webkitwidgets/MIMESniffing/resources/application_rss+xml new file mode 100644 index 000000000..3537c41c5 --- /dev/null +++ b/tests/webkitwidgets/MIMESniffing/resources/application_rss+xml @@ -0,0 +1,45 @@ + + + + +Folha.com - Ambiente - Principal +http://redir.folha.com.br/redir/online/ambiente/rss091/*http://www1.folha.uol.com.br/ambiente/ +Primeiro jornal em tempo real em língua portuguesa +pt-br +Copyright Folha.com. Todos os direitos reservados. +http://redir.folha.com.br/redir/online/ambiente/rss091/*http://www1.folha.uol.com.br/folha/conheca/arquivo_e_copyright.shtml +webmaster@grupofolha.com.br (Webmaster Folha.com) + + +Folha.com - Ambiente - Principal +http://www1.folha.uol.com.br/folha/images/lgo-folha_com-88x31.gif +http://redir.folha.com.br/redir/online/ambiente/rss091/*http://www1.folha.uol.com.br/ambiente/ +88 +31 +Primeiro jornal em tempo real em língua portuguesa + + + +Nasa dimensiona danos da seca na Amazônia em 2,4 mi de km2 +http://redir.folha.com.br/redir/online/ambiente/rss091/*http://www1.folha.uol.com.br/ambiente/895526-nasa-dimensiona-danos-da-seca-na-amazonia-em-24-mi-de-km2.shtml + +Os satélites da Nasa (agência espacial americana) forneceram material para uma análise dos estragos provocados pela <a href="http://www1.folha.uol.com.br/ambiente/870588-amazonia-teve-a-pior-seca-dos-ultimos-cem-anos.shtml">pior seca a atingir a Amazônia em 2010</a>. +Pela tomada aérea, estima-se que foram 2,5 milhões de quilômetros quadrados afetados --pouco menos da metade do ecossistema amazônico. +<table class="articleGraphic"> +<tr> +<td rowspan="3" class="articleGraphicSpace"></td> +<td class="articleGraphicCredit">Universidade de Boston/Nasa</td> +<td rowspan="3" class="articleGraphicSpace"></td> +</tr> +<tr> +<td class="articleGraphicImage"><img src="http://f.i.uol.com.br/folha/ambiente/images/11090120.jpeg" alt="Área (vermelho) mostra redução do índice do verdor, onde a vegetação ficou menos verde e mais seca" border="0" /></td> +</tr> +<tr> +<td class="articleGraphicCaption">Área (vermelho) mostra redução do índice do verdor, onde a vegetação ficou menos verde e mais seca</td> +</tr> +</table> +<a href="http://redir.folha.com.br/redir/online/ambiente/rss091/*http://www1.folha.uol.com.br/ambiente/895526-nasa-dimensiona-danos-da-seca-na-amazonia-em-24-mi-de-km2.shtml">Leia mais</a> (29/03/2011 - 18h04) +29 Mar 2011 18:04:00 -0300 + + + diff --git a/tests/webkitwidgets/MIMESniffing/resources/application_x-gzip b/tests/webkitwidgets/MIMESniffing/resources/application_x-gzip new file mode 100644 index 000000000..a5e7d3131 Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/application_x-gzip differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/application_x-rar-compressed b/tests/webkitwidgets/MIMESniffing/resources/application_x-rar-compressed new file mode 100644 index 000000000..d9cb6ae25 Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/application_x-rar-compressed differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/application_zip b/tests/webkitwidgets/MIMESniffing/resources/application_zip new file mode 100644 index 000000000..8aec52fb2 Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/application_zip differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/audio_x-wave b/tests/webkitwidgets/MIMESniffing/resources/audio_x-wave new file mode 100644 index 000000000..a0f9b85ff Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/audio_x-wave differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/image_bmp b/tests/webkitwidgets/MIMESniffing/resources/image_bmp new file mode 100644 index 000000000..b61d3688f Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/image_bmp differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/image_gif b/tests/webkitwidgets/MIMESniffing/resources/image_gif new file mode 100644 index 000000000..32b1ea23f Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/image_gif differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/image_jpeg b/tests/webkitwidgets/MIMESniffing/resources/image_jpeg new file mode 100644 index 000000000..187457663 Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/image_jpeg differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/image_png b/tests/webkitwidgets/MIMESniffing/resources/image_png new file mode 100644 index 000000000..bef59c785 Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/image_png differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/image_vnd.microsoft.icon b/tests/webkitwidgets/MIMESniffing/resources/image_vnd.microsoft.icon new file mode 100644 index 000000000..58921b8bb Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/image_vnd.microsoft.icon differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/image_webp b/tests/webkitwidgets/MIMESniffing/resources/image_webp new file mode 100644 index 000000000..0da983e2c Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/image_webp differ diff --git a/tests/webkitwidgets/MIMESniffing/resources/text_html b/tests/webkitwidgets/MIMESniffing/resources/text_html new file mode 100644 index 000000000..21eeee345 --- /dev/null +++ b/tests/webkitwidgets/MIMESniffing/resources/text_html @@ -0,0 +1,3 @@ + + +

It works!

\ No newline at end of file diff --git a/tests/webkitwidgets/MIMESniffing/resources/text_xml b/tests/webkitwidgets/MIMESniffing/resources/text_xml new file mode 100644 index 000000000..38a9fe548 --- /dev/null +++ b/tests/webkitwidgets/MIMESniffing/resources/text_xml @@ -0,0 +1,19 @@ + + + + Empire Burlesque + Bob Dylan + USA + Columbia + 10.90 + 1985 + + + Unchain my heart + Joe Cocker + USA + EMI + 8.20 + 1987 + + diff --git a/tests/webkitwidgets/MIMESniffing/resources/video_webm b/tests/webkitwidgets/MIMESniffing/resources/video_webm new file mode 100644 index 000000000..95d5031a8 Binary files /dev/null and b/tests/webkitwidgets/MIMESniffing/resources/video_webm differ diff --git a/tests/webkitwidgets/MIMESniffing/tst_MIMESniffing.cpp b/tests/webkitwidgets/MIMESniffing/tst_MIMESniffing.cpp new file mode 100644 index 000000000..8c5417f26 --- /dev/null +++ b/tests/webkitwidgets/MIMESniffing/tst_MIMESniffing.cpp @@ -0,0 +1,72 @@ +/* + Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "MIMESniffing.h" + +#include "TestData.h" + +#include +#include +#include + +class tst_MIMESniffing : public QObject { + Q_OBJECT + +public: + tst_MIMESniffing(); + +private Q_SLOTS: + void testCase1(); +}; + +tst_MIMESniffing::tst_MIMESniffing() +{ +} + +static inline const char* errorText(const TestData& data, const char* sniffedType) +{ + return QString("file: %1, advertised: %2, image: %3. sniffed mime type was expected to be \"%4\" but instead was \"%5\"").arg(data.file).arg(data.advertisedType).arg(data.isImage).arg(data.sniffedType).arg(sniffedType).toLatin1(); +} + +void tst_MIMESniffing::testCase1() +{ + + for (int i = 0; i < testListSize; ++i) { + QFile file(testList[i].file); + QVERIFY2(file.open(QIODevice::ReadOnly), QString("unable to open file %1").arg(file.fileName()).toLatin1()); + + MIMESniffer sniffer(testList[i].advertisedType, testList[i].isImage); + QByteArray data = file.peek(sniffer.dataSize()); + + const char* sniffedType = sniffer.sniff(data.constData(), data.size()); + + QVERIFY2(!(sniffedType || testList[i].sniffedType) || (sniffedType && testList[i].sniffedType), errorText(testList[i], sniffedType)); + + if (sniffedType) + QVERIFY2(!strcmp(sniffedType, testList[i].sniffedType), errorText(testList[i], sniffedType)); + + } + + QVERIFY2(true, "Failure"); +} + +QTEST_APPLESS_MAIN(tst_MIMESniffing); + +#include "tst_MIMESniffing.moc" diff --git a/tests/webkitwidgets/benchmarks/loading/loading.pro b/tests/webkitwidgets/benchmarks/loading/loading.pro new file mode 100644 index 000000000..2677a2200 --- /dev/null +++ b/tests/webkitwidgets/benchmarks/loading/loading.pro @@ -0,0 +1,2 @@ +include(../../tests.pri) +exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/webkitwidgets/benchmarks/loading/tst_loading.cpp b/tests/webkitwidgets/benchmarks/loading/tst_loading.cpp new file mode 100644 index 000000000..c67f422c0 --- /dev/null +++ b/tests/webkitwidgets/benchmarks/loading/tst_loading.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2009 Holger Hans Peter Freyther + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QT_NO_BEARERMANAGEMENT +#include +#endif + +#include + +#include +#include +#include + +#include "util.h" + +class tst_Loading : public QObject +{ + Q_OBJECT + +public: + +public Q_SLOTS: + void init(); + void cleanup(); + +private Q_SLOTS: + void load_data(); + void load(); + +private: +#ifndef QT_NO_BEARERMANAGEMENT + QNetworkConfigurationManager m_manager; +#endif + QWebView* m_view; + QWebPage* m_page; +}; + +void tst_Loading::init() +{ + m_view = new QWebView; + m_page = m_view->page(); + + QSize viewportSize(1024, 768); + m_view->setFixedSize(viewportSize); + m_page->setViewportSize(viewportSize); +} + +void tst_Loading::cleanup() +{ + delete m_view; +} + +void tst_Loading::load_data() +{ + QTest::addColumn("url"); + QTest::newRow("amazon") << QUrl("http://www.amazon.com"); + QTest::newRow("kde") << QUrl("http://www.kde.org"); + QTest::newRow("apple") << QUrl("http://www.apple.com"); +} + +void tst_Loading::load() +{ + QFETCH(QUrl, url); + +#ifndef QT_NO_BEARERMANAGEMENT + if (!m_manager.isOnline()) + QSKIP("This test requires an active network connection", SkipSingle); +#endif + + QBENCHMARK { + m_view->load(url); + + // really wait for loading, painting is in another test + ::waitForSignal(m_view, SIGNAL(loadFinished(bool)), 0); + } +} + +QTEST_MAIN(tst_Loading) +#include "tst_loading.moc" diff --git a/tests/webkitwidgets/benchmarks/painting/painting.pro b/tests/webkitwidgets/benchmarks/painting/painting.pro new file mode 100644 index 000000000..2677a2200 --- /dev/null +++ b/tests/webkitwidgets/benchmarks/painting/painting.pro @@ -0,0 +1,2 @@ +include(../../tests.pri) +exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/webkitwidgets/benchmarks/painting/tst_painting.cpp b/tests/webkitwidgets/benchmarks/painting/tst_painting.cpp new file mode 100644 index 000000000..f1456f9e3 --- /dev/null +++ b/tests/webkitwidgets/benchmarks/painting/tst_painting.cpp @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2009 Holger Hans Peter Freyther + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QT_NO_BEARERMANAGEMENT +#include +#endif + +#include + +#include +#include +#include +#include + +#include "util.h" + +class tst_Painting : public QObject +{ + Q_OBJECT + +public: + +public Q_SLOTS: + void init(); + void cleanup(); + +private Q_SLOTS: + void paint_data(); + void paint(); + void textAreas(); + +private: +#ifndef QT_NO_BEARERMANAGEMENT + QNetworkConfigurationManager m_manager; +#endif + QWebView* m_view; + QWebPage* m_page; +}; + +void tst_Painting::init() +{ + m_view = new QWebView; + m_page = m_view->page(); + + QSize viewportSize(1024, 768); + m_view->setFixedSize(viewportSize); + m_page->setViewportSize(viewportSize); +} + +void tst_Painting::cleanup() +{ + delete m_view; +} + +void tst_Painting::paint_data() +{ + QTest::addColumn("url"); + QTest::newRow("amazon") << QUrl("http://www.amazon.com"); +} + +void tst_Painting::paint() +{ + QFETCH(QUrl, url); + +#ifndef QT_NO_BEARERMANAGEMENT + if (!m_manager.isOnline()) + QSKIP("This test requires an active network connection", SkipSingle); +#endif + + m_view->load(url); + ::waitForSignal(m_view, SIGNAL(loadFinished(bool)), 0); + + /* force a layout */ + QWebFrame* mainFrame = m_page->mainFrame(); + mainFrame->toPlainText(); + + QPixmap pixmap(m_page->viewportSize()); + QBENCHMARK { + QPainter painter(&pixmap); + mainFrame->render(&painter, QRect(QPoint(0, 0), m_page->viewportSize())); + painter.end(); + } +} + +void tst_Painting::textAreas() +{ + m_view->load(QUrl("data:text/html;")); + ::waitForSignal(m_view, SIGNAL(loadFinished(bool)), 0); + + QWebElement bodyElement = m_page->mainFrame()->findFirstElement("body"); + + int count = 100; + while (count--) { + QString markup(""); + bodyElement.appendInside(markup); + } + + /* force a layout */ + QWebFrame* mainFrame = m_page->mainFrame(); + mainFrame->toPlainText(); + + QPixmap pixmap(mainFrame->contentsSize()); + QBENCHMARK { + QPainter painter(&pixmap); + mainFrame->render(&painter, QRect(QPoint(0, 0), mainFrame->contentsSize())); + painter.end(); + } +} + +QTEST_MAIN(tst_Painting) +#include "tst_painting.moc" diff --git a/tests/webkitwidgets/benchmarks/webgl/10000_triangles.html b/tests/webkitwidgets/benchmarks/webgl/10000_triangles.html new file mode 100644 index 000000000..fd061aa27 --- /dev/null +++ b/tests/webkitwidgets/benchmarks/webgl/10000_triangles.html @@ -0,0 +1,59 @@ + + + + + + diff --git a/tests/webkitwidgets/benchmarks/webgl/tst_webgl.cpp b/tests/webkitwidgets/benchmarks/webgl/tst_webgl.cpp new file mode 100644 index 000000000..14ff1a80f --- /dev/null +++ b/tests/webkitwidgets/benchmarks/webgl/tst_webgl.cpp @@ -0,0 +1,130 @@ +/* + Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#include "../../util.h" +#include +#include +#include +#include +#include +#include + +class GraphicsView; + +class tst_WebGlPerformance : public QObject { + Q_OBJECT + +private Q_SLOTS: + void init(); + void cleanup(); + + void benchSoftwareFallbackRgb16(); + void benchSoftwareFallbackRgb32(); + void benchSoftwareFallbackArgb32(); + void benchSoftwareFallbackArgb32Premultiplied(); + +private: + void benchmarkFrameRenderingOnImage(QImage::Format); + + QScopedPointer m_view; +}; + +class GraphicsView : public QGraphicsView { +public: + GraphicsView(); + QGraphicsWebView* m_webView; + +protected: + void resizeEvent(QResizeEvent*); +}; + +GraphicsView::GraphicsView() +{ + QGraphicsScene* const scene = new QGraphicsScene(this); + setScene(scene); + + m_webView = new QGraphicsWebView; + scene->addItem(m_webView); + + m_webView->page()->settings()->setAttribute(QWebSettings::WebGLEnabled, true); + + resize(800, 600); + setFrameShape(QFrame::NoFrame); + setViewport(new QGLWidget); +} + +void GraphicsView::resizeEvent(QResizeEvent* event) +{ + QGraphicsView::resizeEvent(event); + QRectF rect(QPoint(0, 0), event->size()); + m_webView->setGeometry(rect); + scene()->setSceneRect(rect); +} + +void tst_WebGlPerformance::init() +{ + m_view.reset(new GraphicsView); + m_view->showMaximized(); + QTest::qWaitForWindowShown(m_view.data()); +} + +void tst_WebGlPerformance::cleanup() +{ + m_view.reset(); +} + +void tst_WebGlPerformance::benchSoftwareFallbackRgb16() +{ + benchmarkFrameRenderingOnImage(QImage::Format_RGB16); +} + +void tst_WebGlPerformance::benchSoftwareFallbackRgb32() +{ + benchmarkFrameRenderingOnImage(QImage::Format_RGB32); +} + +void tst_WebGlPerformance::benchSoftwareFallbackArgb32() +{ + benchmarkFrameRenderingOnImage(QImage::Format_ARGB32); +} + +void tst_WebGlPerformance::benchSoftwareFallbackArgb32Premultiplied() +{ + benchmarkFrameRenderingOnImage(QImage::Format_ARGB32_Premultiplied); +} + +void tst_WebGlPerformance::benchmarkFrameRenderingOnImage(QImage::Format format) +{ + m_view->m_webView->load(QUrl(QLatin1String("qrc:///testcases/10000_triangles.html"))); + const bool pageLoaded = waitForSignal(m_view->m_webView, SIGNAL(loadFinished(bool))); + Q_ASSERT(pageLoaded); + Q_UNUSED(pageLoaded); + + QImage target(m_view->size(), format); + QBENCHMARK { + QPainter painter(&target); + m_view->render(&painter); + painter.end(); + } +} + +QTEST_MAIN(tst_WebGlPerformance) + +#include "tst_webgl.moc" diff --git a/tests/webkitwidgets/benchmarks/webgl/tst_webgl.qrc b/tests/webkitwidgets/benchmarks/webgl/tst_webgl.qrc new file mode 100644 index 000000000..b849448d7 --- /dev/null +++ b/tests/webkitwidgets/benchmarks/webgl/tst_webgl.qrc @@ -0,0 +1,5 @@ + + + 10000_triangles.html + + diff --git a/tests/webkitwidgets/benchmarks/webgl/webgl.pro b/tests/webkitwidgets/benchmarks/webgl/webgl.pro new file mode 100644 index 000000000..a471269bd --- /dev/null +++ b/tests/webkitwidgets/benchmarks/webgl/webgl.pro @@ -0,0 +1,3 @@ +include(../../tests.pri) +exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc +QT += opengl diff --git a/tests/webkitwidgets/cmake/cmake.pro b/tests/webkitwidgets/cmake/cmake.pro new file mode 100644 index 000000000..bf2dbcb77 --- /dev/null +++ b/tests/webkitwidgets/cmake/cmake.pro @@ -0,0 +1,5 @@ + +# Cause make to do nothing. +TEMPLATE = subdirs + +CONFIG += ctest_testcase diff --git a/tests/webkitwidgets/hybridPixmap/hybridPixmap.pro b/tests/webkitwidgets/hybridPixmap/hybridPixmap.pro new file mode 100644 index 000000000..68e565941 --- /dev/null +++ b/tests/webkitwidgets/hybridPixmap/hybridPixmap.pro @@ -0,0 +1,10 @@ +# ------------------------------------------------- +# Project created by QtCreator 2009-12-10T11:25:02 +# ------------------------------------------------- +include(../tests.pri) +TARGET = hybridPixmap +SOURCES += widget.cpp +HEADERS += widget.h +FORMS += widget.ui +RESOURCES += tst_hybridPixmap.qrc +CONFIG += console diff --git a/tests/webkitwidgets/hybridPixmap/test.html b/tests/webkitwidgets/hybridPixmap/test.html new file mode 100644 index 000000000..a6cbed1fb --- /dev/null +++ b/tests/webkitwidgets/hybridPixmap/test.html @@ -0,0 +1,99 @@ + + + + + + + + + + + + diff --git a/tests/webkitwidgets/hybridPixmap/tst_hybridPixmap.cpp b/tests/webkitwidgets/hybridPixmap/tst_hybridPixmap.cpp new file mode 100644 index 000000000..84891580a --- /dev/null +++ b/tests/webkitwidgets/hybridPixmap/tst_hybridPixmap.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "../util.h" + +#include "widget.h" +#include + +class tst_hybridPixmap : public QObject { + Q_OBJECT + +public: + tst_hybridPixmap(QObject* o = 0) : QObject(o) {} + +public Q_SLOTS: + void init() + { + } + + void cleanup() + { + } + +private Q_SLOTS: + void hybridPixmap() + { + Widget widget; + widget.show(); + widget.start(); + waitForSignal(&widget, SIGNAL(testComplete())); + } +}; + +QTEST_MAIN(tst_hybridPixmap) + +#include diff --git a/tests/webkitwidgets/hybridPixmap/tst_hybridPixmap.qrc b/tests/webkitwidgets/hybridPixmap/tst_hybridPixmap.qrc new file mode 100644 index 000000000..5fd47e32d --- /dev/null +++ b/tests/webkitwidgets/hybridPixmap/tst_hybridPixmap.qrc @@ -0,0 +1,5 @@ + + + test.html + + diff --git a/tests/webkitwidgets/hybridPixmap/widget.cpp b/tests/webkitwidgets/hybridPixmap/widget.cpp new file mode 100644 index 000000000..6c4d2cd49 --- /dev/null +++ b/tests/webkitwidgets/hybridPixmap/widget.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "widget.h" + +#include "qwebelement.h" +#include "qwebframe.h" +#include "ui_widget.h" +#include +#include + +Widget::Widget(QWidget* parent) : + QWidget(parent), + ui(new Ui::Widget), + abcFilledImage(32, 32, QImage::Format_ARGB32) +{ + ui->setupUi(this); + abcFilledImage.fill(qRgba(0xaa, 0xbb, 0xcc, 0xff)); +} + +void Widget::refreshJS() +{ + ui->webView->page()->mainFrame()->addToJavaScriptWindowObject("myWidget", this); +} +void Widget::start() +{ + ui->webView->load(QUrl("qrc:///test.html")); + connect(ui->webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(refreshJS())); + ui->webView->page()->mainFrame()->addToJavaScriptWindowObject("myWidget", this); +} + +void Widget::completeTest() +{ + QCOMPARE(ui->lbl1->pixmap()->size(), ui->lbl2->size()); + QCOMPARE(ui->lbl3->size(), ui->lbl4->pixmap()->size()); + QCOMPARE(ui->lbl2->size().width(), ui->webView->page()->mainFrame()->findFirstElement("#img1").evaluateJavaScript("this.width").toInt()); + QCOMPARE(ui->lbl3->size().width(), ui->webView->page()->mainFrame()->findFirstElement("#img2").evaluateJavaScript("this.width").toInt()); + emit testComplete(); +} + +void Widget::setPixmap(const QPixmap& p) +{ + ui->lbl1->setPixmap(p); +} +QPixmap Widget::pixmap() const +{ + QPixmap px(ui->lbl3->size()); + { + QPainter p(&px); + ui->lbl3->render(&p); + } + return px; +} +void Widget::setImage(const QImage& img) +{ + ui->lbl4->setPixmap(QPixmap::fromImage(img)); +} + +QImage Widget::image() const +{ + QImage img(ui->lbl2->size(), QImage::Format_ARGB32); + { + QPainter p(&img); + ui->lbl2->render(&p); + } + return img; +} + +QImage Widget::abcImage(int format) +{ + return abcFilledImage.convertToFormat(static_cast(format)); +} + +Widget::~Widget() +{ + delete ui; +} + +void Widget::changeEvent(QEvent* e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} +void Widget::compare(const QVariant& a, const QVariant& b) +{ + QCOMPARE(a, b); +} + +void Widget::imageSlot(const QImage& img) +{ + QCOMPARE(img.size(), ui->lbl3->size()); + emit pixmapSignal(QPixmap::fromImage(img)); +} + +void Widget::pixmapSlot(const QPixmap& pxm) +{ + QCOMPARE(pxm.size(), ui->lbl2->size()); + emit imageSignal(ui->lbl4->pixmap()->toImage()); +} + +void Widget::randomSlot(const QPixmap& pxm) +{ + QVERIFY(pxm.isNull()); +} diff --git a/tests/webkitwidgets/hybridPixmap/widget.h b/tests/webkitwidgets/hybridPixmap/widget.h new file mode 100644 index 000000000..b78df8b5e --- /dev/null +++ b/tests/webkitwidgets/hybridPixmap/widget.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef widget_h +#define widget_h + +#include +#include +#include +#include "qwebview.h" + +typedef QWebView WebView; + +QT_BEGIN_NAMESPACE +namespace Ui { +class Widget; +} +QT_END_NAMESPACE + +class Widget : public QWidget { + Q_OBJECT + Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) + Q_PROPERTY(QImage image READ image WRITE setImage) + +public: + Widget(QWidget* parent = 0); + ~Widget(); + void setPixmap(const QPixmap&); + QPixmap pixmap() const; + void setImage(const QImage&); + QImage image() const; + +private Q_SLOTS: + void refreshJS(); + +public Q_SLOTS: + void completeTest(); + void start(); + void compare(const QVariant& a, const QVariant& b); + void imageSlot(const QImage&); + void pixmapSlot(const QPixmap&); + void randomSlot(const QPixmap&); + QImage abcImage(int format); + +Q_SIGNALS: + void testComplete(); + void imageSignal(const QImage&); + void pixmapSignal(const QPixmap&); + +protected: + void changeEvent(QEvent* e); + +private: + Ui::Widget* ui; + QImage abcFilledImage; +}; + +#endif // widget_h diff --git a/tests/webkitwidgets/hybridPixmap/widget.ui b/tests/webkitwidgets/hybridPixmap/widget.ui new file mode 100644 index 000000000..272d6a71f --- /dev/null +++ b/tests/webkitwidgets/hybridPixmap/widget.ui @@ -0,0 +1,95 @@ + + + Widget + + + + 0 + 0 + 600 + 400 + + + + Widget + + + + + + + about:blank + + + + + + + + + + + + + + + + + + 120 + 30 + + + + + 120 + 30 + + + + Image from Qt to HTML + + + + + + + Pixmap from Qt to HTML + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + WebView + QWidget +
widget.h
+
+
+ + +
diff --git a/tests/webkitwidgets/keyeddecoderqt/tst_keyeddecoderqt.cpp b/tests/webkitwidgets/keyeddecoderqt/tst_keyeddecoderqt.cpp new file mode 100644 index 000000000..515328028 --- /dev/null +++ b/tests/webkitwidgets/keyeddecoderqt/tst_keyeddecoderqt.cpp @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2016 Konstantin Tokarev + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "KeyedDecoderQt.h" +#include "KeyedEncoderQt.h" + +#include + +using WebCore::KeyedDecoder; +using WebCore::KeyedDecoderQt; + +static QVariantMap testData() +{ + return { + { "string", QStringLiteral("привет") }, + { "array", QVariantList { + QVariantMap { + { "baz", QVariantMap { { "int", 1 } } }, + { "string", "1" }, + }, + QVariantMap { + { "baz", QVariantMap { { "int", 2 } } }, + { "string", "2" }, + }, + QVariantMap { + { "baz", QVariantMap { { "int", 3 } } }, + { "string", "3" }, + }, + } }, + { "foo", QVariantMap { + { "begin", "beginFoo" }, + { "bar", QVariantMap { { "float", 2.5f } } }, + { "end", "endFoo" }, + } }, + { "bool", true }, + { "float", 1.5 }, + { "bytes", QByteArray::fromRawData("\0\0\1\0\0", 5) }, + { "longlong", 1234567890123456789ll } + }; +} + +static std::unique_ptr makeDecoder() +{ + return std::make_unique(testData()); +} + +class tst_KeyedDecoderQt : public QObject { + Q_OBJECT + +private slots: + void stringValue() + { + WTF::String s; + KeyedDecoderQt decoder(testData()); + QVERIFY(decoder.decodeString("string", s)); + QCOMPARE(s, WTF::String::fromUTF8("привет")); + } + + void boolValue() + { + bool b; + KeyedDecoderQt decoder(testData()); + QVERIFY(decoder.decodeBool("bool", b)); + QCOMPARE(b, true); + } + + void floatValue() + { + float f; + KeyedDecoderQt decoder(testData()); + QVERIFY(decoder.decodeFloat("float", f)); + QCOMPARE(f, 1.5f); + } + + void bytesValue() + { + const uint8_t* bytes; + size_t size; + KeyedDecoderQt decoder(testData()); + QVERIFY(decoder.decodeBytes("bytes", bytes, size)); + + const uint8_t expected[] = { 0, 0, 1, 0, 0 }; + QCOMPARE(size, (size_t)5); + QCOMPARE(bytes[0], (uint8_t)0); + QCOMPARE(bytes[1], (uint8_t)0); + QCOMPARE(bytes[2], (uint8_t)1); + QCOMPARE(bytes[3], (uint8_t)0); + QCOMPARE(bytes[4], (uint8_t)0); + } + + void int64Value() + { + int64_t i; + KeyedDecoderQt decoder(testData()); + QVERIFY(decoder.decodeInt64("longlong", i)); + QCOMPARE(i, (int64_t)1234567890123456789ll); + } + + void missingValue() + { + WTF::String s; + KeyedDecoderQt decoder(testData()); + QVERIFY(!decoder.decodeString("foobar", s)); + QCOMPARE(s, WTF::String()); + } + + void wrongType1() + { + float f = 1.0; + KeyedDecoderQt decoder(testData()); + QVERIFY(!decoder.decodeFloat("string", f)); + QCOMPARE(f, 1.0); + } + + void wrongType2() + { + WTF::String s; + KeyedDecoderQt decoder(testData()); + QVERIFY(!decoder.decodeString("array", s)); + QVERIFY(!decoder.decodeString("foo", s)); + } + + void object() + { + struct Foo { + WTF::String begin; + WTF::String end; + float f; + } foo; + + KeyedDecoderQt decoder(testData()); + decoder.decodeObject("foo", foo, [&](KeyedDecoder& d1, Foo& foo) -> bool { + if (!d1.decodeString("begin", foo.begin)) + return false; + if (!d1.decodeString("end", foo.end)) + return false; + return d1.decodeObject("bar", foo, [&](KeyedDecoder& d2, Foo& foo) { + return d2.decodeFloat("float", foo.f); + }); + }); + QCOMPARE(foo.begin, WTF::String("beginFoo")); + QCOMPARE(foo.end, WTF::String("endFoo")); + QCOMPARE(foo.f, 2.5f); + } + + void array() + { + struct Foo { + WTF::String s; + int i; + }; + + WTF::Vector v; + + KeyedDecoderQt decoder(testData()); + decoder.decodeObjects("array", v, [&](KeyedDecoder& d1, Foo& foo) -> bool { + if (!d1.decodeString("string", foo.s)) + return false; + return d1.decodeObject("baz", foo, [&](KeyedDecoder& d2, Foo& foo) { + return d2.decodeInt32("int", foo.i); + }); + }); + QCOMPARE(v.size(), (size_t)3); + QCOMPARE(v[0].s, WTF::String("1")); + QCOMPARE(v[0].i, 1); + QCOMPARE(v[1].s, WTF::String("2")); + QCOMPARE(v[1].i, 2); + QCOMPARE(v[2].s, WTF::String("3")); + QCOMPARE(v[2].i, 3); + } +}; + +QTEST_GUILESS_MAIN(tst_KeyedDecoderQt) +#include "tst_keyeddecoderqt.moc" diff --git a/tests/webkitwidgets/keyedencoderqt/tst_keyedencoderqt.cpp b/tests/webkitwidgets/keyedencoderqt/tst_keyedencoderqt.cpp new file mode 100644 index 000000000..a61c02059 --- /dev/null +++ b/tests/webkitwidgets/keyedencoderqt/tst_keyedencoderqt.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2016 Konstantin Tokarev + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "KeyedEncoderQt.h" + +#include + +using WebCore::KeyedEncoder; +using WebCore::KeyedEncoderQt; + +class tst_KeyedEncoderQt : public QObject { + Q_OBJECT + std::unique_ptr m_encoder { nullptr }; + +private slots: + void init() + { + m_encoder.reset(new KeyedEncoderQt); + } + + void cleanup() + { + m_encoder = nullptr; + } + + void simpleValues() + { + m_encoder->encodeBool("bool", true); + const uint8_t bytes[] = { 0, 0, 1, 0, 0 }; + m_encoder->encodeBytes("bytes", bytes, 5); + m_encoder->encodeString("string", QStringLiteral("привет")); + + auto result = m_encoder->toMap(); + QCOMPARE(result["bool"].type(), QVariant::Bool); + QCOMPARE(result["bool"].toBool(), true); + QCOMPARE(result["bytes"].type(), QVariant::ByteArray); + QCOMPARE(result["bytes"].toByteArray(), QByteArray::fromRawData("\0\0\1\0\0", 5)); + QCOMPARE(result["string"].type(), QVariant::String); + QCOMPARE(result["string"].toString(), QStringLiteral("привет")); + } + + void nestedObjects() + { + struct dummy {}; + + m_encoder->encodeString("begin", "begin"); + m_encoder->encodeObject("foo", dummy(), [](KeyedEncoder& e1, dummy) { + e1.encodeString("begin", "beginFoo"); + e1.encodeObject("bar", dummy(), [](KeyedEncoder& e2, dummy) { + e2.encodeFloat("float", 1.5); + }); + e1.encodeString("end", "endFoo"); + }); + m_encoder->encodeString("end", "end"); + + QVariantMap expected = { + { "begin", "begin" }, + { "foo", QVariantMap { + { "begin", "beginFoo" }, + { "bar", QVariantMap { { "float", 1.5f } } }, + { "end", "endFoo" }, + } }, + { "end", "end" }, + }; + + QCOMPARE(m_encoder->toMap(), expected); + } + + void array() + { + QList values = { 1, 2, 3 }; + + m_encoder->encodeString("begin", "begin"); + m_encoder->encodeObjects("array", values.begin(), values.end(), + [](KeyedEncoder& e, int v) { + e.encodeUInt32("int", v); + e.encodeString("string", QString::number(v)); + }); + m_encoder->encodeString("end", "end"); + + QVariantMap expected = { + { "begin", "begin" }, + { "array", QVariantList { + QVariantMap { { "int", 1 }, { "string", "1" } }, + QVariantMap { { "int", 2 }, { "string", "2" } }, + QVariantMap { { "int", 3 }, { "string", "3" } }, + } }, + { "end", "end" }, + }; + + QCOMPARE(m_encoder->toMap(), expected); + } + + void arrayWithObjects() + { + QList values = { 1, 2, 3 }; + struct dummy {}; + + m_encoder->encodeString("begin", "begin"); + m_encoder->encodeObjects("array", values.begin(), values.end(), + [](KeyedEncoder& e1, int v) { + e1.encodeObject("foo", dummy(), [v](KeyedEncoder& e2, dummy) { + e2.encodeInt32("int", v); + }); + e1.encodeString("string", QString::number(v)); + }); + m_encoder->encodeString("end", "end"); + + QVariantMap expected = { + { "begin", "begin" }, + { "array", QVariantList { + QVariantMap { + { "foo", QVariantMap { { "int", 1 } } }, + { "string", "1" }, + }, + QVariantMap { + { "foo", QVariantMap { { "int", 2 } } }, + { "string", "2" }, + }, + QVariantMap { + { "foo", QVariantMap { { "int", 3 } } }, + { "string", "3" }, + }, + } }, + { "end", "end" }, + }; + + QCOMPARE(m_encoder->toMap(), expected); + } + +}; + +QTEST_GUILESS_MAIN(tst_KeyedEncoderQt) +#include "tst_keyedencoderqt.moc" diff --git a/tests/webkitwidgets/qgraphicswebview/qgraphicswebview.pro b/tests/webkitwidgets/qgraphicswebview/qgraphicswebview.pro new file mode 100644 index 000000000..78e17a06d --- /dev/null +++ b/tests/webkitwidgets/qgraphicswebview/qgraphicswebview.pro @@ -0,0 +1,6 @@ +include(../tests.pri) +exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc + +enable?(WEBGL) { + QT += opengl +} diff --git a/tests/webkitwidgets/qgraphicswebview/resources/greendiv.html b/tests/webkitwidgets/qgraphicswebview/resources/greendiv.html new file mode 100644 index 000000000..2f7fa97ca --- /dev/null +++ b/tests/webkitwidgets/qgraphicswebview/resources/greendiv.html @@ -0,0 +1,8 @@ + +
+ + diff --git a/tests/webkitwidgets/qgraphicswebview/resources/input_types.html b/tests/webkitwidgets/qgraphicswebview/resources/input_types.html new file mode 100644 index 000000000..18ab314bf --- /dev/null +++ b/tests/webkitwidgets/qgraphicswebview/resources/input_types.html @@ -0,0 +1,8 @@ + +
+
+
+
+
+
" + \ No newline at end of file diff --git a/tests/webkitwidgets/qgraphicswebview/resources/pointing_right.html b/tests/webkitwidgets/qgraphicswebview/resources/pointing_right.html new file mode 100644 index 000000000..bc592fbde --- /dev/null +++ b/tests/webkitwidgets/qgraphicswebview/resources/pointing_right.html @@ -0,0 +1,45 @@ + + + + + + diff --git a/tests/webkitwidgets/qgraphicswebview/resources/pointing_up.html b/tests/webkitwidgets/qgraphicswebview/resources/pointing_up.html new file mode 100644 index 000000000..474a56d3f --- /dev/null +++ b/tests/webkitwidgets/qgraphicswebview/resources/pointing_up.html @@ -0,0 +1,46 @@ + + + + + + diff --git a/tests/webkitwidgets/qgraphicswebview/resources/scrolltest_page.html b/tests/webkitwidgets/qgraphicswebview/resources/scrolltest_page.html new file mode 100644 index 000000000..18fcbbebe --- /dev/null +++ b/tests/webkitwidgets/qgraphicswebview/resources/scrolltest_page.html @@ -0,0 +1,6 @@ + +Scrolling test + +
+ + diff --git a/tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.cpp b/tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.cpp new file mode 100644 index 000000000..0e8577d8c --- /dev/null +++ b/tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.cpp @@ -0,0 +1,730 @@ +/* + Copyright (C) 2009 Jakub Wieczorek + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "../util.h" +#include +#include +#include +#include +#include +#include +#include + +#if defined(ENABLE_WEBGL) && ENABLE_WEBGL +#include +#endif + +class tst_QGraphicsWebView : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void qgraphicswebview(); + void crashOnViewlessWebPages(); + void microFocusCoordinates(); + void focusInputTypes(); + void crashOnSetScaleBeforeSetUrl(); + void widgetsRenderingThroughCache(); + void windowResizeEvent(); + void horizontalScrollbarTest(); + +#if !(defined(USE_QT_MOBILE_THEME) && USE_QT_MOBILE_THEME) + void setPalette_data(); + void setPalette(); +#endif + void renderHints(); +#if defined(USE_TILED_BACKING_STORE) && USE_TILED_BACKING_STORE + void bug57798(); + void bug56929(); +#endif +#if defined(ENABLE_WEBGL) && ENABLE_WEBGL + void webglSoftwareFallbackVerticalOrientation(); + void webglSoftwareFallbackHorizontalOrientation(); + +private: + void compareCanvasToImage(const QUrl&, const QImage&); +#endif +}; + +void tst_QGraphicsWebView::qgraphicswebview() +{ + QGraphicsWebView item; + item.url(); + item.title(); + item.icon(); + item.zoomFactor(); + item.history(); + item.settings(); + item.page(); + item.setPage(0); + item.page(); + item.setUrl(QUrl()); + item.setZoomFactor(0); + item.load(QUrl()); + item.setHtml(QString()); + item.setContent(QByteArray()); + item.isModified(); +} + +class WebPage : public QWebPage +{ + Q_OBJECT + +public: + WebPage(QObject* parent = 0): QWebPage(parent) + { + } + + QGraphicsWebView* webView; + +private Q_SLOTS: + // Force a webview deletion during the load. + // It should not cause WebPage to crash due to + // it accessing invalid pageClient pointer. + void aborting() + { + delete webView; + } +}; + +class GraphicsWebView : public QGraphicsWebView +{ + Q_OBJECT + +public: + GraphicsWebView(QGraphicsItem* parent = 0): QGraphicsWebView(parent) + { + } + + void fireMouseClick(QPointF point) { + QGraphicsSceneMouseEvent presEv(QEvent::GraphicsSceneMousePress); + presEv.setPos(point); + presEv.setButton(Qt::LeftButton); + presEv.setButtons(Qt::LeftButton); + QGraphicsSceneMouseEvent relEv(QEvent::GraphicsSceneMouseRelease); + relEv.setPos(point); + relEv.setButton(Qt::LeftButton); + relEv.setButtons(Qt::LeftButton); + QGraphicsWebView::sceneEvent(&presEv); + QGraphicsWebView::sceneEvent(&relEv); + } +}; + +void tst_QGraphicsWebView::crashOnViewlessWebPages() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + + QGraphicsWebView* webView = new QGraphicsWebView; + WebPage* page = new WebPage; + webView->setPage(page); + page->webView = webView; + scene.addItem(webView); + + view.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + view.resize(600, 480); + webView->resize(view.geometry().size()); + + QCoreApplication::processEvents(); + view.show(); + + // Resizing the page will resize and layout the empty "about:blank" + // page, so we first connect the signal afterward. + connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), page, SLOT(aborting())); + + page->mainFrame()->load(QUrl("data:text/html," + "" + "" + "" + "")); + + QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); + delete page; +} + +void tst_QGraphicsWebView::crashOnSetScaleBeforeSetUrl() +{ + QGraphicsWebView* webView = new QGraphicsWebView; + webView->setScale(2.0); + delete webView; +} + +void tst_QGraphicsWebView::widgetsRenderingThroughCache() +{ + QSKIP("TiledBackingStore does not work -- https://github.com/qtwebkit/qtwebkit/issues/407"); + + // Widgets should be rendered the same way with and without + // intermediate cache (tiling for example). + // See bug https://bugs.webkit.org/show_bug.cgi?id=47767 where + // widget are rendered as disabled when caching is using. + + QGraphicsWebView* webView = new QGraphicsWebView; + webView->setHtml(QLatin1String("")); + + QGraphicsView view; + // Disable the scrollbars on the graphics view because QtWebKit handles scrolling and scrollbar automatically + view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view.show(); + QGraphicsScene* scene = new QGraphicsScene(&view); + view.setScene(scene); + scene->addItem(webView); + view.setGeometry(QRect(0, 0, 500, 500)); + QWidget *const widget = &view; + QTest::qWaitForWindowExposed(widget); + + // 1. Reference without tiling. + webView->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, false); + QPixmap referencePixmap(view.size()); + QApplication::processEvents(); + widget->render(&referencePixmap); + + // 2. With tiling. + webView->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); + QPixmap viewWithTiling(view.size()); + widget->render(&viewWithTiling); + QApplication::processEvents(); + widget->render(&viewWithTiling); + + QCOMPARE(referencePixmap.toImage(), viewWithTiling.toImage()); +} + +#if defined(USE_TILED_BACKING_STORE) && USE_TILED_BACKING_STORE +void tst_QGraphicsWebView::bug57798() +{ + // When content size grows from less than viewport size to more than that, tiles may need to be regenerated. + + QGraphicsWebView* webView = new QGraphicsWebView(); + webView->setGeometry(QRectF(0.0, 0.0, 100.0, 100.0)); + QGraphicsView view(new QGraphicsScene()); + view.scene()->setParent(&view); + view.scene()->addItem(webView); + webView->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); + QStyleOptionGraphicsItem option; + option.exposedRect = view.sceneRect(); + QImage img(view.width(), view.height(), + QImage::Format_ARGB32_Premultiplied); + QPainter painter(&img); + // This will not paint anything as the tiles are not ready, but will trigger tile creation with size (0, 0). + webView->paint(&painter, &option); + QApplication::processEvents(); + QUrl url("qrc:///resources/greendiv.html"); + webView->load(url); + QVERIFY(waitForSignal(webView, SIGNAL(loadFinished(bool)))); + // This should trigger the recreation of the tiles. + webView->paint(&painter, &option); + QApplication::processEvents(); + painter.fillRect(option.exposedRect, Qt::red); // This is here to ensure failure if paint does not paint anything + webView->paint(&painter, &option); + QCOMPARE(img.pixel(option.exposedRect.width() / 4, option.exposedRect.height() / 4), qRgba(0, 128, 0, 255)); +} + +void tst_QGraphicsWebView::bug56929() +{ + // When rendering from tiles sychronous layout should not be triggered + // and scrollbars should be in sync with the size of the document in the displayed state. + + QGraphicsWebView* webView = new QGraphicsWebView(); + webView->setGeometry(QRectF(0.0, 0.0, 100.0, 100.0)); + QGraphicsView view(new QGraphicsScene()); + view.scene()->setParent(&view); + view.scene()->addItem(webView); + webView->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); + QUrl url("qrc:///resources/greendiv.html"); + webView->load(url); + QVERIFY(waitForSignal(webView, SIGNAL(loadFinished(bool)))); + QStyleOptionGraphicsItem option; + option.exposedRect = webView->geometry(); + QImage img(option.exposedRect.width(), option.exposedRect.height(), QImage::Format_ARGB32_Premultiplied); + QPainter painter(&img); + // This will not paint anything as the tiles are not ready, yet. + webView->paint(&painter, &option); + QApplication::processEvents(); + webView->paint(&painter, &option); + QCOMPARE(img.pixel(option.exposedRect.width() - 2, option.exposedRect.height() / 2), qRgba(255, 255, 255, 255)); + painter.fillRect(option.exposedRect, Qt::black); + QCOMPARE(img.pixel(option.exposedRect.width() - 2, option.exposedRect.height() / 2), qRgba(0, 0, 0, 255)); + webView->page()->mainFrame()->evaluateJavaScript(QString("resizeDiv();")); + webView->paint(&painter, &option); + QCOMPARE(img.pixel(option.exposedRect.width() - 2, option.exposedRect.height() / 2), qRgba(255, 255, 255, 255)); +} +#endif + +void tst_QGraphicsWebView::microFocusCoordinates() +{ + QWebPage* page = new QWebPage; + QGraphicsWebView* webView = new QGraphicsWebView; + webView->setPage( page ); + QGraphicsView* view = new QGraphicsView; + QGraphicsScene* scene = new QGraphicsScene(view); + view->setScene(scene); + scene->addItem(webView); + view->setGeometry(QRect(0,0,500,500)); + + page->mainFrame()->setHtml("" \ + "
" \ + "" \ + "
" \ + "" \ + ""); + + page->mainFrame()->setFocus(); + + QVariant initialMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); + QVERIFY(initialMicroFocus.isValid()); + + page->mainFrame()->scroll(0,300); + + QVariant currentMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); + QVERIFY(currentMicroFocus.isValid()); + + QCOMPARE(initialMicroFocus.toRect().translated(QPoint(0,-300)), currentMicroFocus.toRect()); + + delete view; +} + +void tst_QGraphicsWebView::focusInputTypes() +{ + QWebPage* page = new QWebPage; + GraphicsWebView* webView = new GraphicsWebView; + webView->setPage( page ); + QGraphicsView* view = new QGraphicsView; + QGraphicsScene* scene = new QGraphicsScene(view); + view->setScene(scene); + scene->addItem(webView); + view->setGeometry(QRect(0,0,500,500)); + QCoreApplication::processEvents(); + QUrl url("qrc:///resources/input_types.html"); + page->mainFrame()->load(url); + page->mainFrame()->setFocus(); + + QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); + + // 'text' type + webView->fireMouseClick(QPointF(20.0, 10.0)); + QVERIFY(webView->inputMethodHints() == Qt::ImhNone); + + // 'password' field + webView->fireMouseClick(QPointF(20.0, 60.0)); + QVERIFY(webView->inputMethodHints() & Qt::ImhHiddenText); + + // 'tel' field + webView->fireMouseClick(QPointF(20.0, 110.0)); + QVERIFY(webView->inputMethodHints() & Qt::ImhDialableCharactersOnly); + + // 'number' field + webView->fireMouseClick(QPointF(20.0, 160.0)); + QVERIFY(webView->inputMethodHints() & Qt::ImhDigitsOnly); + + // 'email' field + webView->fireMouseClick(QPointF(20.0, 210.0)); + QVERIFY(webView->inputMethodHints() & Qt::ImhEmailCharactersOnly); + + // 'url' field + webView->fireMouseClick(QPointF(20.0, 260.0)); + QVERIFY(webView->inputMethodHints() & Qt::ImhUrlCharactersOnly); + + delete webView; + delete view; +} + +#if !(defined(USE_QT_MOBILE_THEME) && USE_QT_MOBILE_THEME) +void tst_QGraphicsWebView::setPalette_data() +{ + QTest::addColumn("active"); + QTest::addColumn("background"); + QTest::newRow("activeBG") << true << true; + QTest::newRow("activeFG") << true << false; + QTest::newRow("inactiveBG") << false << true; + QTest::newRow("inactiveFG") << false << false; +} + +// Render a QGraphicsWebView to a QImage twice, each time with a different palette set, +// verify that images rendered are not the same, confirming WebCore usage of +// custom palette on selections. +void tst_QGraphicsWebView::setPalette() +{ + QString html = "" + "" + "Some text here" + "" + ""; + + QFETCH(bool, active); + QFETCH(bool, background); + + QWidget* activeView = 0; + + // Use controlView to manage active/inactive state of test views by raising + // or lowering their position in the window stack. + QGraphicsScene controlScene; + QGraphicsView controlView(&controlScene); + QGraphicsWebView controlWebView; + controlScene.addItem(&controlWebView); + controlWebView.setHtml(html); + controlWebView.setGeometry(QRectF(0, 0, 200, 200)); + + QGraphicsScene scene1; + QGraphicsView view1(&scene1); + view1.setSceneRect(0, 0, 300, 300); + QGraphicsWebView webView1; + webView1.setResizesToContents(true); + scene1.addItem(&webView1); + webView1.setFocus(); + + QPalette palette1; + QBrush brush1(Qt::red); + brush1.setStyle(Qt::SolidPattern); + if (active && background) { + // Rendered image must have red background on an active QGraphicsWebView. + palette1.setBrush(QPalette::Active, QPalette::Highlight, brush1); + } else if (active && !background) { + // Rendered image must have red foreground on an active QGraphicsWebView. + palette1.setBrush(QPalette::Active, QPalette::HighlightedText, brush1); + } else if (!active && background) { + // Rendered image must have red background on an inactive QGraphicsWebView. + palette1.setBrush(QPalette::Inactive, QPalette::Highlight, brush1); + } else if (!active && !background) { + // Rendered image must have red foreground on an inactive QGraphicsWebView. + palette1.setBrush(QPalette::Inactive, QPalette::HighlightedText, brush1); + } + + webView1.setHtml(html); + view1.resize(webView1.page()->viewportSize()); + webView1.setPalette(palette1); + view1.show(); + + QVERIFY(webView1.palette() == palette1); + QVERIFY(webView1.page()->palette() == palette1); + + QTest::qWaitForWindowExposed(&view1); + + if (!active) { + controlView.show(); + QTest::qWaitForWindowExposed(&controlView); + QApplication::setActiveWindow(&controlView); + activeView = &controlView; + controlView.activateWindow(); + } else { + QApplication::setActiveWindow(&view1); + view1.activateWindow(); + activeView = &view1; + } + + QTRY_COMPARE(QApplication::activeWindow(), activeView); + + webView1.page()->triggerAction(QWebPage::SelectAll); + + QImage img1(webView1.page()->viewportSize(), QImage::Format_ARGB32); + QPainter painter1(&img1); + webView1.page()->currentFrame()->render(&painter1); + painter1.end(); + view1.close(); + controlView.close(); + + QGraphicsScene scene2; + QGraphicsView view2(&scene2); + view2.setSceneRect(0, 0, 300, 300); + QGraphicsWebView webView2; + webView2.setResizesToContents(true); + scene2.addItem(&webView2); + webView2.setFocus(); + + QPalette palette2; + QBrush brush2(Qt::blue); + brush2.setStyle(Qt::SolidPattern); + if (active && background) { + // Rendered image must have blue background on an active QGraphicsWebView. + palette2.setBrush(QPalette::Active, QPalette::Highlight, brush2); + } else if (active && !background) { + // Rendered image must have blue foreground on an active QGraphicsWebView. + palette2.setBrush(QPalette::Active, QPalette::HighlightedText, brush2); + } else if (!active && background) { + // Rendered image must have blue background on an inactive QGraphicsWebView. + palette2.setBrush(QPalette::Inactive, QPalette::Highlight, brush2); + } else if (!active && !background) { + // Rendered image must have blue foreground on an inactive QGraphicsWebView. + palette2.setBrush(QPalette::Inactive, QPalette::HighlightedText, brush2); + } + + webView2.setHtml(html); + view2.resize(webView2.page()->viewportSize()); + webView2.setPalette(palette2); + view2.show(); + + QTest::qWaitForWindowExposed(&view2); + + if (!active) { + controlView.show(); + QTest::qWaitForWindowExposed(&controlView); + QApplication::setActiveWindow(&controlView); + activeView = &controlView; + controlView.activateWindow(); + } else { + QApplication::setActiveWindow(&view2); + view2.activateWindow(); + activeView = &view2; + } + + QTRY_COMPARE(QApplication::activeWindow(), activeView); + + webView2.page()->triggerAction(QWebPage::SelectAll); + + QImage img2(webView2.page()->viewportSize(), QImage::Format_ARGB32); + QPainter painter2(&img2); + webView2.page()->currentFrame()->render(&painter2); + painter2.end(); + + view2.close(); + controlView.close(); + + QVERIFY(img1 != img2); +} +#endif + +void tst_QGraphicsWebView::renderHints() +{ + QGraphicsWebView webView; + + // default is only text antialiasing + smooth pixmap transform + QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); + QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); + QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); + QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); + + webView.setRenderHint(QPainter::Antialiasing, true); + QVERIFY(webView.renderHints() & QPainter::Antialiasing); + QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); + QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); + QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); + + webView.setRenderHint(QPainter::Antialiasing, false); + QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); + QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); + QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); + QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); + + webView.setRenderHint(QPainter::SmoothPixmapTransform, true); + QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); + QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); + QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); + QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); + + webView.setRenderHint(QPainter::SmoothPixmapTransform, false); + QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); + QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform)); + QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); +} + +class GraphicsView : public QGraphicsView { +public: + GraphicsView(); + QGraphicsWebView* m_webView; +}; + +#if defined(ENABLE_WEBGL) && ENABLE_WEBGL +bool compareImagesFuzzyPixelCount(const QImage& image1, const QImage& image2, qreal tolerance = 0.05) +{ + if (image1.size() != image2.size()) + return false; + + unsigned diffPixelCount = 0; + for (int row = 0; row < image1.size().width(); ++row) { + for (int column = 0; column < image1.size().height(); ++column) + if (image1.pixel(row, column) != image2.pixel(row, column)) + ++diffPixelCount; + } + + if (diffPixelCount > (image1.size().width() * image1.size().height()) * tolerance) + return false; + + return true; +} + +GraphicsView::GraphicsView() +{ + QGraphicsScene* const scene = new QGraphicsScene(this); + setScene(scene); + + m_webView = new QGraphicsWebView; + scene->addItem(m_webView); + + m_webView->page()->settings()->setAttribute(QWebSettings::WebGLEnabled, true); + m_webView->setResizesToContents(true); + + setFrameShape(QFrame::NoFrame); + setViewport(new QGLWidget); +} + +void tst_QGraphicsWebView::webglSoftwareFallbackVerticalOrientation() +{ + QSKIP("Hangs on X11 -- https://bugs.webkit.org/show_bug.cgi?id=105820"); + QSize canvasSize(100, 100); + QImage reference(canvasSize, QImage::Format_ARGB32); + reference.fill(0xFF00FF00); + { // Reference. + QPainter painter(&reference); + QPolygonF triangleUp; + triangleUp << QPointF(0, canvasSize.height()) + << QPointF(canvasSize.width(), canvasSize.height()) + << QPointF(canvasSize.width() / 2.0, canvasSize.height() / 2.0); + painter.setPen(Qt::NoPen); + painter.setBrush(Qt::red); + painter.drawPolygon(triangleUp); + } + + compareCanvasToImage(QUrl(QLatin1String("qrc:///resources/pointing_up.html")), reference); +} + +void tst_QGraphicsWebView::webglSoftwareFallbackHorizontalOrientation() +{ + QSKIP("Hangs on X11 -- https://bugs.webkit.org/show_bug.cgi?id=105820"); + QSize canvasSize(100, 100); + QImage reference(canvasSize, QImage::Format_ARGB32); + reference.fill(0xFF00FF00); + { // Reference. + QPainter painter(&reference); + QPolygonF triangleUp; + triangleUp << QPointF(0, 0) + << QPointF(0, canvasSize.height()) + << QPointF(canvasSize.width() / 2.0, canvasSize.height() / 2.0); + painter.setPen(Qt::NoPen); + painter.setBrush(Qt::red); + painter.drawPolygon(triangleUp); + } + + compareCanvasToImage(QUrl(QLatin1String("qrc:///resources/pointing_right.html")), reference); +} + +void tst_QGraphicsWebView::compareCanvasToImage(const QUrl& url, const QImage& reference) +{ + GraphicsView view; + view.show(); + QTest::qWaitForWindowExposed(&view); + + QGraphicsWebView* const graphicsWebView = view.m_webView; + graphicsWebView->load(url); + QVERIFY(waitForSignal(graphicsWebView, SIGNAL(loadFinished(bool)))); + { // Force a render, to create the accelerated compositing tree. + QPixmap pixmap(view.size()); + QPainter painter(&pixmap); + view.render(&painter); + } + + const QSize imageSize = reference.size(); + + QImage target(imageSize, QImage::Format_ARGB32); + { // Web page content. + QPainter painter(&target); + QRectF renderRect(0, 0, imageSize.width(), imageSize.height()); + view.scene()->render(&painter, renderRect, renderRect); + } + QVERIFY(compareImagesFuzzyPixelCount(target, reference, 0.01)); +} +#endif + +class ResizeSpy : public QObject { + Q_OBJECT +public Q_SLOTS: + void receiveResize(int width, int height) + { + m_size = QSize(width, height); + emit resized(); + } + + QSize size() const + { + return m_size; + } + +Q_SIGNALS: + void resized(); + +private: + QSize m_size; +}; + +void tst_QGraphicsWebView::windowResizeEvent() +{ + QGraphicsWebView webView; + ResizeSpy resizeSpy; + resizeSpy.setProperty("resizeCount", 0); + + QString html = ""; + + webView.page()->mainFrame()->setHtml(html); + webView.page()->mainFrame()->addToJavaScriptWindowObject("resizeSpy", + &resizeSpy); + webView.setGeometry(QRect(0, 0, 50, 50)); + QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118670", Continue); + QVERIFY(::waitForSignal(&resizeSpy, SIGNAL(resized()), 1000)); + QCOMPARE(resizeSpy.size(), QSize(50, 50)); + + webView.page()->setActualVisibleContentRect(QRect(10, 10, 60, 60)); + webView.setGeometry(QRect(0, 0, 100, 100)); + waitForSignal(&resizeSpy, SIGNAL(resized()), 1000); + + // This will be triggered without the fix on DOMWindow::innerHeight/Width + QCOMPARE(resizeSpy.size(), QSize(60, 60)); +} + +void tst_QGraphicsWebView::horizontalScrollbarTest() +{ + QWebPage* page = new QWebPage; + GraphicsWebView* webView = new GraphicsWebView; + webView->setPage(page); + webView->setGeometry(QRect(0, 0, 600, 600)); + QGraphicsView* view = new QGraphicsView; + QGraphicsScene* scene = new QGraphicsScene(view); + view->setScene(scene); + scene->addItem(webView); + + // Turn off scrolling on the containing QGraphicsView, let the + // QGraphicsWebView handle the scrolling by itself. + view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view->show(); + QCoreApplication::processEvents(); + + QUrl url("qrc:///resources/scrolltest_page.html"); + page->mainFrame()->load(url); + page->mainFrame()->setFocus(); + + QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); + + QVERIFY(webView->page()->mainFrame()->scrollPosition() == QPoint(0, 0)); + + // Note: The test below assumes that the layout direction is Qt::LeftToRight. + webView->fireMouseClick(QPointF(550.0, 590.0)); + QVERIFY(page->mainFrame()->scrollPosition().x() > 0); + + // Note: The test below assumes that the layout direction is Qt::LeftToRight. + webView->fireMouseClick(QPointF(20.0, 590.0)); + QVERIFY(page->mainFrame()->scrollPosition() == QPoint(0, 0)); + + delete webView; + delete view; +} + +QTEST_MAIN(tst_QGraphicsWebView) + +#include "tst_qgraphicswebview.moc" diff --git a/tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.qrc b/tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.qrc new file mode 100644 index 000000000..ff06bd8c4 --- /dev/null +++ b/tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.qrc @@ -0,0 +1,9 @@ + + + resources/input_types.html + resources/pointing_right.html + resources/pointing_up.html + resources/greendiv.html + resources/scrolltest_page.html + + diff --git a/tests/webkitwidgets/qobjectbridge/qobjectbridge.pro b/tests/webkitwidgets/qobjectbridge/qobjectbridge.pro new file mode 100644 index 000000000..f434ccbc1 --- /dev/null +++ b/tests/webkitwidgets/qobjectbridge/qobjectbridge.pro @@ -0,0 +1,3 @@ +include(../tests.pri) +exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc + diff --git a/tests/webkitwidgets/qobjectbridge/tst_qobjectbridge.cpp b/tests/webkitwidgets/qobjectbridge/tst_qobjectbridge.cpp new file mode 100644 index 000000000..a46d39050 --- /dev/null +++ b/tests/webkitwidgets/qobjectbridge/tst_qobjectbridge.cpp @@ -0,0 +1,2271 @@ +/* + Copyright (C) 2008,2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include + +#include +#include +#include +#include +#include + +struct CustomType { + QString string; +}; +Q_DECLARE_METATYPE(CustomType) + +Q_DECLARE_METATYPE(QBrush*) +Q_DECLARE_METATYPE(QObjectList) +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QVariantList) +Q_DECLARE_METATYPE(QVariantMap) + +class MyQObject : public QObject { + Q_OBJECT + + Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty) + Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty) + Q_PROPERTY(QVariantList variantListProperty READ variantListProperty WRITE setVariantListProperty) + Q_PROPERTY(QVariantMap variantMapProperty READ variantMapProperty WRITE setVariantMapProperty) + Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty) + Q_PROPERTY(QStringList stringListProperty READ stringListProperty WRITE setStringListProperty) + Q_PROPERTY(QByteArray byteArrayProperty READ byteArrayProperty WRITE setByteArrayProperty) + Q_PROPERTY(QBrush brushProperty READ brushProperty WRITE setBrushProperty) + Q_PROPERTY(double hiddenProperty READ hiddenProperty WRITE setHiddenProperty SCRIPTABLE false) + Q_PROPERTY(int writeOnlyProperty WRITE setWriteOnlyProperty) + Q_PROPERTY(int readOnlyProperty READ readOnlyProperty) + Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) + Q_PROPERTY(CustomType propWithCustomType READ propWithCustomType WRITE setPropWithCustomType) + Q_PROPERTY(QWebElement webElementProperty READ webElementProperty WRITE setWebElementProperty) + Q_PROPERTY(QObject* objectStarProperty READ objectStarProperty WRITE setObjectStarProperty) + Q_ENUMS(Policy Strategy) + Q_FLAGS(Ability) + +public: + enum Policy { + FooPolicy = 0, + BarPolicy, + BazPolicy + }; + + enum Strategy { + FooStrategy = 10, + BarStrategy, + BazStrategy + }; + + enum AbilityFlag { + NoAbility = 0x000, + FooAbility = 0x001, + BarAbility = 0x080, + BazAbility = 0x200, + AllAbility = FooAbility | BarAbility | BazAbility + }; + + Q_DECLARE_FLAGS(Ability, AbilityFlag) + + MyQObject(QObject* parent = 0) + : QObject(parent), + m_intValue(123), + m_variantValue(QLatin1String("foo")), + m_variantListValue(QVariantList() << QVariant(123) << QVariant(QLatin1String("foo"))), + m_stringValue(QLatin1String("bar")), + m_stringListValue(QStringList() << QLatin1String("zig") << QLatin1String("zag")), + m_brushValue(QColor(10, 20, 30, 40)), + m_hiddenValue(456.0), + m_writeOnlyValue(789), + m_readOnlyValue(987), + m_objectStar(0), + m_qtFunctionInvoked(-1) + { + m_variantMapValue.insert("a", QVariant(123)); + m_variantMapValue.insert("b", QVariant(QLatin1String("foo"))); + m_variantMapValue.insert("c", QVariant::fromValue(this)); + } + + ~MyQObject() { } + + int intProperty() const + { + return m_intValue; + } + void setIntProperty(int value) + { + m_intValue = value; + } + + QVariant variantProperty() const + { + return m_variantValue; + } + void setVariantProperty(const QVariant& value) + { + m_variantValue = value; + } + + QVariantList variantListProperty() const + { + return m_variantListValue; + } + void setVariantListProperty(const QVariantList& value) + { + m_variantListValue = value; + } + + QVariantMap variantMapProperty() const + { + return m_variantMapValue; + } + void setVariantMapProperty(const QVariantMap& value) + { + m_variantMapValue = value; + } + + QString stringProperty() const + { + return m_stringValue; + } + void setStringProperty(const QString& value) + { + m_stringValue = value; + } + + QStringList stringListProperty() const + { + return m_stringListValue; + } + void setStringListProperty(const QStringList& value) + { + m_stringListValue = value; + } + + QByteArray byteArrayProperty() const + { + return m_byteArrayValue; + } + void setByteArrayProperty(const QByteArray& value) + { + m_byteArrayValue = value; + } + + QBrush brushProperty() const + { + return m_brushValue; + } + void setBrushProperty(const QBrush& value) + { + m_brushValue = value; + } + + double hiddenProperty() const + { + return m_hiddenValue; + } + void setHiddenProperty(double value) + { + m_hiddenValue = value; + } + + int writeOnlyProperty() const + { + return m_writeOnlyValue; + } + void setWriteOnlyProperty(int value) + { + m_writeOnlyValue = value; + } + + int readOnlyProperty() const + { + return m_readOnlyValue; + } + + QKeySequence shortcut() const + { + return m_shortcut; + } + void setShortcut(const QKeySequence& seq) + { + m_shortcut = seq; + } + + QWebElement webElementProperty() const + { + return m_webElement; + } + void setWebElementProperty(const QWebElement& element) + { + m_webElement = element; + } + + CustomType propWithCustomType() const + { + return m_customType; + } + void setPropWithCustomType(const CustomType& c) + { + m_customType = c; + } + + QObject* objectStarProperty() const + { + return m_objectStar; + } + void setObjectStarProperty(QObject* object) + { + m_objectStar = object; + } + + + int qtFunctionInvoked() const + { + return m_qtFunctionInvoked; + } + + QVariantList qtFunctionActuals() const + { + return m_actuals; + } + + void resetQtFunctionInvoked() + { + m_qtFunctionInvoked = -1; + m_actuals.clear(); + } + + Q_INVOKABLE void myInvokable() + { + m_qtFunctionInvoked = 0; + } + Q_INVOKABLE void myInvokableWithIntArg(int arg) + { + m_qtFunctionInvoked = 1; + m_actuals << arg; + } + Q_INVOKABLE void myInvokableWithLonglongArg(qlonglong arg) + { + m_qtFunctionInvoked = 2; + m_actuals << arg; + } + Q_INVOKABLE void myInvokableWithFloatArg(float arg) + { + m_qtFunctionInvoked = 3; + m_actuals << arg; + } + Q_INVOKABLE void myInvokableWithDoubleArg(double arg) + { + m_qtFunctionInvoked = 4; + m_actuals << arg; + } + Q_INVOKABLE void myInvokableWithStringArg(const QString& arg) + { + m_qtFunctionInvoked = 5; + m_actuals << arg; + } + Q_INVOKABLE void myInvokableWithIntArgs(int arg1, int arg2) + { + m_qtFunctionInvoked = 6; + m_actuals << arg1 << arg2; + } + Q_INVOKABLE int myInvokableReturningInt() + { + m_qtFunctionInvoked = 7; + return 123; + } + Q_INVOKABLE qlonglong myInvokableReturningLongLong() + { + m_qtFunctionInvoked = 39; + return 456; + } + Q_INVOKABLE QString myInvokableReturningString() + { + m_qtFunctionInvoked = 8; + return QLatin1String("ciao"); + } + Q_INVOKABLE void myInvokableWithIntArg(int arg1, int arg2) // Overload. + { + m_qtFunctionInvoked = 9; + m_actuals << arg1 << arg2; + } + Q_INVOKABLE void myInvokableWithEnumArg(Policy policy) + { + m_qtFunctionInvoked = 10; + m_actuals << policy; + } + Q_INVOKABLE void myInvokableWithQualifiedEnumArg(MyQObject::Policy policy) + { + m_qtFunctionInvoked = 36; + m_actuals << policy; + } + Q_INVOKABLE Policy myInvokableReturningEnum() + { + m_qtFunctionInvoked = 37; + return BazPolicy; + } + Q_INVOKABLE MyQObject::Policy myInvokableReturningQualifiedEnum() + { + m_qtFunctionInvoked = 38; + return BazPolicy; + } + Q_INVOKABLE QVector myInvokableReturningVectorOfInt() + { + m_qtFunctionInvoked = 11; + return QVector(); + } + Q_INVOKABLE void myInvokableWithVectorOfIntArg(const QVector&) + { + m_qtFunctionInvoked = 12; + } + Q_INVOKABLE QObject* myInvokableReturningQObjectStar() + { + m_qtFunctionInvoked = 13; + return this; + } + Q_INVOKABLE QObjectList myInvokableWithQObjectListArg(const QObjectList& lst) + { + m_qtFunctionInvoked = 14; + m_actuals << QVariant::fromValue(lst); + return lst; + } + Q_INVOKABLE QVariant myInvokableWithVariantArg(const QVariant& v) + { + m_qtFunctionInvoked = 15; + m_actuals << v; + return v; + } + Q_INVOKABLE QVariantMap myInvokableWithVariantMapArg(const QVariantMap& vm) + { + m_qtFunctionInvoked = 16; + m_actuals << vm; + return vm; + } + Q_INVOKABLE QList myInvokableWithListOfIntArg(const QList& lst) + { + m_qtFunctionInvoked = 17; + m_actuals << QVariant::fromValue(lst); + return lst; + } + Q_INVOKABLE QObject* myInvokableWithQObjectStarArg(QObject* obj) + { + m_qtFunctionInvoked = 18; + m_actuals << QVariant::fromValue(obj); + return obj; + } + Q_INVOKABLE QBrush myInvokableWithQBrushArg(const QBrush& brush) + { + m_qtFunctionInvoked = 19; + m_actuals << QVariant::fromValue(brush); + return brush; + } + Q_INVOKABLE void myInvokableWithBrushStyleArg(Qt::BrushStyle style) + { + m_qtFunctionInvoked = 43; + // Qt::BrushStyle isn't registered and this shouldn't be reached. + QVERIFY(false); + } + Q_INVOKABLE void myInvokableWithVoidStarArg(void* arg) + { + m_qtFunctionInvoked = 44; + m_actuals << QVariant::fromValue(arg); + } + Q_INVOKABLE void myInvokableWithAmbiguousArg(int arg) + { + m_qtFunctionInvoked = 45; + m_actuals << QVariant::fromValue(arg); + } + Q_INVOKABLE void myInvokableWithAmbiguousArg(uint arg) + { + m_qtFunctionInvoked = 46; + m_actuals << QVariant::fromValue(arg); + } + Q_INVOKABLE void myInvokableWithDefaultArgs(int arg1, const QString& arg2 = QString()) + { + m_qtFunctionInvoked = 47; + m_actuals << QVariant::fromValue(arg1) << qVariantFromValue(arg2); + } + Q_INVOKABLE QObject& myInvokableReturningRef() + { + m_qtFunctionInvoked = 48; + return *this; + } + Q_INVOKABLE const QObject& myInvokableReturningConstRef() const + { + const_cast(this)->m_qtFunctionInvoked = 49; + return *this; + } + Q_INVOKABLE void myInvokableWithPointArg(const QPoint &arg) { + const_cast(this)->m_qtFunctionInvoked = 50; + m_actuals << QVariant::fromValue(arg); + } + Q_INVOKABLE void myInvokableWithPointArg(const QPointF &arg) { + const_cast(this)->m_qtFunctionInvoked = 51; + m_actuals << QVariant::fromValue(arg); + } + Q_INVOKABLE void myInvokableWithBoolArg(bool arg) { + m_qtFunctionInvoked = 52; + m_actuals << arg; + } + + void emitMySignal() + { + emit mySignal(); + } + void emitMySignalWithIntArg(int arg) + { + emit mySignalWithIntArg(arg); + } + void emitMySignal2(bool arg) + { + emit mySignal2(arg); + } + void emitMySignal2() + { + emit mySignal2(); + } + void emitMySignalWithDateTimeArg(QDateTime dt) + { + emit mySignalWithDateTimeArg(dt); + } + +public Q_SLOTS: + void mySlot() + { + m_qtFunctionInvoked = 20; + } + + void mySlotWithIntArg(int arg) + { + m_qtFunctionInvoked = 21; + m_actuals << arg; + } + + void mySlotWithDoubleArg(double arg) + { + m_qtFunctionInvoked = 22; + m_actuals << arg; + } + + void mySlotWithStringArg(const QString &arg) + { + m_qtFunctionInvoked = 23; + m_actuals << arg; + } + + void myOverloadedSlot() + { + m_qtFunctionInvoked = 24; + } + + void myOverloadedSlot(QObject* arg) + { + m_qtFunctionInvoked = 41; + m_actuals << QVariant::fromValue(arg); + } + + void myOverloadedSlot(bool arg) + { + m_qtFunctionInvoked = 25; + m_actuals << arg; + } + + void myOverloadedSlot(const QStringList &arg) + { + m_qtFunctionInvoked = 42; + m_actuals << arg; + } + + void myOverloadedSlot(double arg) + { + m_qtFunctionInvoked = 26; + m_actuals << arg; + } + + void myOverloadedSlot(float arg) + { + m_qtFunctionInvoked = 27; + m_actuals << arg; + } + + void myOverloadedSlot(int arg) + { + m_qtFunctionInvoked = 28; + m_actuals << arg; + } + + void myOverloadedSlot(const QString &arg) + { + m_qtFunctionInvoked = 29; + m_actuals << arg; + } + + void myOverloadedSlot(const QColor &arg) + { + m_qtFunctionInvoked = 30; + m_actuals << arg; + } + + void myOverloadedSlot(const QBrush &arg) + { + m_qtFunctionInvoked = 31; + m_actuals << arg; + } + + void myOverloadedSlot(const QDateTime &arg) + { + m_qtFunctionInvoked = 32; + m_actuals << arg; + } + + void myOverloadedSlot(const QDate &arg) + { + m_qtFunctionInvoked = 33; + m_actuals << arg; + } + + void myOverloadedSlot(const QVariant &arg) + { + m_qtFunctionInvoked = 35; + m_actuals << arg; + } + + void myOverloadedSlot(const QWebElement &arg) + { + m_qtFunctionInvoked = 36; + m_actuals << QVariant::fromValue(arg); + } + +protected Q_SLOTS: + void myProtectedSlot() + { + m_qtFunctionInvoked = 36; + } + +private Q_SLOTS: + void myPrivateSlot() { } + +Q_SIGNALS: + void mySignal(); + void mySignalWithIntArg(int); + void mySignalWithDoubleArg(double); + void mySignal2(bool arg = false); + void mySignalWithDateTimeArg(QDateTime); + +private: + int m_intValue; + QVariant m_variantValue; + QVariantList m_variantListValue; + QVariantMap m_variantMapValue; + QString m_stringValue; + QStringList m_stringListValue; + QByteArray m_byteArrayValue; + QBrush m_brushValue; + double m_hiddenValue; + int m_writeOnlyValue; + int m_readOnlyValue; + QKeySequence m_shortcut; + QWebElement m_webElement; + CustomType m_customType; + QObject* m_objectStar; + int m_qtFunctionInvoked; + QVariantList m_actuals; +}; + +class MyWebElementSlotOnlyObject : public QObject { + Q_OBJECT + Q_PROPERTY(QString tagName READ tagName) +public Q_SLOTS: + void doSomethingWithWebElement(const QWebElement& element) + { + m_tagName = element.tagName(); + } + +public: + QString tagName() const + { + return m_tagName; + } +private: + QString m_tagName; +}; + +class MyOtherQObject : public MyQObject { +public: + MyOtherQObject(QObject* parent = 0) + : MyQObject(parent) { } +}; + +class tst_QObjectBridge : public QObject { + Q_OBJECT + +public: + tst_QObjectBridge(); + +public Q_SLOTS: + void init(); + void cleanup(); + +private Q_SLOTS: + void getSetStaticProperty(); + void getSetDynamicProperty(); + void getSetChildren(); + void callQtInvokable(); + void connectAndDisconnect(); + void overrideInvokable(); + void overloadedSlots(); + void webElementSlotOnly(); + void enumerate_data(); + void enumerate(); + void objectDeleted(); + void typeConversion(); + void arrayObjectEnumerable(); + void domCycles(); + void jsByteArray(); + void ownership(); + void nullValue(); + void qObjectWrapperWithSameIdentity(); + void introspectQtMethods_data(); + void introspectQtMethods(); + void scriptablePlugin(); + void exceptionInSlot(); + +private: + QString evalJS(const QString& s) + { + QVariant ret = evalJSV(s); + if (!ret.isValid()) + return "undefined"; + return ret.toString(); + } + + QVariant evalJSV(const QString& s) + { + return m_page->mainFrame()->evaluateJavaScript(s); + } + + QString evalJS(const QString& s, QString& type) + { + return evalJSV(s, type).toString(); + } + + QVariant evalJSV(const QString& s, QString& type) + { + // As a special measure, if we get an exception we set the type to 'error' + // (in ecma, an Error object has typeof object, but qtscript has a convenience function) + // Similarly, an array is an object, but we'd prefer to have a type of 'array' + QString escaped = s; + escaped.replace('\'', "\\'"); // Don't preescape your single quotes! + QString code("var retvalue; " + "var typevalue; " + "try { " + " retvalue = eval('%1'); " + " typevalue = typeof retvalue; " + " if (retvalue instanceof Array) " + " typevalue = 'array'; " + "} catch(e) { " + " retvalue = e.name + ': ' + e.message; " + " typevalue = 'error'; " + "}"); + evalJS(code.arg(escaped)); + + QVariant ret = evalJSV("retvalue"); + if (ret.isValid()) + type = evalJS("typevalue"); + else { + ret = QString("undefined"); + type = sUndefined; + } + evalJS("delete retvalue; delete typevalue"); + return ret; + } + + const QString sTrue; + const QString sFalse; + const QString sUndefined; + const QString sArray; + const QString sFunction; + const QString sError; + const QString sString; + const QString sObject; + const QString sNumber; + +private: + QWebView* m_view; + QWebPage* m_page; + MyQObject* m_myObject; +}; + +tst_QObjectBridge::tst_QObjectBridge() + : sTrue("true") + , sFalse("false") + , sUndefined("undefined") + , sArray("array") + , sFunction("function") + , sError("error") + , sString("string") + , sObject("object") + , sNumber("number") +{ +} + +void tst_QObjectBridge::init() +{ + m_view = new QWebView(); + m_page = m_view->page(); + m_myObject = new MyQObject(); + m_page->mainFrame()->addToJavaScriptWindowObject("myObject", m_myObject); +} + +void tst_QObjectBridge::cleanup() +{ + delete m_view; + delete m_myObject; +} + +void tst_QObjectBridge::getSetStaticProperty() +{ + m_page->mainFrame()->setHtml(""); + QCOMPARE(evalJS("typeof myObject.noSuchProperty"), sUndefined); + + // initial value (set in MyQObject constructor) + { + QString type; + QVariant ret = evalJSV("myObject.intProperty", type); + QCOMPARE(type, sNumber); + QCOMPARE(ret.type(), QVariant::Double); + QCOMPARE(ret.toInt(), 123); + } + QCOMPARE(evalJS("myObject.intProperty === 123.0"), sTrue); + + { + QString type; + QVariant ret = evalJSV("myObject.variantProperty", type); + QCOMPARE(type, sString); + QCOMPARE(ret.type(), QVariant::String); + QCOMPARE(ret.toString(), QLatin1String("foo")); + } + QCOMPARE(evalJS("myObject.variantProperty == 'foo'"), sTrue); + + { + QString type; + QVariant ret = evalJSV("myObject.stringProperty", type); + QCOMPARE(type, sString); + QCOMPARE(ret.type(), QVariant::String); + QCOMPARE(ret.toString(), QLatin1String("bar")); + } + QCOMPARE(evalJS("myObject.stringProperty === 'bar'"), sTrue); + + { + QString type; + QVariant ret = evalJSV("myObject.variantListProperty", type); + QCOMPARE(type, sArray); + QCOMPARE(ret.type(), QVariant::List); + QVariantList vl = ret.value(); + QCOMPARE(vl.size(), 2); + QCOMPARE(vl.at(0).toInt(), 123); + QCOMPARE(vl.at(1).toString(), QLatin1String("foo")); + } + QCOMPARE(evalJS("myObject.variantListProperty.length === 2"), sTrue); + QCOMPARE(evalJS("myObject.variantListProperty[0] === 123"), sTrue); + QCOMPARE(evalJS("myObject.variantListProperty[1] === 'foo'"), sTrue); + + { + QString type; + QVariant ret = evalJSV("myObject.variantMapProperty", type); + QCOMPARE(type, sObject); + QCOMPARE(ret.type(), QVariant::Map); + QVariantMap vm = ret.value(); + QCOMPARE(vm.size(), 3); + QCOMPARE(vm.value("a").toInt(), 123); + QCOMPARE(vm.value("b").toString(), QLatin1String("foo")); + QCOMPARE(vm.value("c").value(), static_cast(m_myObject)); + } + QCOMPARE(evalJS("myObject.variantMapProperty.a === 123"), sTrue); + QCOMPARE(evalJS("myObject.variantMapProperty.b === 'foo'"), sTrue); + QCOMPARE(evalJS("myObject.variantMapProperty.c.variantMapProperty.b === 'foo'"), sTrue); + + { + QString type; + QVariant ret = evalJSV("myObject.stringListProperty", type); + QCOMPARE(type, sArray); + QCOMPARE(ret.type(), QVariant::List); + QVariantList vl = ret.value(); + QCOMPARE(vl.size(), 2); + QCOMPARE(vl.at(0).toString(), QLatin1String("zig")); + QCOMPARE(vl.at(1).toString(), QLatin1String("zag")); + } + QCOMPARE(evalJS("myObject.stringListProperty.length === 2"), sTrue); + QCOMPARE(evalJS("typeof myObject.stringListProperty[0]"), sString); + QCOMPARE(evalJS("myObject.stringListProperty[0]"), QLatin1String("zig")); + QCOMPARE(evalJS("typeof myObject.stringListProperty[1]"), sString); + QCOMPARE(evalJS("myObject.stringListProperty[1]"), QLatin1String("zag")); + + // property change in C++ should be reflected in script + m_myObject->setIntProperty(456); + QCOMPARE(evalJS("myObject.intProperty == 456"), sTrue); + m_myObject->setIntProperty(789); + QCOMPARE(evalJS("myObject.intProperty == 789"), sTrue); + + m_myObject->setVariantProperty(QLatin1String("bar")); + QCOMPARE(evalJS("myObject.variantProperty === 'bar'"), sTrue); + m_myObject->setVariantProperty(42); + QCOMPARE(evalJS("myObject.variantProperty === 42"), sTrue); + m_myObject->setVariantProperty(QVariant::fromValue(QBrush())); + + m_myObject->setStringProperty(QLatin1String("baz")); + QCOMPARE(evalJS("myObject.stringProperty === 'baz'"), sTrue); + m_myObject->setStringProperty(QLatin1String("zab")); + QCOMPARE(evalJS("myObject.stringProperty === 'zab'"), sTrue); + + // property change in script should be reflected in C++ + QCOMPARE(evalJS("myObject.intProperty = 123"), QLatin1String("123")); + QCOMPARE(evalJS("myObject.intProperty == 123"), sTrue); + QCOMPARE(m_myObject->intProperty(), 123); + QCOMPARE(evalJS("myObject.intProperty = 'ciao!';" + "myObject.intProperty == 0"), sTrue); + QCOMPARE(m_myObject->intProperty(), 0); + QCOMPARE(evalJS("myObject.intProperty = '123';" + "myObject.intProperty == 123"), sTrue); + QCOMPARE(m_myObject->intProperty(), 123); + + QCOMPARE(evalJS("myObject.stringProperty = 'ciao'"), QLatin1String("ciao")); + QCOMPARE(evalJS("myObject.stringProperty"), QLatin1String("ciao")); + QCOMPARE(m_myObject->stringProperty(), QLatin1String("ciao")); + QCOMPARE(evalJS("myObject.stringProperty = 123;" + "myObject.stringProperty"), QLatin1String("123")); + QCOMPARE(m_myObject->stringProperty(), QLatin1String("123")); + QCOMPARE(evalJS("myObject.stringProperty = null"), QString()); + QCOMPARE(evalJS("myObject.stringProperty"), QString()); + QCOMPARE(m_myObject->stringProperty(), QString()); + QCOMPARE(evalJS("myObject.stringProperty = undefined"), sUndefined); + QCOMPARE(evalJS("myObject.stringProperty"), QString()); + QCOMPARE(m_myObject->stringProperty(), QString()); + + QCOMPARE(evalJS("myObject.variantProperty = new Number(1234);" + "myObject.variantProperty").toDouble(), 1234.0); + QCOMPARE(m_myObject->variantProperty().toDouble(), 1234.0); + + QCOMPARE(evalJS("myObject.variantProperty = new Boolean(1234);" + "myObject.variantProperty"), sTrue); + QCOMPARE(m_myObject->variantProperty().toBool(), true); + + QCOMPARE(evalJS("myObject.variantProperty = null;" + "myObject.variantProperty.valueOf()"), sUndefined); + QCOMPARE(m_myObject->variantProperty(), QVariant()); + QCOMPARE(evalJS("myObject.variantProperty = undefined;" + "myObject.variantProperty.valueOf()"), sUndefined); + QCOMPARE(m_myObject->variantProperty(), QVariant()); + + QCOMPARE(evalJS("myObject.variantProperty = 'foo';" + "myObject.variantProperty.valueOf()"), QLatin1String("foo")); + QCOMPARE(m_myObject->variantProperty(), QVariant(QLatin1String("foo"))); + QCOMPARE(evalJS("myObject.variantProperty = 42;" + "myObject.variantProperty").toDouble(), 42.0); + QCOMPARE(m_myObject->variantProperty().toDouble(), 42.0); + + QCOMPARE(evalJS("myObject.variantListProperty = [1, 'two', true];" + "myObject.variantListProperty.length == 3"), sTrue); + QCOMPARE(evalJS("myObject.variantListProperty[0] === 1"), sTrue); + QCOMPARE(evalJS("myObject.variantListProperty[1]"), QLatin1String("two")); + QCOMPARE(evalJS("myObject.variantListProperty[2] === true"), sTrue); + + QCOMPARE(evalJS("myObject.stringListProperty = [1, 'two', true];" + "myObject.stringListProperty.length == 3"), sTrue); + QCOMPARE(evalJS("typeof myObject.stringListProperty[0]"), sString); + QCOMPARE(evalJS("myObject.stringListProperty[0] == '1'"), sTrue); + QCOMPARE(evalJS("typeof myObject.stringListProperty[1]"), sString); + QCOMPARE(evalJS("myObject.stringListProperty[1]"), QLatin1String("two")); + QCOMPARE(evalJS("typeof myObject.stringListProperty[2]"), sString); + QCOMPARE(evalJS("myObject.stringListProperty[2]"), QLatin1String("true")); + evalJS("myObject.webElementProperty=document.body;"); + QCOMPARE(evalJS("myObject.webElementProperty.tagName"), QLatin1String("BODY")); + + // try to delete + QCOMPARE(evalJS("delete myObject.intProperty"), sFalse); + QCOMPARE(evalJS("myObject.intProperty == 123"), sTrue); + + QCOMPARE(evalJS("delete myObject.variantProperty"), sFalse); + QCOMPARE(evalJS("myObject.variantProperty").toDouble(), 42.0); + + // custom property + QCOMPARE(evalJS("myObject.customProperty"), sUndefined); + QCOMPARE(evalJS("myObject.customProperty = 123;" + "myObject.customProperty == 123"), sTrue); + QVariant v = m_page->mainFrame()->evaluateJavaScript("myObject.customProperty"); + QCOMPARE(v.type(), QVariant::Double); + QCOMPARE(v.toInt(), 123); + + // non-scriptable property + QCOMPARE(m_myObject->hiddenProperty(), 456.0); + QCOMPARE(evalJS("myObject.hiddenProperty"), sUndefined); + QCOMPARE(evalJS("myObject.hiddenProperty = 123;" + "myObject.hiddenProperty == 123"), sTrue); + QCOMPARE(m_myObject->hiddenProperty(), 456.0); + + // write-only property + QCOMPARE(m_myObject->writeOnlyProperty(), 789); + QCOMPARE(evalJS("typeof myObject.writeOnlyProperty"), sUndefined); + QCOMPARE(evalJS("myObject.writeOnlyProperty = 123;" + "typeof myObject.writeOnlyProperty"), sUndefined); + QCOMPARE(m_myObject->writeOnlyProperty(), 123); + + // read-only property + QCOMPARE(m_myObject->readOnlyProperty(), 987); + QCOMPARE(evalJS("myObject.readOnlyProperty == 987"), sTrue); + QCOMPARE(evalJS("myObject.readOnlyProperty = 654;" + "myObject.readOnlyProperty == 987"), sTrue); + QCOMPARE(m_myObject->readOnlyProperty(), 987); + + // QObject* property + m_myObject->setObjectStarProperty(0); + QCOMPARE(m_myObject->objectStarProperty(), (QObject*)0); + QCOMPARE(evalJS("myObject.objectStarProperty == null"), sTrue); + QCOMPARE(evalJS("typeof myObject.objectStarProperty"), sObject); + QCOMPARE(evalJS("Boolean(myObject.objectStarProperty)"), sFalse); + QCOMPARE(evalJS("String(myObject.objectStarProperty) == 'null'"), sTrue); + QCOMPARE(evalJS("myObject.objectStarProperty.objectStarProperty"), + sUndefined); + m_myObject->setObjectStarProperty(this); + QCOMPARE(evalJS("myObject.objectStarProperty != null"), sTrue); + QCOMPARE(evalJS("typeof myObject.objectStarProperty"), sObject); + QCOMPARE(evalJS("Boolean(myObject.objectStarProperty)"), sTrue); + QCOMPARE(evalJS("String(myObject.objectStarProperty) != 'null'"), sTrue); +} + +void tst_QObjectBridge::getSetDynamicProperty() +{ + // initially the object does not have the property + // In WebKit, RuntimeObjects do not inherit Object, so don't have hasOwnProperty + + // QCOMPARE(evalJS("myObject.hasOwnProperty('dynamicProperty')"), sFalse); + QCOMPARE(evalJS("typeof myObject.dynamicProperty"), sUndefined); + + // add a dynamic property in C++ + QCOMPARE(m_myObject->setProperty("dynamicProperty", 123), false); + // QCOMPARE(evalJS("myObject.hasOwnProperty('dynamicProperty')"), sTrue); + QCOMPARE(evalJS("typeof myObject.dynamicProperty != 'undefined'"), sTrue); + QCOMPARE(evalJS("myObject.dynamicProperty == 123"), sTrue); + + // property change in script should be reflected in C++ + QCOMPARE(evalJS("myObject.dynamicProperty = 'foo';" + "myObject.dynamicProperty"), QLatin1String("foo")); + QCOMPARE(m_myObject->property("dynamicProperty").toString(), QLatin1String("foo")); + + // delete the property (XFAIL - can't delete properties) + QEXPECT_FAIL("", "can't delete properties", Continue); + QCOMPARE(evalJS("delete myObject.dynamicProperty"), sTrue); + /* + QCOMPARE(m_myObject->property("dynamicProperty").isValid(), false); + QCOMPARE(evalJS("typeof myObject.dynamicProperty"), sUndefined); + // QCOMPARE(evalJS("myObject.hasOwnProperty('dynamicProperty')"), sFalse); + QCOMPARE(evalJS("typeof myObject.dynamicProperty"), sUndefined); + */ +} + +void tst_QObjectBridge::getSetChildren() +{ + // initially the object does not have the child + // (again, no hasOwnProperty) + + // QCOMPARE(evalJS("myObject.hasOwnProperty('child')"), sFalse); + QCOMPARE(evalJS("typeof myObject.child"), sUndefined); + + // add a child + MyQObject* child = new MyQObject(m_myObject); + child->setObjectName("child"); +// QCOMPARE(evalJS("myObject.hasOwnProperty('child')"), sTrue); + QCOMPARE(evalJS("typeof myObject.child != 'undefined'"), sTrue); + + // add a grandchild + MyQObject* grandChild = new MyQObject(child); + grandChild->setObjectName("grandChild"); +// QCOMPARE(evalJS("myObject.child.hasOwnProperty('grandChild')"), sTrue); + QCOMPARE(evalJS("typeof myObject.child.grandChild != 'undefined'"), sTrue); + + // delete grandchild + delete grandChild; +// QCOMPARE(evalJS("myObject.child.hasOwnProperty('grandChild')"), sFalse); + QCOMPARE(evalJS("typeof myObject.child.grandChild == 'undefined'"), sTrue); + + // delete child + delete child; +// QCOMPARE(evalJS("myObject.hasOwnProperty('child')"), sFalse); + QCOMPARE(evalJS("typeof myObject.child == 'undefined'"), sTrue); +} + +Q_DECLARE_METATYPE(QVector) +Q_DECLARE_METATYPE(QVector) +Q_DECLARE_METATYPE(QVector) + +void tst_QObjectBridge::callQtInvokable() +{ + qRegisterMetaType(); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokable()"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 0); + QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList()); + + // extra arguments should silently be ignored + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokable(10, 20, 30)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 0); + QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList()); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArg(123)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArg('123')"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithLonglongArg(123)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 2); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toLongLong(), qlonglong(123)); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithFloatArg(123.5)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 3); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.5); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithDoubleArg(123.5)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 4); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.5); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithDoubleArg(new Number(1234.5))"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 4); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 1234.5); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithBoolArg(new Boolean(true))"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 52); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toBool(), true); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithStringArg('ciao')"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 5); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("ciao")); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithStringArg(123)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 5); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("123")); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithStringArg(null)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 5); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QString()); + QVERIFY(m_myObject->qtFunctionActuals().at(0).toString().isEmpty()); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithStringArg(undefined)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 5); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QString()); + QVERIFY(m_myObject->qtFunctionActuals().at(0).toString().isEmpty()); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArgs(123, 456)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 6); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 2); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); + QCOMPARE(m_myObject->qtFunctionActuals().at(1).toInt(), 456); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("myObject.myInvokableReturningInt()"), QLatin1String("123")); + QCOMPARE(m_myObject->qtFunctionInvoked(), 7); + QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList()); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("myObject.myInvokableReturningLongLong()"), QLatin1String("456")); + QCOMPARE(m_myObject->qtFunctionInvoked(), 39); + QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList()); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("myObject.myInvokableReturningString()"), QLatin1String("ciao")); + QCOMPARE(m_myObject->qtFunctionInvoked(), 8); + QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList()); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArg(123, 456)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 9); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 2); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); + QCOMPARE(m_myObject->qtFunctionActuals().at(1).toInt(), 456); + + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("typeof myObject.myInvokableWithVoidStarArg(null)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 44); + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QString ret = evalJS("myObject.myInvokableWithVoidStarArg(123)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: incompatible type of argument(s) in call to myInvokableWithVoidStarArg(); candidates were\n myInvokableWithVoidStarArg(void*)")); + QCOMPARE(m_myObject->qtFunctionInvoked(), -1); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QString ret = evalJS("myObject.myInvokableWithAmbiguousArg(123)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: ambiguous call of overloaded function myInvokableWithAmbiguousArg(); candidates were\n myInvokableWithAmbiguousArg(int)\n myInvokableWithAmbiguousArg(uint)")); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QString ret = evalJS("myObject.myInvokableWithDefaultArgs(123, 'hello')", type); + QCOMPARE(type, sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 47); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 2); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); + QCOMPARE(m_myObject->qtFunctionActuals().at(1).toString(), QLatin1String("hello")); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QString ret = evalJS("myObject.myInvokableWithDefaultArgs(456)", type); + QCOMPARE(type, sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 47); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 2); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456); + QCOMPARE(m_myObject->qtFunctionActuals().at(1).toString(), QString()); + } + + // calling function that returns (const)ref + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QString ret = evalJS("typeof myObject.myInvokableReturningRef()"); + QCOMPARE(ret, sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 48); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QString ret = evalJS("typeof myObject.myInvokableReturningConstRef()"); + QCOMPARE(ret, sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 49); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QVariant ret = evalJSV("myObject.myInvokableReturningQObjectStar()", type); + QCOMPARE(m_myObject->qtFunctionInvoked(), 13); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 0); + QCOMPARE(type, sObject); + QCOMPARE(ret.userType(), int(QMetaType::QObjectStar)); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QVariant ret = evalJSV("myObject.myInvokableWithQObjectListArg([myObject])", type); + QCOMPARE(m_myObject->qtFunctionInvoked(), 14); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(type, sArray); + QCOMPARE(ret.userType(), int(QVariant::List)); // All lists get downgraded to QVariantList + QVariantList vl = qvariant_cast(ret); + QCOMPARE(vl.count(), 1); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + m_myObject->setVariantProperty(QVariant(123)); + QVariant ret = evalJSV("myObject.myInvokableWithVariantArg(myObject.variantProperty)", type); + QCOMPARE(type, sNumber); + QCOMPARE(m_myObject->qtFunctionInvoked(), 15); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0), m_myObject->variantProperty()); + QCOMPARE(ret.userType(), int(QMetaType::Double)); // all JS numbers are doubles, even though this started as an int + QCOMPARE(ret.toInt(), 123); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QVariant ret = evalJSV("myObject.myInvokableWithVariantArg(null)", type); + QCOMPARE(type, sObject); + QCOMPARE(m_myObject->qtFunctionInvoked(), 15); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant()); + QVERIFY(!m_myObject->qtFunctionActuals().at(0).isValid()); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QVariant ret = evalJSV("myObject.myInvokableWithVariantArg(undefined)", type); + QCOMPARE(type, sObject); + QCOMPARE(m_myObject->qtFunctionInvoked(), 15); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant()); + QVERIFY(!m_myObject->qtFunctionActuals().at(0).isValid()); + } + + /* XFAIL - variant support + m_myObject->resetQtFunctionInvoked(); + { + m_myObject->setVariantProperty(QVariant::fromValue(QBrush())); + QVariant ret = evalJS("myObject.myInvokableWithVariantArg(myObject.variantProperty)"); + QVERIFY(ret.isVariant()); + QCOMPARE(m_myObject->qtFunctionInvoked(), 15); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(ret.toVariant(), m_myObject->qtFunctionActuals().at(0)); + QCOMPARE(ret.toVariant(), m_myObject->variantProperty()); + } + */ + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QVariant ret = evalJSV("myObject.myInvokableWithVariantArg(123)", type); + QCOMPARE(type, sNumber); + QCOMPARE(m_myObject->qtFunctionInvoked(), 15); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant(123)); + QCOMPARE(ret.userType(), int(QMetaType::Double)); + QCOMPARE(ret.toInt(), 123); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QVariant ret = evalJSV("myObject.myInvokableWithVariantMapArg({ a:123, b:'ciao' })", type); + QCOMPARE(m_myObject->qtFunctionInvoked(), 16); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + + QVariant v = m_myObject->qtFunctionActuals().at(0); + QCOMPARE(v.userType(), int(QMetaType::QVariantMap)); + + QVariantMap vmap = qvariant_cast(v); + QCOMPARE(vmap.keys().size(), 2); + QCOMPARE(vmap.keys().at(0), QLatin1String("a")); + QCOMPARE(vmap.value("a"), QVariant(123)); + QCOMPARE(vmap.keys().at(1), QLatin1String("b")); + QCOMPARE(vmap.value("b"), QVariant("ciao")); + + QCOMPARE(type, sObject); + + QCOMPARE(ret.userType(), int(QMetaType::QVariantMap)); + vmap = qvariant_cast(ret); + QCOMPARE(vmap.keys().size(), 2); + QCOMPARE(vmap.keys().at(0), QLatin1String("a")); + QCOMPARE(vmap.value("a"), QVariant(123)); + QCOMPARE(vmap.keys().at(1), QLatin1String("b")); + QCOMPARE(vmap.value("b"), QVariant("ciao")); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QVariant ret = evalJSV("myObject.myInvokableWithListOfIntArg([1, 5])", type); + QCOMPARE(m_myObject->qtFunctionInvoked(), 17); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QVariant v = m_myObject->qtFunctionActuals().at(0); + QCOMPARE(v.userType(), qMetaTypeId >()); + QList ilst = qvariant_cast >(v); + QCOMPARE(ilst.size(), 2); + QCOMPARE(ilst.at(0), 1); + QCOMPARE(ilst.at(1), 5); + + QCOMPARE(type, sArray); + QCOMPARE(ret.userType(), int(QMetaType::QVariantList)); // ints get converted to doubles, so this is a qvariantlist + QVariantList vlst = qvariant_cast(ret); + QCOMPARE(vlst.size(), 2); + QCOMPARE(vlst.at(0).toInt(), 1); + QCOMPARE(vlst.at(1).toInt(), 5); + } + + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QVariant ret = evalJSV("myObject.myInvokableWithQObjectStarArg(myObject)", type); + QCOMPARE(m_myObject->qtFunctionInvoked(), 18); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QVariant v = m_myObject->qtFunctionActuals().at(0); + QCOMPARE(v.userType(), int(QMetaType::QObjectStar)); + QCOMPARE(qvariant_cast(v), (QObject*)m_myObject); + + QCOMPARE(ret.userType(), int(QMetaType::QObjectStar)); + QCOMPARE(qvariant_cast(ret), (QObject*)m_myObject); + + QCOMPARE(type, sObject); + } + + m_myObject->resetQtFunctionInvoked(); + { + // no implicit conversion from integer to QObject* + QString type; + evalJS("myObject.myInvokableWithQObjectStarArg(123)", type); + QCOMPARE(type, sError); + } + + /* + m_myObject->resetQtFunctionInvoked(); + { + QString fun = evalJS("myObject.myInvokableWithQBrushArg"); + Q_ASSERT(fun.isFunction()); + QColor color(10, 20, 30, 40); + // QColor should be converted to a QBrush + QVariant ret = fun.call(QString(), QStringList() + << qScriptValueFromValue(m_engine, color)); + QCOMPARE(m_myObject->qtFunctionInvoked(), 19); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QVariant v = m_myObject->qtFunctionActuals().at(0); + QCOMPARE(v.userType(), int(QMetaType::QBrush)); + QCOMPARE(qvariant_cast(v), color); + + QCOMPARE(qscriptvalue_cast(ret), color); + } + */ + + // private slots should not be part of the QObject binding + QCOMPARE(evalJS("typeof myObject.myPrivateSlot"), sUndefined); + + // protected slots should be fine + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myProtectedSlot()"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 36); + + // call with too few arguments + { + QString type; + QString ret = evalJS("myObject.myInvokableWithIntArg()", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: too few arguments in call to myInvokableWithIntArg(); candidates are\n myInvokableWithIntArg(int,int)\n myInvokableWithIntArg(int)")); + } + + // call function where not all types have been registered + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QString ret = evalJS("myObject.myInvokableWithBrushStyleArg(0)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: cannot call myInvokableWithBrushStyleArg(): unknown type `Qt::BrushStyle'")); + QCOMPARE(m_myObject->qtFunctionInvoked(), -1); + } + + // call function with incompatible argument type + m_myObject->resetQtFunctionInvoked(); + { + QString type; + QString ret = evalJS("myObject.myInvokableWithQBrushArg(null)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: incompatible type of argument(s) in call to myInvokableWithQBrushArg(); candidates were\n myInvokableWithQBrushArg(QBrush)")); + QCOMPARE(m_myObject->qtFunctionInvoked(), -1); + } +} + +void tst_QObjectBridge::connectAndDisconnect() +{ + // connect(function) + QCOMPARE(evalJS("typeof myObject.mySignal"), sFunction); + QCOMPARE(evalJS("typeof myObject.mySignal.connect"), sFunction); + QCOMPARE(evalJS("typeof myObject.mySignal.disconnect"), sFunction); + + { + QString type; + evalJS("myObject.mySignal.connect(123)", type); + QCOMPARE(type, sError); + } + + evalJS("myHandler = function() { window.gotSignal = true; window.signalArgs = arguments; window.slotThisObject = this; }"); + + QCOMPARE(evalJS("myObject.mySignal.connect(myHandler)"), sUndefined); + + evalJS("gotSignal = false"); + evalJS("myObject.mySignal()"); + QCOMPARE(evalJS("gotSignal"), sTrue); + QCOMPARE(evalJS("signalArgs.length == 0"), sTrue); + QCOMPARE(evalJS("slotThisObject == window"), sTrue); + + evalJS("gotSignal = false"); + m_myObject->emitMySignal(); + QCOMPARE(evalJS("gotSignal"), sTrue); + QCOMPARE(evalJS("signalArgs.length == 0"), sTrue); + + QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myHandler)"), sUndefined); + + evalJS("gotSignal = false"); + m_myObject->emitMySignalWithIntArg(123); + QCOMPARE(evalJS("gotSignal"), sTrue); + QCOMPARE(evalJS("signalArgs.length == 1"), sTrue); + QCOMPARE(evalJS("signalArgs[0] == 123.0"), sTrue); + + QCOMPARE(evalJS("myObject.mySignal.disconnect(myHandler)"), sUndefined); + { + QString type; + evalJS("myObject.mySignal.disconnect(myHandler)", type); + QCOMPARE(type, sError); + } + + evalJS("gotSignal = false"); + QCOMPARE(evalJS("myObject.mySignal2.connect(myHandler)"), sUndefined); + m_myObject->emitMySignal2(true); + QCOMPARE(evalJS("gotSignal"), sTrue); + QCOMPARE(evalJS("signalArgs.length == 1"), sTrue); + QCOMPARE(evalJS("signalArgs[0]"), sTrue); + + QCOMPARE(evalJS("myObject.mySignal2.disconnect(myHandler)"), sUndefined); + + QCOMPARE(evalJS("typeof myObject['mySignal2()']"), sFunction); + QCOMPARE(evalJS("typeof myObject['mySignal2()'].connect"), sFunction); + QCOMPARE(evalJS("typeof myObject['mySignal2()'].disconnect"), sFunction); + + QCOMPARE(evalJS("myObject['mySignal2()'].connect(myHandler)"), sUndefined); + + evalJS("gotSignal = false"); + m_myObject->emitMySignal2(); + QCOMPARE(evalJS("gotSignal"), sTrue); + + QCOMPARE(evalJS("myObject['mySignal2()'].disconnect(myHandler)"), sUndefined); + + // connect(object, function) + evalJS("otherObject = { name:'foo' }"); + QCOMPARE(evalJS("myObject.mySignal.connect(otherObject, myHandler)"), sUndefined); + QCOMPARE(evalJS("myObject.mySignal.disconnect(otherObject, myHandler)"), sUndefined); + evalJS("gotSignal = false"); + m_myObject->emitMySignal(); + QCOMPARE(evalJS("gotSignal"), sFalse); + + { + QString type; + evalJS("myObject.mySignal.disconnect(otherObject, myHandler)", type); + QCOMPARE(type, sError); + } + + QCOMPARE(evalJS("myObject.mySignal.connect(otherObject, myHandler)"), sUndefined); + evalJS("gotSignal = false"); + m_myObject->emitMySignal(); + QCOMPARE(evalJS("gotSignal"), sTrue); + QCOMPARE(evalJS("signalArgs.length == 0"), sTrue); + QCOMPARE(evalJS("slotThisObject"), evalJS("otherObject")); + QCOMPARE(evalJS("slotThisObject.name"), QLatin1String("foo")); + QCOMPARE(evalJS("myObject.mySignal.disconnect(otherObject, myHandler)"), sUndefined); + + evalJS("yetAnotherObject = { name:'bar', func : function() { } }"); + QCOMPARE(evalJS("myObject.mySignal2.connect(yetAnotherObject, myHandler)"), sUndefined); + evalJS("gotSignal = false"); + m_myObject->emitMySignal2(true); + QCOMPARE(evalJS("gotSignal"), sTrue); + QCOMPARE(evalJS("signalArgs.length == 1"), sTrue); + QCOMPARE(evalJS("slotThisObject == yetAnotherObject"), sTrue); + QCOMPARE(evalJS("slotThisObject.name"), QLatin1String("bar")); + QCOMPARE(evalJS("myObject.mySignal2.disconnect(yetAnotherObject, myHandler)"), sUndefined); + + QCOMPARE(evalJS("myObject.mySignal2.connect(myObject, myHandler)"), sUndefined); + evalJS("gotSignal = false"); + m_myObject->emitMySignal2(true); + QCOMPARE(evalJS("gotSignal"), sTrue); + QCOMPARE(evalJS("signalArgs.length == 1"), sTrue); + QCOMPARE(evalJS("slotThisObject == myObject"), sTrue); + QCOMPARE(evalJS("myObject.mySignal2.disconnect(myObject, myHandler)"), sUndefined); + + // connect(obj, string) + { + QString type; + QCOMPARE(evalJS("myObject.mySignal.connect(yetAnotherObject, 'func')", type), sUndefined); + QCOMPARE(evalJS("myObject.mySignal.connect(myObject, 'mySlot')", type), sUndefined); + QCOMPARE(evalJS("myObject.mySignal.disconnect(yetAnotherObject, 'func')", type), sUndefined); + QCOMPARE(evalJS("myObject.mySignal.disconnect(myObject, 'mySlot')", type), sUndefined); + } + + // check that emitting signals from script works + + // no arguments + QCOMPARE(evalJS("myObject.mySignal.connect(myObject.mySlot)"), sUndefined); + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("myObject.mySignal()"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 20); + QCOMPARE(evalJS("myObject.mySignal.disconnect(myObject.mySlot)"), sUndefined); + + // one argument + QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.mySlotWithIntArg)"), sUndefined); + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 21); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); + QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithIntArg)"), sUndefined); + + QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.mySlotWithDoubleArg)"), sUndefined); + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 22); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.0); + QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithDoubleArg)"), sUndefined); + + QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.mySlotWithStringArg)"), sUndefined); + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 23); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("123")); + QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithStringArg)"), sUndefined); + + // connecting to overloaded slot + QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.myOverloadedSlot)"), sUndefined); + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 26); // double overload + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123); + QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.myOverloadedSlot)"), sUndefined); + + QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject['myOverloadedSlot(int)'])"), sUndefined); + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("myObject.mySignalWithIntArg(456)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 28); // int overload + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456); + QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject['myOverloadedSlot(int)'])"), sUndefined); + + QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject, 'myOverloadedSlot(int)')"), sUndefined); + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("myObject.mySignalWithIntArg(456)"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 28); // int overload + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456); + QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject, 'myOverloadedSlot(int)')"), sUndefined); + + // erroneous input +#define NOT_A_FUNCTION(f, expr) \ + "TypeError: " f " is not a function. (In '" expr "', '" f "' is undefined)" + + { + // ### QtScript adds .connect to all functions, WebKit does only to signals/slots + QString type; + QString ret = evalJS("(function() { }).connect()", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String(NOT_A_FUNCTION("(function() { }).connect", "(function() { }).connect()"))); + } + { + QString type; + QString ret = evalJS("var o = { }; o.connect = Function.prototype.connect; o.connect()", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String(NOT_A_FUNCTION("o.connect", "o.connect()"))); + } + + { + QString type; + QString ret = evalJS("(function() { }).connect(123)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String(NOT_A_FUNCTION("(function() { }).connect", "(function() { }).connect(123)"))); + } + { + QString type; + QString ret = evalJS("var o = { }; o.connect = Function.prototype.connect; o.connect(123)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String(NOT_A_FUNCTION("o.connect", "o.connect(123)"))); + } + + { + QString type; + QString ret = evalJS("myObject.myInvokable.connect(123)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.connect: MyQObject::myInvokable() is not a signal")); + } + { + QString type; + QString ret = evalJS("myObject.myInvokable.connect(function() { })", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.connect: MyQObject::myInvokable() is not a signal")); + } + + { + QString type; + QString ret = evalJS("myObject.mySignal.connect(123)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.connect: target is not a function")); + } + + { + QString type; + QString ret = evalJS("var randomObject = new Object; myObject.mySignal.connect(myObject, randomObject)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.connect: target is not a function")); + } + + { + QString type; + QString ret = evalJS("myObject.mySignal.connect(myObject, 'nonExistantSlot')", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.connect: target is not a function")); + } + + { + QString type; + QString ret = evalJS("myObject.mySignal.disconnect()", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: no arguments given")); + } + { + QString type; + QString ret = evalJS("var o = { }; o.disconnect = myObject.mySignal.disconnect; o.disconnect()", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: no arguments given")); + } + + { + QString type; + QString ret = evalJS("myObject.mySignal.disconnect(myObject, 'nonExistantSlot')", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: target is not a function")); + } + + /* XFAIL - Function.prototype doesn't get connect/disconnect, just signals/slots + { + QString type; + QString ret = evalJS("(function() { }).disconnect(123)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("TypeError: QtMetaMethod.disconnect: this object is not a signal")); + } + */ + + { + QString type; + QString ret = evalJS("var o = { }; o.disconnect = myObject.myInvokable.disconnect; o.disconnect(123)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: MyQObject::myInvokable() is not a signal")); + } + + { + QString type; + QString ret = evalJS("myObject.myInvokable.disconnect(123)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: MyQObject::myInvokable() is not a signal")); + } + { + QString type; + QString ret = evalJS("myObject.myInvokable.disconnect(function() { })", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: MyQObject::myInvokable() is not a signal")); + } + + { + QString type; + QString ret = evalJS("myObject.mySignal.disconnect(123)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: target is not a function")); + } + + { + QString type; + QString ret = evalJS("myObject.mySignal.disconnect(function() { })", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: failed to disconnect from MyQObject::mySignal()")); + } + + // when the wrapper dies, the connection stays alive + QCOMPARE(evalJS("myObject.mySignal.connect(myObject.mySlot)"), sUndefined); + m_myObject->resetQtFunctionInvoked(); + m_myObject->emitMySignal(); + QCOMPARE(m_myObject->qtFunctionInvoked(), 20); + evalJS("myObject = null"); + evalJS("gc()"); + m_myObject->resetQtFunctionInvoked(); + m_myObject->emitMySignal(); + QCOMPARE(m_myObject->qtFunctionInvoked(), 20); +} + +void tst_QObjectBridge::overrideInvokable() +{ + m_myObject->resetQtFunctionInvoked(); + QCOMPARE(evalJS("myObject.myInvokable()"), sUndefined); + QCOMPARE(m_myObject->qtFunctionInvoked(), 0); + + /* XFAIL - can't write to functions with RuntimeObject + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myInvokable = function() { window.a = 123; }"); + evalJS("myObject.myInvokable()"); + QCOMPARE(m_myObject->qtFunctionInvoked(), -1); + QCOMPARE(evalJS("window.a").toDouble(), 123.0); + + evalJS("myObject.myInvokable = function() { window.a = 456; }"); + evalJS("myObject.myInvokable()"); + QCOMPARE(m_myObject->qtFunctionInvoked(), -1); + QCOMPARE(evalJS("window.a").toDouble(), 456.0); + */ + + evalJS("delete myObject.myInvokable"); + evalJS("myObject.myInvokable()"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 0); + + /* XFAIL - ditto + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myInvokable = myObject.myInvokableWithIntArg"); + evalJS("myObject.myInvokable(123)"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 1); + */ + + evalJS("delete myObject.myInvokable"); + m_myObject->resetQtFunctionInvoked(); + // this form (with the '()') is read-only + evalJS("myObject['myInvokable()'] = function() { window.a = 123; }"); + evalJS("myObject.myInvokable()"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 0); +} + +void tst_QObjectBridge::overloadedSlots() +{ + // should pick myOverloadedSlot(double) + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myOverloadedSlot(10)"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 26); + + // should pick myOverloadedSlot(double) + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myOverloadedSlot(10.0)"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 26); + + // should pick myOverloadedSlot(QString) + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myOverloadedSlot('10')"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 29); + + // should pick myOverloadedSlot(bool) + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myOverloadedSlot(true)"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 25); + + // should pick myOverloadedSlot(QDateTime) + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myOverloadedSlot(new Date())"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 32); + + // should pick myOverloadedSlot(QVariant) + /* XFAIL + m_myObject->resetQtFunctionInvoked(); + QString f = evalJS("myObject.myOverloadedSlot"); + f.call(QString(), QStringList() << m_engine->newVariant(QVariant("ciao"))); + QCOMPARE(m_myObject->qtFunctionInvoked(), 35); + */ + + // Should pick myOverloadedSlot(QWebElement). + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myOverloadedSlot(document.body)"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 36); + + // should pick myOverloadedSlot(QObject*) + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myOverloadedSlot(myObject)"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 41); + + // should pick myOverloadedSlot(QObject*) + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myOverloadedSlot(null)"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 41); + + // should pick myOverloadedSlot(QStringList) + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myOverloadedSlot(['hello'])"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 42); +} + +class MyEnumTestQObject : public QObject { + Q_OBJECT + Q_PROPERTY(QString p1 READ p1) + Q_PROPERTY(QString p2 READ p2) + Q_PROPERTY(QString p3 READ p3 SCRIPTABLE false) + Q_PROPERTY(QString p4 READ p4) + Q_PROPERTY(QString p5 READ p5 SCRIPTABLE false) + Q_PROPERTY(QString p6 READ p6) +public: + MyEnumTestQObject(QObject* parent = 0) + : QObject(parent) { } + + QString p1() const { return QLatin1String("p1"); } + QString p2() const { return QLatin1String("p2"); } + QString p3() const { return QLatin1String("p3"); } + QString p4() const { return QLatin1String("p4"); } + QString p5() const { return QLatin1String("p5"); } + QString p6() const { return QLatin1String("p6"); } + +public Q_SLOTS: + void mySlot() { } + void myOtherSlot() { } +Q_SIGNALS: + void mySignal(); +}; + +void tst_QObjectBridge::enumerate_data() +{ + QTest::addColumn("expectedNames"); + + QTest::newRow("enumerate all") + << (QStringList() + // meta-object-defined properties: + // inherited + << "objectName" + // non-inherited + << "p1" << "p2" << "p4" << "p6" + // dynamic properties + << "dp1" << "dp2" << "dp3" + // inherited signals and slots + << "destroyed(QObject*)" << "destroyed()" + << "objectNameChanged(QString)" + << "deleteLater()" + // not included because it's private: + // << "_q_reregisterTimers(void*)" + // signals + << "mySignal()" + // slots + << "mySlot()" << "myOtherSlot()"); +} + +void tst_QObjectBridge::enumerate() +{ + QFETCH(QStringList, expectedNames); + + MyEnumTestQObject enumQObject; + // give it some dynamic properties + enumQObject.setProperty("dp1", "dp1"); + enumQObject.setProperty("dp2", "dp2"); + enumQObject.setProperty("dp3", "dp3"); + m_page->mainFrame()->addToJavaScriptWindowObject("myEnumObject", &enumQObject); + + // enumerate in script + { + evalJS("var enumeratedProperties = []"); + evalJS("for (var p in myEnumObject) { enumeratedProperties.push(p); }"); + QStringList result = evalJSV("enumeratedProperties").toStringList(); + QCOMPARE(result.size(), expectedNames.size()); + for (int i = 0; i < expectedNames.size(); ++i) + QCOMPARE(result.at(i), expectedNames.at(i)); + } +} + +void tst_QObjectBridge::objectDeleted() +{ + MyQObject* qobj = new MyQObject(); + m_page->mainFrame()->addToJavaScriptWindowObject("bar", qobj); + evalJS("bar.objectName = 'foo';"); + QCOMPARE(qobj->objectName(), QLatin1String("foo")); + evalJS("bar.intProperty = 123;"); + QCOMPARE(qobj->intProperty(), 123); + qobj->resetQtFunctionInvoked(); + evalJS("bar.myInvokable.call(bar);"); + QCOMPARE(qobj->qtFunctionInvoked(), 0); + + // do this, to ensure that we cache that it implements call + evalJS("bar()"); + + // now delete the object + delete qobj; + + QCOMPARE(evalJS("typeof bar"), sObject); + + // any attempt to access properties of the object should result in an exception + { + QString type; + QString ret = evalJS("bar.objectName", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: cannot access member `objectName' of deleted QObject")); + } + { + QString type; + QString ret = evalJS("bar.objectName = 'foo'", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: cannot access member `objectName' of deleted QObject")); + } + + // myInvokable is stored in member table (since we've accessed it before deletion) + { + QString type; + evalJS("bar.myInvokable", type); + QCOMPARE(type, sFunction); + } + + { + QString type; + QString ret = evalJS("bar.myInvokable.call(bar);", type); + ret = evalJS("bar.myInvokable(bar)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: cannot call function of deleted QObject")); + } + // myInvokableWithIntArg is not stored in member table (since we've not accessed it) + { + QString type; + QString ret = evalJS("bar.myInvokableWithIntArg", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: cannot access member `myInvokableWithIntArg' of deleted QObject")); + } + + // access from script + evalJS("window.o = bar;"); + { + QString type; + QString ret = evalJS("o.objectName", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: cannot access member `objectName' of deleted QObject")); + } + { + QString type; + QString ret = evalJS("o.myInvokable()", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: cannot call function of deleted QObject")); + } + { + QString type; + QString ret = evalJS("o.myInvokableWithIntArg(10)", type); + QCOMPARE(type, sError); + QCOMPARE(ret, QLatin1String("Error: cannot access member `myInvokableWithIntArg' of deleted QObject")); + } +} + +void tst_QObjectBridge::typeConversion() +{ + m_myObject->resetQtFunctionInvoked(); + + QDateTime localdt(QDate(2008, 1, 18), QTime(12, 31, 0)); + QDateTime utclocaldt = localdt.toUTC(); + QDateTime utcdt(QDate(2008, 1, 18), QTime(12, 31, 0), Qt::UTC); + + // Dates in JS (default to local) + evalJS("myObject.myOverloadedSlot(new Date(2008,0,18,12,31,0))"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 32); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDateTime().toUTC(), utclocaldt); + + m_myObject->resetQtFunctionInvoked(); + evalJS("myObject.myOverloadedSlot(new Date(Date.UTC(2008,0,18,12,31,0)))"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 32); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDateTime().toUTC(), utcdt); + + // Pushing QDateTimes into JS + // Local + evalJS("function checkDate(d) {window.__date_equals = (d.toString() == new Date(2008,0,18,12,31,0))?true:false;}"); + evalJS("myObject.mySignalWithDateTimeArg.connect(checkDate)"); + m_myObject->emitMySignalWithDateTimeArg(localdt); + QCOMPARE(evalJS("window.__date_equals"), sTrue); + evalJS("delete window.__date_equals"); + m_myObject->emitMySignalWithDateTimeArg(utclocaldt); + QCOMPARE(evalJS("window.__date_equals"), sTrue); + evalJS("delete window.__date_equals"); + evalJS("myObject.mySignalWithDateTimeArg.disconnect(checkDate); delete checkDate;"); + + // UTC + evalJS("function checkDate(d) {window.__date_equals = (d.toString() == new Date(Date.UTC(2008,0,18,12,31,0)))?true:false; }"); + evalJS("myObject.mySignalWithDateTimeArg.connect(checkDate)"); + m_myObject->emitMySignalWithDateTimeArg(utcdt); + QCOMPARE(evalJS("window.__date_equals"), sTrue); + evalJS("delete window.__date_equals"); + evalJS("myObject.mySignalWithDateTimeArg.disconnect(checkDate); delete checkDate;"); +} + +class StringListTestObject : public QObject { + Q_OBJECT +public Q_SLOTS: + QVariant stringList() + { + return QStringList() << "Q" << "t"; + }; +}; + +void tst_QObjectBridge::arrayObjectEnumerable() +{ + QWebPage page; + QWebFrame* frame = page.mainFrame(); + QObject* qobject = new StringListTestObject(); + frame->addToJavaScriptWindowObject("test", qobject, QWebFrame::ScriptOwnership); + + const QString script("var stringArray = test.stringList();" + "var result = '';" + "for (var i in stringArray) {" + " result += stringArray[i];" + "}" + "result;"); + QCOMPARE(frame->evaluateJavaScript(script).toString(), QString::fromLatin1("Qt")); +} + +void tst_QObjectBridge::domCycles() +{ + m_view->setHtml(""); + QVariant v = m_page->mainFrame()->evaluateJavaScript("document"); + QVERIFY(v.type() == QVariant::Map); +} + +void tst_QObjectBridge::jsByteArray() +{ + QByteArray ba("hello world"); + m_myObject->setByteArrayProperty(ba); + + // read-only property + QCOMPARE(m_myObject->byteArrayProperty(), ba); + QString type; + QVariant v = evalJSV("myObject.byteArrayProperty"); + QCOMPARE(int(v.type()), int(QVariant::ByteArray)); + + QCOMPARE(v.toByteArray(), ba); +} + +void tst_QObjectBridge::ownership() +{ + // test ownership + { + QPointer ptr = new QObject(); + QVERIFY(ptr); + { + QWebPage page; + QWebFrame* frame = page.mainFrame(); + frame->addToJavaScriptWindowObject("test", ptr.data(), QWebFrame::ScriptOwnership); + } + QVERIFY(!ptr); + } + { + QPointer ptr = new QObject(); + QVERIFY(ptr); + QObject* before = ptr.data(); + { + QWebPage page; + QWebFrame* frame = page.mainFrame(); + frame->addToJavaScriptWindowObject("test", ptr.data(), QWebFrame::QtOwnership); + } + QVERIFY(ptr.data() == before); + delete ptr.data(); + } + { + QObject* parent = new QObject(); + QObject* child = new QObject(parent); + QWebPage page; + QWebFrame* frame = page.mainFrame(); + frame->addToJavaScriptWindowObject("test", child, QWebFrame::QtOwnership); + QVariant v = frame->evaluateJavaScript("test"); + QCOMPARE(qvariant_cast(v), child); + delete parent; + v = frame->evaluateJavaScript("test"); + QCOMPARE(qvariant_cast(v), (QObject *)0); + } + { + QPointer ptr = new QObject(); + QVERIFY(ptr); + { + QWebPage page; + QWebFrame* frame = page.mainFrame(); + frame->addToJavaScriptWindowObject("test", ptr.data(), QWebFrame::AutoOwnership); + } + // no parent, so it should be like ScriptOwnership + QVERIFY(!ptr); + } + { + QObject* parent = new QObject(); + QPointer child = new QObject(parent); + QVERIFY(child); + { + QWebPage page; + QWebFrame* frame = page.mainFrame(); + frame->addToJavaScriptWindowObject("test", child.data(), QWebFrame::AutoOwnership); + } + // has parent, so it should be like QtOwnership + QVERIFY(child); + delete parent; + } +} + +void tst_QObjectBridge::nullValue() +{ + QVariant v = m_view->page()->mainFrame()->evaluateJavaScript("null"); + QVERIFY(v.isNull()); +} + +class TestFactory : public QObject { + Q_OBJECT +public: + TestFactory() + : obj(0), counter(0) + { } + + Q_INVOKABLE QObject* getNewObject() + { + delete obj; + obj = new QObject(this); + obj->setObjectName(QLatin1String("test") + QString::number(++counter)); + return obj; + + } + + QObject* obj; + int counter; +}; + +void tst_QObjectBridge::qObjectWrapperWithSameIdentity() +{ + m_view->setHtml("" + "test"); + + QWebFrame* mainFrame = m_view->page()->mainFrame(); + QCOMPARE(mainFrame->toPlainText(), QString("test")); + + mainFrame->addToJavaScriptWindowObject("test", new TestFactory, QWebFrame::ScriptOwnership); + + mainFrame->evaluateJavaScript("triggerBug();"); + QCOMPARE(mainFrame->toPlainText(), QString("test1")); + + mainFrame->evaluateJavaScript("triggerBug();"); + QCOMPARE(mainFrame->toPlainText(), QString("test2")); +} + +void tst_QObjectBridge::introspectQtMethods_data() +{ + QTest::addColumn("objectExpression"); + QTest::addColumn("methodName"); + QTest::addColumn("expectedPropertyNames"); + + QTest::newRow("myObject.mySignal") + << "myObject" << "mySignal" << (QStringList() << "connect" << "disconnect" << "name"); + QTest::newRow("myObject.mySlot") + << "myObject" << "mySlot" << (QStringList() << "connect" << "disconnect" << "name"); + QTest::newRow("myObject.myInvokable") + << "myObject" << "myInvokable" << (QStringList() << "connect" << "disconnect" << "name"); + QTest::newRow("myObject.mySignal.connect") + << "myObject.mySignal" << "connect" << (QStringList() << "name"); + QTest::newRow("myObject.mySignal.disconnect") + << "myObject.mySignal" << "disconnect" << (QStringList() << "name"); +} + +void tst_QObjectBridge::introspectQtMethods() +{ + QFETCH(QString, objectExpression); + QFETCH(QString, methodName); + QFETCH(QStringList, expectedPropertyNames); + + QString methodLookup = QString::fromLatin1("%0['%1']").arg(objectExpression).arg(methodName); + QCOMPARE(evalJSV(QString::fromLatin1("Object.getOwnPropertyNames(%0).sort()").arg(methodLookup)).toStringList(), expectedPropertyNames); + + for (int i = 0; i < expectedPropertyNames.size(); ++i) { + QString name = expectedPropertyNames.at(i); + QCOMPARE(evalJS(QString::fromLatin1("%0.hasOwnProperty('%1')").arg(methodLookup).arg(name)), sTrue); + evalJS(QString::fromLatin1("var descriptor = Object.getOwnPropertyDescriptor(%0, '%1')").arg(methodLookup).arg(name)); + QCOMPARE(evalJS("typeof descriptor"), QString::fromLatin1("object")); + QCOMPARE(evalJS("descriptor.get"), sUndefined); + QCOMPARE(evalJS("descriptor.set"), sUndefined); + QCOMPARE(evalJS(QString::fromLatin1("descriptor.value === %0['%1']").arg(methodLookup).arg(name)), sTrue); + QCOMPARE(evalJS(QString::fromLatin1("descriptor.enumerable")), sFalse); + QCOMPARE(evalJS(QString::fromLatin1("descriptor.configurable")), sFalse); + } + + QVERIFY(evalJSV("var props=[]; for (var p in myObject.deleteLater) {props.push(p);}; props.sort()").toStringList().isEmpty()); +} + +void tst_QObjectBridge::webElementSlotOnly() +{ + MyWebElementSlotOnlyObject object; + m_page->mainFrame()->setHtml(""); + m_page->mainFrame()->addToJavaScriptWindowObject("myWebElementSlotObject", &object); + evalJS("myWebElementSlotObject.doSomethingWithWebElement(document.body)"); + QCOMPARE(evalJS("myWebElementSlotObject.tagName"), QString("BODY")); +} + +class TestPluginWidget : public QWidget { + Q_OBJECT +public: + TestPluginWidget() { } + +public Q_SLOTS: + int slotWithReturnValue() { return 42; } +}; + +class TestWebPage : public QWebPage { + Q_OBJECT +public: + TestWebPage(QObject* parent = 0) + : QWebPage(parent) + , creationCount(0) + { } + + int creationCount; + +protected: + virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) + { + creationCount++; + return new TestPluginWidget; + } +}; + +void tst_QObjectBridge::scriptablePlugin() +{ +//#if !PLUGIN_VIEW_IS_BROKEN + QWebView view; + TestWebPage* page = new TestWebPage; + view.setPage(page); + page->setParent(&view); + view.settings()->setAttribute(QWebSettings::PluginsEnabled, true); + + page->mainFrame()->setHtml(""); + QCOMPARE(page->creationCount, 1); + + QVariant result = page->mainFrame()->evaluateJavaScript("document.querySelector(\"object\").slotWithReturnValue()"); + QCOMPARE(result.toString(), QLatin1String("42")); +//#endif +} + +class WebPageWithConsoleCapture : public QWebPage +{ +public: + void javaScriptConsoleMessage(const QString &message, int, const QString &) + { + consoleMessages << message; + } + + QStringList consoleMessages; +}; + +void tst_QObjectBridge::exceptionInSlot() +{ + WebPageWithConsoleCapture page; + QWebFrame* frame = page.mainFrame(); + frame->addToJavaScriptWindowObject("myObject", m_myObject); + frame->evaluateJavaScript( + "myHandler = function() { window.gotSignal = true; throw 'exception in slot'; };" + "myObject.mySignal.connect(myHandler);" + "gotSignal = false;" + "myObject.mySignal();" + ); + QString ret = frame->evaluateJavaScript("gotSignal").toString(); + QCOMPARE(ret, sTrue); + QCOMPARE(page.consoleMessages, QStringList() << "exception in slot"); +} + +QTEST_MAIN(tst_QObjectBridge) +#include "tst_qobjectbridge.moc" diff --git a/tests/webkitwidgets/qwebelement/qwebelement.pro b/tests/webkitwidgets/qwebelement/qwebelement.pro new file mode 100644 index 000000000..ff6c49628 --- /dev/null +++ b/tests/webkitwidgets/qwebelement/qwebelement.pro @@ -0,0 +1,2 @@ +include(../tests.pri) +exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/webkitwidgets/qwebelement/resources/image.png b/tests/webkitwidgets/qwebelement/resources/image.png new file mode 100644 index 000000000..8d703640c Binary files /dev/null and b/tests/webkitwidgets/qwebelement/resources/image.png differ diff --git a/tests/webkitwidgets/qwebelement/resources/style.css b/tests/webkitwidgets/qwebelement/resources/style.css new file mode 100644 index 000000000..2713dfda9 --- /dev/null +++ b/tests/webkitwidgets/qwebelement/resources/style.css @@ -0,0 +1 @@ +#idP {color: black !important} diff --git a/tests/webkitwidgets/qwebelement/resources/style2.css b/tests/webkitwidgets/qwebelement/resources/style2.css new file mode 100644 index 000000000..6575dcb04 --- /dev/null +++ b/tests/webkitwidgets/qwebelement/resources/style2.css @@ -0,0 +1 @@ +#idP {color: green ! important} diff --git a/tests/webkitwidgets/qwebelement/tst_qwebelement.cpp b/tests/webkitwidgets/qwebelement/tst_qwebelement.cpp new file mode 100644 index 000000000..4ca5fe5f9 --- /dev/null +++ b/tests/webkitwidgets/qwebelement/tst_qwebelement.cpp @@ -0,0 +1,1080 @@ +/* + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#include +#include +#include +#include +#include +#include +#include +//TESTED_CLASS= +//TESTED_FILES= + +class tst_QWebElement : public QObject +{ + Q_OBJECT + +public: + tst_QWebElement(); + virtual ~tst_QWebElement(); + +public Q_SLOTS: + void init(); + void cleanup(); + +private Q_SLOTS: + void textHtml(); + void simpleCollection(); + void attributes(); + void attributesNS(); + void listAttributes(); + void classes(); + void namespaceURI(); + void iteration(); + void nonConstIterator(); + void constIterator(); + void foreachManipulation(); + void emptyCollection(); + void appendCollection(); + void evaluateJavaScript(); + void documentElement(); + void frame(); + void style(); + void computedStyle(); + void appendAndPrepend(); + void insertBeforeAndAfter(); + void remove(); + void clear(); + void replaceWith(); + void encloseWith(); + void encloseContentsWith(); + void nullSelect(); + void firstChildNextSibling(); + void lastChildPreviousSibling(); + void hasSetFocus(); + void render(); + void addElementToHead(); + +private: + QWebView* m_view { nullptr }; + QWebPage* m_page { nullptr }; + QWebFrame* m_mainFrame { nullptr }; +}; + +tst_QWebElement::tst_QWebElement() +{ +} + +tst_QWebElement::~tst_QWebElement() +{ +} + +void tst_QWebElement::init() +{ + m_view = new QWebView(); + m_page = m_view->page(); + m_mainFrame = m_page->mainFrame(); +} + +void tst_QWebElement::cleanup() +{ + delete m_view; +} + +void tst_QWebElement::textHtml() +{ + QString html = "

test

"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + QVERIFY(!body.isNull()); + + QCOMPARE(body.toPlainText(), QString("test")); + QCOMPARE(body.toPlainText(), m_mainFrame->toPlainText()); + + QCOMPARE(body.toInnerXml(), html); +} + +void tst_QWebElement::simpleCollection() +{ + QString html = "

first para

second para

"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + + QWebElementCollection list = body.findAll("p"); + QCOMPARE(list.count(), 2); + QCOMPARE(list.at(0).toPlainText(), QString("first para")); + QCOMPARE(list.at(1).toPlainText(), QString("second para")); +} + +void tst_QWebElement::attributes() +{ + m_mainFrame->setHtml("

Test"); + QWebElement body = m_mainFrame->documentElement(); + + QVERIFY(!body.hasAttribute("title")); + QVERIFY(!body.hasAttributes()); + + body.setAttribute("title", "test title"); + + QVERIFY(body.hasAttributes()); + QVERIFY(body.hasAttribute("title")); + + QCOMPARE(body.attribute("title"), QString("test title")); + + body.removeAttribute("title"); + + QVERIFY(!body.hasAttribute("title")); + QVERIFY(!body.hasAttributes()); + + QCOMPARE(body.attribute("does-not-exist", "testvalue"), QString("testvalue")); +} + +void tst_QWebElement::attributesNS() +{ + QString content = "" + "" + ""; + + m_mainFrame->setContent(content.toUtf8(), "application/xhtml+xml"); + + QWebElement svg = m_mainFrame->findFirstElement("svg"); + QVERIFY(!svg.isNull()); + + QVERIFY(!svg.hasAttributeNS("http://www.w3.org/2000/svg", "foobar")); + QCOMPARE(svg.attributeNS("http://www.w3.org/2000/svg", "foobar", "defaultblah"), QString("defaultblah")); + svg.setAttributeNS("http://www.w3.org/2000/svg", "svg:foobar", "true"); + QVERIFY(svg.hasAttributeNS("http://www.w3.org/2000/svg", "foobar")); + QCOMPARE(svg.attributeNS("http://www.w3.org/2000/svg", "foobar", "defaultblah"), QString("true")); +} + +void tst_QWebElement::listAttributes() +{ + QString content = "" + "" + ""; + + m_mainFrame->setContent(content.toUtf8(), "application/xhtml+xml"); + + QWebElement svg = m_mainFrame->findFirstElement("svg"); + QVERIFY(!svg.isNull()); + + QVERIFY(svg.attributeNames().contains("foo")); + QVERIFY(svg.attributeNames("http://www.w3.org/2000/svg").contains("bar")); + + svg.setAttributeNS("http://www.w3.org/2000/svg", "svg:foobar", "true"); + QVERIFY(svg.attributeNames().contains("foo")); + QStringList attributes = svg.attributeNames("http://www.w3.org/2000/svg"); + QCOMPARE(attributes.size(), 2); + QVERIFY(attributes.contains("bar")); + QVERIFY(attributes.contains("foobar")); +} + +void tst_QWebElement::classes() +{ + m_mainFrame->setHtml("

Test"); + + QWebElement body = m_mainFrame->documentElement(); + QCOMPARE(body.classes().count(), 0); + + QWebElement p = m_mainFrame->documentElement().findAll("p").at(0); + QStringList classes = p.classes(); + QCOMPARE(classes.count(), 4); + QCOMPARE(classes[0], QLatin1String("a")); + QCOMPARE(classes[1], QLatin1String("b")); + QCOMPARE(classes[2], QLatin1String("c")); + QCOMPARE(classes[3], QLatin1String("d")); + QVERIFY(p.hasClass("a")); + QVERIFY(p.hasClass("b")); + QVERIFY(p.hasClass("c")); + QVERIFY(p.hasClass("d")); + QVERIFY(!p.hasClass("e")); + + p.addClass("f"); + QVERIFY(p.hasClass("f")); + p.addClass("a"); + QCOMPARE(p.classes().count(), 5); + QVERIFY(p.hasClass("a")); + QVERIFY(p.hasClass("b")); + QVERIFY(p.hasClass("c")); + QVERIFY(p.hasClass("d")); + + p.toggleClass("a"); + QVERIFY(!p.hasClass("a")); + QVERIFY(p.hasClass("b")); + QVERIFY(p.hasClass("c")); + QVERIFY(p.hasClass("d")); + QVERIFY(p.hasClass("f")); + QCOMPARE(p.classes().count(), 4); + p.toggleClass("f"); + QVERIFY(!p.hasClass("f")); + QCOMPARE(p.classes().count(), 3); + p.toggleClass("a"); + p.toggleClass("f"); + QVERIFY(p.hasClass("a")); + QVERIFY(p.hasClass("f")); + QCOMPARE(p.classes().count(), 5); + + p.removeClass("f"); + QVERIFY(!p.hasClass("f")); + QCOMPARE(p.classes().count(), 4); + p.removeClass("d"); + QVERIFY(!p.hasClass("d")); + QCOMPARE(p.classes().count(), 3); + p.removeClass("not-exist"); + QCOMPARE(p.classes().count(), 3); + p.removeClass("c"); + QVERIFY(!p.hasClass("c")); + QCOMPARE(p.classes().count(), 2); + p.removeClass("b"); + QVERIFY(!p.hasClass("b")); + QCOMPARE(p.classes().count(), 1); + p.removeClass("a"); + QVERIFY(!p.hasClass("a")); + QCOMPARE(p.classes().count(), 0); + p.removeClass("foobar"); + QCOMPARE(p.classes().count(), 0); +} + +void tst_QWebElement::namespaceURI() +{ + QString content = "" + "" + ""; + + m_mainFrame->setContent(content.toUtf8(), "application/xhtml+xml"); + QWebElement body = m_mainFrame->documentElement(); + QCOMPARE(body.namespaceUri(), QLatin1String("http://www.w3.org/1999/xhtml")); + + QWebElement svg = body.findAll("*#foobar").at(0); + QCOMPARE(svg.prefix(), QLatin1String("svg")); + QCOMPARE(svg.localName(), QLatin1String("svg")); + QCOMPARE(svg.tagName(), QLatin1String("svg:svg")); + QCOMPARE(svg.namespaceUri(), QLatin1String("http://www.w3.org/2000/svg")); + +} + +void tst_QWebElement::iteration() +{ + QString html = "

first para

second para

"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + + QWebElementCollection paras = body.findAll("p"); + QList referenceList = paras.toList(); + + QList foreachList; + foreach(QWebElement p, paras) { + foreachList.append(p); + } + QVERIFY(foreachList.count() == 2); + QCOMPARE(foreachList.count(), referenceList.count()); + QCOMPARE(foreachList.at(0), referenceList.at(0)); + QCOMPARE(foreachList.at(1), referenceList.at(1)); + + QList forLoopList; + for (int i = 0; i < paras.count(); ++i) { + forLoopList.append(paras.at(i)); + } + QVERIFY(foreachList.count() == 2); + QCOMPARE(foreachList.count(), referenceList.count()); + QCOMPARE(foreachList.at(0), referenceList.at(0)); + QCOMPARE(foreachList.at(1), referenceList.at(1)); + + for (int i = 0; i < paras.count(); ++i) { + QCOMPARE(paras.at(i), paras[i]); + } + + QCOMPARE(paras.at(0), paras.first()); + QCOMPARE(paras.at(1), paras.last()); +} + +void tst_QWebElement::nonConstIterator() +{ + QString html = "

first para

second para

"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + QWebElementCollection paras = body.findAll("p"); + + QWebElementCollection::iterator it = paras.begin(); + QCOMPARE(*it, paras.at(0)); + ++it; + (*it).encloseWith("
"); + QCOMPARE(*it, paras.at(1)); + ++it; + QCOMPARE(it, paras.end()); +} + +void tst_QWebElement::constIterator() +{ + QString html = "

first para

second para

"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + const QWebElementCollection paras = body.findAll("p"); + + QWebElementCollection::const_iterator it = paras.begin(); + QCOMPARE(*it, paras.at(0)); + ++it; + QCOMPARE(*it, paras.at(1)); + ++it; + QCOMPARE(it, paras.end()); +} + +void tst_QWebElement::foreachManipulation() +{ + QString html = "

first para

second para

"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + + foreach(QWebElement p, body.findAll("p")) { + p.setInnerXml("
foo
bar
"); + } + + QCOMPARE(body.findAll("div").count(), 4); +} + +void tst_QWebElement::emptyCollection() +{ + QWebElementCollection emptyCollection; + QCOMPARE(emptyCollection.count(), 0); +} + +void tst_QWebElement::appendCollection() +{ + QString html = "aaa

first para

foo
" + "bbb

second para

bar
"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + + QWebElementCollection collection = body.findAll("p"); + QCOMPARE(collection.count(), 2); + + collection.append(body.findAll("div")); + QCOMPARE(collection.count(), 4); + + collection += body.findAll("span.a"); + QCOMPARE(collection.count(), 5); + + QWebElementCollection all = collection + body.findAll("span.b"); + QCOMPARE(all.count(), 6); + QCOMPARE(collection.count(), 5); + + all += collection; + QCOMPARE(all.count(), 11); + + QCOMPARE(collection.count(), 5); + QWebElementCollection test; + test.append(collection); + QCOMPARE(test.count(), 5); + test.append(QWebElementCollection()); + QCOMPARE(test.count(), 5); +} + +void tst_QWebElement::evaluateJavaScript() +{ + QVariant result; + m_mainFrame->setHtml("

test"); + QWebElement para = m_mainFrame->findFirstElement("p"); + + result = para.evaluateJavaScript("this.tagName"); + QVERIFY(result.isValid()); + QVERIFY(result.type() == QVariant::String); + QCOMPARE(result.toString(), QLatin1String("P")); + + result = para.evaluateJavaScript("this.hasAttributes()"); + QVERIFY(result.isValid()); + QVERIFY(result.type() == QVariant::Bool); + QVERIFY(!result.toBool()); + + para.evaluateJavaScript("this.setAttribute('align', 'left');"); + QCOMPARE(para.attribute("align"), QLatin1String("left")); + + result = para.evaluateJavaScript("this.hasAttributes()"); + QVERIFY(result.isValid()); + QVERIFY(result.type() == QVariant::Bool); + QVERIFY(result.toBool()); +} + +void tst_QWebElement::documentElement() +{ + m_mainFrame->setHtml("

Test"); + + QWebElement para = m_mainFrame->documentElement().findAll("p").at(0); + QVERIFY(para.parent().parent() == m_mainFrame->documentElement()); + QVERIFY(para.document() == m_mainFrame->documentElement()); +} + +void tst_QWebElement::frame() +{ + m_mainFrame->setHtml("

test"); + + QWebElement doc = m_mainFrame->documentElement(); + QVERIFY(doc.webFrame() == m_mainFrame); + + m_mainFrame->load(QUrl("data:text/html,frame1\">" + "frame2\">")); + + waitForSignal(m_page, SIGNAL(loadFinished(bool))); + + QCOMPARE(m_mainFrame->childFrames().count(), 2); + + QWebFrame* firstFrame = m_mainFrame->childFrames().at(0); + QWebFrame* secondFrame = m_mainFrame->childFrames().at(1); + + QCOMPARE(firstFrame->toPlainText(), QString("frame1")); + QCOMPARE(secondFrame->toPlainText(), QString("frame2")); + + QWebElement firstPara = firstFrame->documentElement().findAll("p").at(0); + QWebElement secondPara = secondFrame->documentElement().findAll("p").at(0); + + QVERIFY(firstPara.webFrame() == firstFrame); + QVERIFY(secondPara.webFrame() == secondFrame); +} + +void tst_QWebElement::style() +{ + QString html = "" + "" + "" + "" + "

some text

" + ""; + + m_mainFrame->setHtml(html); + + QWebElement p = m_mainFrame->documentElement().findAll("p").at(0); + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); + QVERIFY(p.styleProperty("cursor", QWebElement::InlineStyle).isEmpty()); + + p.setStyleProperty("color", "red"); + p.setStyleProperty("cursor", "auto"); + + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("red")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("yellow")); + QCOMPARE(p.styleProperty("cursor", QWebElement::InlineStyle), QLatin1String("auto")); + + p.setStyleProperty("color", "green !important"); + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("green")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("green")); + + p.setStyleProperty("color", "blue"); + // A current important InlineStyle shouldn't be overwritten by a non-important one. + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("green")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("green")); + + p.setStyleProperty("color", "blue !important"); + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue")); + + QString html2 = "" + "" + "" + "" + "

some text

" + ""; + + m_mainFrame->setHtml(html2); + p = m_mainFrame->documentElement().findAll("p").at(0); + + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue")); + + QString html3 = "" + "" + "" + "" + "

some text

" + ""; + + m_mainFrame->setHtml(html3); + p = m_mainFrame->documentElement().findAll("p").at(0); + + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue")); + + QString html5 = "" + "" + "" + "" + "

some text

" + ""; + + m_mainFrame->setHtml(html5); + p = m_mainFrame->documentElement().findAll("p").at(0); + + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("red")); + + QString html6 = "" + "" + "" + "" + "" + "

some text

" + ""; + + // in few seconds, the CSS should be completey loaded + m_mainFrame->setHtml(html6); + waitForSignal(m_page, SIGNAL(loadFinished(bool)), 200); + + p = m_mainFrame->documentElement().findAll("p").at(0); + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("black")); + + QString html7 = "" + "" + "" + "" + "" + "

some text

" + ""; + + // in few seconds, the style should be completey loaded + m_mainFrame->setHtml(html7); + waitForSignal(m_page, SIGNAL(loadFinished(bool)), 200); + + p = m_mainFrame->documentElement().findAll("p").at(0); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("black")); + + QString html8 = "

some text

"; + + m_mainFrame->setHtml(html8); + p = m_mainFrame->documentElement().findAll("p").at(0); + + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("")); +} + +void tst_QWebElement::computedStyle() +{ + QString html = "

some text

"; + m_mainFrame->setHtml(html); + + QWebElement p = m_mainFrame->documentElement().findAll("p").at(0); + QCOMPARE(p.styleProperty("cursor", QWebElement::ComputedStyle), QLatin1String("auto")); + QVERIFY(!p.styleProperty("cursor", QWebElement::ComputedStyle).isEmpty()); + QVERIFY(p.styleProperty("cursor", QWebElement::InlineStyle).isEmpty()); + + p.setStyleProperty("cursor", "text"); + p.setStyleProperty("color", "red"); + + QCOMPARE(p.styleProperty("cursor", QWebElement::ComputedStyle), QLatin1String("text")); + QCOMPARE(p.styleProperty("color", QWebElement::ComputedStyle), QLatin1String("rgb(255, 0, 0)")); + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("red")); +} + +void tst_QWebElement::appendAndPrepend() +{ + QString html = "" + "

" + "foo" + "

" + "

" + "bar" + "

" + ""; + + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement().findFirst("body"); + + QCOMPARE(body.findAll("p").count(), 2); + body.appendInside(body.findFirst("p")); + QCOMPARE(body.findAll("p").count(), 2); + QCOMPARE(body.findFirst("p").toPlainText(), QString("bar")); + QCOMPARE(body.findAll("p").last().toPlainText(), QString("foo")); + + body.appendInside(body.findFirst("p").clone()); + QCOMPARE(body.findAll("p").count(), 3); + QCOMPARE(body.findFirst("p").toPlainText(), QString("bar")); + QCOMPARE(body.findAll("p").last().toPlainText(), QString("bar")); + + body.prependInside(body.findAll("p").at(1).clone()); + QCOMPARE(body.findAll("p").count(), 4); + QCOMPARE(body.findFirst("p").toPlainText(), QString("foo")); + + body.findFirst("p").appendInside("
booyakasha
"); + QCOMPARE(body.findAll("p div").count(), 1); + QCOMPARE(body.findFirst("p div").toPlainText(), QString("booyakasha")); + + body.findFirst("div").prependInside("yepp"); + QCOMPARE(body.findAll("p div code").count(), 1); + QCOMPARE(body.findFirst("p div code").toPlainText(), QString("yepp")); + + // Inserting HTML into an img tag is not allowed, but appending/prepending outside is. + body.findFirst("div").appendInside(""); + QCOMPARE(body.findAll("p div img").count(), 1); + + QWebElement img = body.findFirst("img"); + QVERIFY(!img.isNull()); + img.appendInside("

"); + QCOMPARE(body.findAll("p#fail1").count(), 0); + + img.appendOutside("

"); + QCOMPARE(body.findAll("p#success1").count(), 1); + + img.prependInside("

"); + QCOMPARE(body.findAll("p#fail2").count(), 0); + + img.prependOutside("

"); + QCOMPARE(body.findAll("p#success2").count(), 1); + + +} + +void tst_QWebElement::insertBeforeAndAfter() +{ + QString html = "" + "

" + "foo" + "

" + "
" + "yeah" + "
" + "

" + "bar" + "

" + ""; + + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement().findFirst("body"); + QWebElement div = body.findFirst("div"); + + QCOMPARE(body.findAll("p").count(), 2); + QCOMPARE(body.findAll("div").count(), 1); + + div.prependOutside(body.findAll("p").last().clone()); + QCOMPARE(body.findAll("p").count(), 3); + QCOMPARE(body.findAll("p").at(0).toPlainText(), QString("foo")); + QCOMPARE(body.findAll("p").at(1).toPlainText(), QString("bar")); + QCOMPARE(body.findAll("p").at(2).toPlainText(), QString("bar")); + + div.appendOutside(body.findFirst("p").clone()); + QCOMPARE(body.findAll("p").count(), 4); + QCOMPARE(body.findAll("p").at(0).toPlainText(), QString("foo")); + QCOMPARE(body.findAll("p").at(1).toPlainText(), QString("bar")); + QCOMPARE(body.findAll("p").at(2).toPlainText(), QString("foo")); + QCOMPARE(body.findAll("p").at(3).toPlainText(), QString("bar")); + + div.prependOutside("hey"); + QCOMPARE(body.findAll("span").count(), 1); + + div.appendOutside("there"); + QCOMPARE(body.findAll("span").count(), 2); + QCOMPARE(body.findAll("span").at(0).toPlainText(), QString("hey")); + QCOMPARE(body.findAll("span").at(1).toPlainText(), QString("there")); +} + +void tst_QWebElement::remove() +{ + QString html = "" + "

" + "foo" + "

" + "
" + "

yeah

" + "
" + "

" + "bar" + "

" + ""; + + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement().findFirst("body"); + + QCOMPARE(body.findAll("div").count(), 1); + QCOMPARE(body.findAll("p").count(), 3); + + QWebElement div = body.findFirst("div"); + div.takeFromDocument(); + + QCOMPARE(div.isNull(), false); + QCOMPARE(body.findAll("div").count(), 0); + QCOMPARE(body.findAll("p").count(), 2); + + body.appendInside(div); + + QCOMPARE(body.findAll("div").count(), 1); + QCOMPARE(body.findAll("p").count(), 3); +} + +void tst_QWebElement::clear() +{ + QString html = "" + "

" + "foo" + "

" + "
" + "

yeah

" + "
" + "

" + "bar" + "

" + ""; + + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement().findFirst("body"); + + QCOMPARE(body.findAll("div").count(), 1); + QCOMPARE(body.findAll("p").count(), 3); + body.findFirst("div").removeAllChildren(); + QCOMPARE(body.findAll("div").count(), 1); + QCOMPARE(body.findAll("p").count(), 2); +} + + +void tst_QWebElement::replaceWith() +{ + QString html = "" + "

" + "foo" + "

" + "
" + "yeah" + "
" + "

" + "haba" + "

" + ""; + + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement().findFirst("body"); + + QCOMPARE(body.findAll("div").count(), 1); + QCOMPARE(body.findAll("span").count(), 1); + body.findFirst("div").replace(body.findFirst("span").clone()); + QCOMPARE(body.findAll("div").count(), 0); + QCOMPARE(body.findAll("span").count(), 2); + QCOMPARE(body.findAll("p").count(), 2); + + body.findFirst("span").replace("

wow

"); + QCOMPARE(body.findAll("p").count(), 3); + QCOMPARE(body.findAll("p code").count(), 1); + QCOMPARE(body.findFirst("p code").toPlainText(), QString("wow")); +} + +void tst_QWebElement::encloseContentsWith() +{ + QString html = "" + "
" + "" + "yeah" + "" + "" + "hello" + "" + "
" + "

" + "foo" + "bar" + "

" + "" + "" + "hey" + ""; + + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement().findFirst("body"); + + body.findFirst("p").encloseContentsWith(body.findFirst("b")); + QCOMPARE(body.findAll("p b span").count(), 2); + QCOMPARE(body.findFirst("p b span").toPlainText(), QString("foo")); + + body.findFirst("u").encloseContentsWith(""); + QCOMPARE(body.findAll("u i").count(), 1); + QCOMPARE(body.findFirst("u i").toPlainText(), QString()); + + body.findFirst("div").encloseContentsWith(""); + QCOMPARE(body.findAll("div span i").count(), 2); + QCOMPARE(body.findFirst("div span i").toPlainText(), QString("yeah")); + + QString snippet = "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
"; + + body.findFirst("em").encloseContentsWith(snippet); + QCOMPARE(body.findFirst("em table tbody tr td").toPlainText(), QString("hey")); +} + +void tst_QWebElement::encloseWith() +{ + QString html = "" + "

" + "foo" + "

" + "
" + "yeah" + "
" + "

" + "bar" + "

" + "hey" + "

hello

" + ""; + + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement().findFirst("body"); + + body.findFirst("p").encloseWith("
"); + QCOMPARE(body.findAll("br").count(), 0); + + QCOMPARE(body.findAll("div").count(), 1); + body.findFirst("div").encloseWith(body.findFirst("span").clone()); + QCOMPARE(body.findAll("div").count(), 1); + QCOMPARE(body.findAll("span").count(), 2); + QCOMPARE(body.findAll("p").count(), 2); + + body.findFirst("div").encloseWith(""); + QCOMPARE(body.findAll("code").count(), 1); + QCOMPARE(body.findAll("code div").count(), 1); + QCOMPARE(body.findFirst("code div").toPlainText(), QString("yeah")); + + QString snippet = "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
"; + + body.findFirst("em").encloseWith(snippet); + QCOMPARE(body.findFirst("table tbody tr td em").toPlainText(), QString("hey")); + + // Enclosing the contents of an img tag is not allowed, but enclosing the img tag itself is. + body.findFirst("td").appendInside(""); + QCOMPARE(body.findAll("img").count(), 1); + + QWebElement img = body.findFirst("img"); + QVERIFY(!img.isNull()); + img.encloseWith("

"); + QCOMPARE(body.findAll("p#success").count(), 1); + + img.encloseContentsWith("

"); + QCOMPARE(body.findAll("p#fail").count(), 0); + +} + +void tst_QWebElement::nullSelect() +{ + m_mainFrame->setHtml("

Test"); + + QWebElementCollection collection = m_mainFrame->findAllElements("invalid{syn(tax;;%#$f223e>>"); + QVERIFY(collection.count() == 0); +} + +void tst_QWebElement::firstChildNextSibling() +{ + m_mainFrame->setHtml("

Test

"); + + QWebElement body = m_mainFrame->findFirstElement("body"); + QVERIFY(!body.isNull()); + QWebElement p = body.firstChild(); + QVERIFY(!p.isNull()); + QCOMPARE(p.tagName(), QString("P")); + QWebElement table = p.nextSibling(); + QVERIFY(!table.isNull()); + QCOMPARE(table.tagName(), QString("TABLE")); + QVERIFY(table.nextSibling().isNull()); +} + +void tst_QWebElement::lastChildPreviousSibling() +{ + m_mainFrame->setHtml("

Test

"); + + QWebElement body = m_mainFrame->findFirstElement("body"); + QVERIFY(!body.isNull()); + QWebElement table = body.lastChild(); + QVERIFY(!table.isNull()); + QCOMPARE(table.tagName(), QString("TABLE")); + QWebElement p = table.previousSibling(); + QVERIFY(!p.isNull()); + QCOMPARE(p.tagName(), QString("P")); + QVERIFY(p.previousSibling().isNull()); +} + +void tst_QWebElement::hasSetFocus() +{ + m_mainFrame->setHtml("" \ + "" \ + "
"\ + "" \ + ""); + + QWebElementCollection inputs = m_mainFrame->documentElement().findAll("input"); + QWebElement input1 = inputs.at(0); + input1.setFocus(); + QVERIFY(input1.hasFocus()); + + QWebElement input2 = inputs.at(1); + input2.setFocus(); + QVERIFY(!input1.hasFocus()); + QVERIFY(input2.hasFocus()); +} + +void tst_QWebElement::render() +{ + QString html( "" + "" + "
" + "" + "" + "" + "" + "
test" + "" + "
" + "" + "" + ); + + QWebPage page; + QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); + page.mainFrame()->setHtml(html); + + waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(loadSpy.count(), 1); + + QSize size = page.mainFrame()->contentsSize(); + page.setViewportSize(size); + + QWebElementCollection imgs = page.mainFrame()->findAllElements("img"); + QCOMPARE(imgs.count(), 1); + + QImage resource(":/image.png"); + QRect imageRect(0, 0, resource.width(), resource.height()); + + QImage testImage(resource.width(), resource.height(), QImage::Format_ARGB32); + QPainter painter0(&testImage); + painter0.fillRect(imageRect, Qt::white); + // render() uses pixmaps internally, and pixmaps might have bit depths + // other than 32, giving different pixel values due to rounding. + QPixmap pix = QPixmap::fromImage(resource); + painter0.drawPixmap(0, 0, pix); + painter0.end(); + + QImage image1(resource.width(), resource.height(), QImage::Format_ARGB32); + QPainter painter1(&image1); + painter1.fillRect(imageRect, Qt::white); + imgs[0].render(&painter1); + painter1.end(); + + QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=65243", Continue); + QVERIFY(image1 == testImage); + + // render image 2nd time to make sure that cached rendering works fine + QImage image2(resource.width(), resource.height(), QImage::Format_ARGB32); + QPainter painter2(&image2); + painter2.fillRect(imageRect, Qt::white); + imgs[0].render(&painter2); + painter2.end(); + + QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=65243", Continue); + QVERIFY(image2 == testImage); + + // compare table rendered through QWebElement::render to whole page table rendering + QRect tableRect(0, 0, 300, 300); + QWebElementCollection tables = page.mainFrame()->findAllElements("table"); + QCOMPARE(tables.count(), 1); + + QImage image3(300, 300, QImage::Format_ARGB32); + QPainter painter3(&image3); + painter3.fillRect(tableRect, Qt::white); + tables[0].render(&painter3); + painter3.end(); + + QImage image4(300, 300, QImage::Format_ARGB32); + QPainter painter4(&image4); + page.mainFrame()->render(&painter4, tableRect); + painter4.end(); + + QVERIFY(image3 == image4); + + // Chunked render test reuses page rendered in image4 in previous test + const int chunkHeight = tableRect.height(); + const int chunkWidth = tableRect.width() / 3; + QImage chunk(chunkWidth, chunkHeight, QImage::Format_ARGB32); + QRect chunkRect(0, 0, chunkWidth, chunkHeight); + for (int x = 0; x < tableRect.width(); x += chunkWidth) { + QPainter painter(&chunk); + painter.fillRect(chunkRect, Qt::white); + QRect chunkPaintRect(x, 0, chunkWidth, chunkHeight); + tables[0].render(&painter, chunkPaintRect); + painter.end(); + + QVERIFY(chunk == image4.copy(chunkPaintRect)); + } +} + +void tst_QWebElement::addElementToHead() +{ + m_mainFrame->setHtml(""); + QWebElement head = m_mainFrame->findFirstElement("head"); + QVERIFY(!head.isNull()); + QString append = ""; + head.appendInside(append); + QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=102234", Continue); + QCOMPARE(head.toInnerXml(), append); +} + +QTEST_MAIN(tst_QWebElement) +#include "tst_qwebelement.moc" diff --git a/tests/webkitwidgets/qwebelement/tst_qwebelement.qrc b/tests/webkitwidgets/qwebelement/tst_qwebelement.qrc new file mode 100644 index 000000000..7384c76e0 --- /dev/null +++ b/tests/webkitwidgets/qwebelement/tst_qwebelement.qrc @@ -0,0 +1,7 @@ + + +resources/style.css +resources/style2.css +resources/image.png + + diff --git a/tests/webkitwidgets/qwebframe/qwebframe.pro b/tests/webkitwidgets/qwebframe/qwebframe.pro new file mode 100644 index 000000000..f434ccbc1 --- /dev/null +++ b/tests/webkitwidgets/qwebframe/qwebframe.pro @@ -0,0 +1,3 @@ +include(../tests.pri) +exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc + diff --git a/tests/webkitwidgets/qwebframe/resources/image.png b/tests/webkitwidgets/qwebframe/resources/image.png new file mode 100644 index 000000000..8d703640c Binary files /dev/null and b/tests/webkitwidgets/qwebframe/resources/image.png differ diff --git a/tests/webkitwidgets/qwebframe/resources/style.css b/tests/webkitwidgets/qwebframe/resources/style.css new file mode 100644 index 000000000..c05b747f1 --- /dev/null +++ b/tests/webkitwidgets/qwebframe/resources/style.css @@ -0,0 +1 @@ +#idP {color: red !important} diff --git a/tests/webkitwidgets/qwebframe/resources/test1.html b/tests/webkitwidgets/qwebframe/resources/test1.html new file mode 100644 index 000000000..b323f966e --- /dev/null +++ b/tests/webkitwidgets/qwebframe/resources/test1.html @@ -0,0 +1 @@ +

Some text 1

diff --git a/tests/webkitwidgets/qwebframe/resources/test2.html b/tests/webkitwidgets/qwebframe/resources/test2.html new file mode 100644 index 000000000..63ac1f6ec --- /dev/null +++ b/tests/webkitwidgets/qwebframe/resources/test2.html @@ -0,0 +1 @@ +

Some text 2

diff --git a/tests/webkitwidgets/qwebframe/resources/testiframe.html b/tests/webkitwidgets/qwebframe/resources/testiframe.html new file mode 100644 index 000000000..ee0f64d1b --- /dev/null +++ b/tests/webkitwidgets/qwebframe/resources/testiframe.html @@ -0,0 +1,53 @@ + + + + + + + +
You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible.
+ + + + \ No newline at end of file diff --git a/tests/webkitwidgets/qwebframe/resources/testiframe2.html b/tests/webkitwidgets/qwebframe/resources/testiframe2.html new file mode 100644 index 000000000..483e94e1d --- /dev/null +++ b/tests/webkitwidgets/qwebframe/resources/testiframe2.html @@ -0,0 +1,20 @@ + + + + + + +
+ + \ No newline at end of file diff --git a/tests/webkitwidgets/qwebframe/tst_qwebframe.cpp b/tests/webkitwidgets/qwebframe/tst_qwebframe.cpp new file mode 100644 index 000000000..d635f8e2c --- /dev/null +++ b/tests/webkitwidgets/qwebframe/tst_qwebframe.cpp @@ -0,0 +1,1601 @@ +/* + Copyright (C) 2008,2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef QT_NO_OPENSSL +#include +#endif +#include "../util.h" + +class tst_QWebFrame : public QObject +{ + Q_OBJECT + +public: + bool eventFilter(QObject* watched, QEvent* event); + +public Q_SLOTS: + void init(); + void cleanup(); + +private Q_SLOTS: + void horizontalScrollAfterBack(); + void symmetricUrl(); + void progressSignal(); + void urlChange(); + void requestedUrl(); + void requestedUrlAfterSetAndLoadFailures(); + void javaScriptWindowObjectCleared_data(); + void javaScriptWindowObjectCleared(); + void javaScriptWindowObjectClearedOnEvaluate(); + void setHtml(); + void setHtmlWithImageResource(); + void setHtmlWithStylesheetResource(); + void setHtmlWithBaseURL(); + void setHtmlWithJSAlert(); + void ipv6HostEncoding(); + void metaData(); +#if !defined(QT_NO_COMBOBOX) + void popupFocus(); +#endif + void inputFieldFocus(); + void hitTestContent(); + void baseUrl_data(); + void baseUrl(); + void hasSetFocus(); + void renderGeometry(); + void renderHints(); + void scrollPosition(); + void scrollToAnchor(); + void scrollbarsOff(); + void evaluateWillCauseRepaint(); + void setContent_data(); + void setContent(); + void setCacheLoadControlAttribute(); + void setUrlWithPendingLoads(); + void setUrlWithFragment_data(); + void setUrlWithFragment(); + void setUrlToEmpty(); + void setUrlToInvalid(); + void setUrlHistory(); + void setUrlUsingStateObject(); + void setUrlSameUrl(); + void setUrlThenLoads_data(); + void setUrlThenLoads(); + void loadFinishedAfterNotFoundError(); + void signalsDuringErrorHandling(); + void loadInSignalHandlers_data(); + void loadInSignalHandlers(); + +private: + QWebView* m_view { nullptr }; + QWebPage* m_page { nullptr }; + QWebView* m_inputFieldsTestView { nullptr }; + int m_inputFieldTestPaintCount { 0 }; +}; + +bool tst_QWebFrame::eventFilter(QObject* watched, QEvent* event) +{ + // used on the inputFieldFocus test + if (watched == m_inputFieldsTestView) { + if (event->type() == QEvent::Paint) + m_inputFieldTestPaintCount++; + } + return QObject::eventFilter(watched, event); +} + +void tst_QWebFrame::init() +{ + m_view = new QWebView(); + m_page = m_view->page(); +} + +void tst_QWebFrame::cleanup() +{ + delete m_view; +} + +void tst_QWebFrame::symmetricUrl() +{ + QVERIFY(m_view->url().isEmpty()); + + QCOMPARE(m_view->history()->count(), 0); + + QUrl dataUrl("data:text/html,

Test"); + + m_view->setUrl(dataUrl); + QCOMPARE(m_view->url(), dataUrl); + QCOMPARE(m_view->history()->count(), 0); + + // loading is _not_ immediate, so the text isn't set just yet. + QVERIFY(m_view->page()->mainFrame()->toPlainText().isEmpty()); + + ::waitForSignal(m_view, SIGNAL(loadFinished(bool))); + + QCOMPARE(m_view->history()->count(), 1); + QCOMPARE(m_view->page()->mainFrame()->toPlainText(), QString("Test")); + + QUrl dataUrl2("data:text/html,

Test2"); + QUrl dataUrl3("data:text/html,

Test3"); + + m_view->setUrl(dataUrl2); + m_view->setUrl(dataUrl3); + + QCOMPARE(m_view->url(), dataUrl3); + + ::waitForSignal(m_view, SIGNAL(loadFinished(bool))); + + QCOMPARE(m_view->history()->count(), 2); + + QCOMPARE(m_view->page()->mainFrame()->toPlainText(), QString("Test3")); +} + +void tst_QWebFrame::progressSignal() +{ + QSignalSpy progressSpy(m_view, SIGNAL(loadProgress(int))); + + QUrl dataUrl("data:text/html,

Test"); + m_view->setUrl(dataUrl); + + ::waitForSignal(m_view, SIGNAL(loadFinished(bool))); + + QVERIFY(progressSpy.size() >= 1); + QCOMPARE(progressSpy.last().first().toInt(), 100); +} + +void tst_QWebFrame::urlChange() +{ + QSignalSpy urlSpy(m_page->mainFrame(), SIGNAL(urlChanged(QUrl))); + + QUrl dataUrl("data:text/html,

Test"); + m_view->setUrl(dataUrl); + + ::waitForSignal(m_page->mainFrame(), SIGNAL(urlChanged(QUrl))); + + QCOMPARE(urlSpy.size(), 1); + + QUrl dataUrl2("data:text/html,title

Test"); + m_view->setUrl(dataUrl2); + + ::waitForSignal(m_page->mainFrame(), SIGNAL(urlChanged(QUrl))); + + QCOMPARE(urlSpy.size(), 2); +} + +class FakeReply : public QNetworkReply { + Q_OBJECT + +public: + static const QUrl urlFor404ErrorWithoutContents; + + FakeReply(const QNetworkRequest& request, QObject* parent = 0) + : QNetworkReply(parent) + { + setOperation(QNetworkAccessManager::GetOperation); + setRequest(request); + setUrl(request.url()); + if (request.url() == QUrl("qrc:/test1.html")) { + setHeader(QNetworkRequest::LocationHeader, QString("qrc:/test2.html")); + setAttribute(QNetworkRequest::RedirectionTargetAttribute, QUrl("qrc:/test2.html")); + QTimer::singleShot(0, this, SLOT(continueRedirect())); + } +#ifndef QT_NO_OPENSSL + else if (request.url() == QUrl("qrc:/fake-ssl-error.html")) { + setError(QNetworkReply::SslHandshakeFailedError, tr("Fake error!")); + QTimer::singleShot(0, this, SLOT(continueError())); + } +#endif + else if (request.url().host() == QLatin1String("abcdef.abcdef")) { + setError(QNetworkReply::HostNotFoundError, tr("Invalid URL")); + QTimer::singleShot(0, this, SLOT(continueError())); + } else if (request.url() == FakeReply::urlFor404ErrorWithoutContents) { + setError(QNetworkReply::ContentNotFoundError, "Not found"); + setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 404); + QTimer::singleShot(0, this, SLOT(continueError())); + } + + open(QIODevice::ReadOnly); + } + ~FakeReply() + { + close(); + } + virtual void abort() {} + virtual void close() {} + +protected: + qint64 readData(char*, qint64) + { + return 0; + } + +private Q_SLOTS: + void continueRedirect() + { + emit metaDataChanged(); + emit finished(); + } + + void continueError() + { + emit error(this->error()); + emit finished(); + } +}; + +const QUrl FakeReply::urlFor404ErrorWithoutContents = QUrl("http://this.will/return-http-404-error-without-contents.html"); + +class FakeNetworkManager : public QNetworkAccessManager { + Q_OBJECT + +public: + FakeNetworkManager(QObject* parent) : QNetworkAccessManager(parent) { } + +protected: + virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest& request, QIODevice* outgoingData) + { + QString url = request.url().toString(); + if (op == QNetworkAccessManager::GetOperation) { +#ifndef QT_NO_OPENSSL + if (url == "qrc:/fake-ssl-error.html") { + FakeReply* reply = new FakeReply(request, this); + QList errors; + emit sslErrors(reply, errors << QSslError(QSslError::UnspecifiedError)); + return reply; + } +#endif + if (url == "qrc:/test1.html" || url == "http://abcdef.abcdef/" || request.url() == FakeReply::urlFor404ErrorWithoutContents) + return new FakeReply(request, this); + } + + return QNetworkAccessManager::createRequest(op, request, outgoingData); + } +}; + +void tst_QWebFrame::requestedUrl() +{ + QWebPage page; + QWebFrame* frame = page.mainFrame(); + + // in few seconds, the image should be completely loaded + QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); + FakeNetworkManager* networkManager = new FakeNetworkManager(&page); + page.setNetworkAccessManager(networkManager); + + frame->setUrl(QUrl("qrc:/test1.html")); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); + QCOMPARE(spy.count(), 1); + QCOMPARE(frame->requestedUrl(), QUrl("qrc:/test1.html")); + QCOMPARE(frame->url(), QUrl("qrc:/test2.html")); + + frame->setUrl(QUrl("qrc:/non-existent.html")); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); + QCOMPARE(spy.count(), 2); + QCOMPARE(frame->requestedUrl(), QUrl("qrc:/non-existent.html")); + QCOMPARE(frame->url(), QUrl("qrc:/non-existent.html")); + + frame->setUrl(QUrl("http://abcdef.abcdef")); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); + QCOMPARE(spy.count(), 3); + QCOMPARE(frame->requestedUrl(), QUrl("http://abcdef.abcdef/")); + QCOMPARE(frame->url(), QUrl("http://abcdef.abcdef/")); + +#ifndef QT_NO_OPENSSL + qRegisterMetaType >("QList"); + qRegisterMetaType("QNetworkReply*"); + + QSignalSpy spy2(page.networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*,QList))); + frame->setUrl(QUrl("qrc:/fake-ssl-error.html")); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); + QCOMPARE(spy2.count(), 1); + QCOMPARE(frame->requestedUrl(), QUrl("qrc:/fake-ssl-error.html")); + QCOMPARE(frame->url(), QUrl("qrc:/fake-ssl-error.html")); +#endif +} + +void tst_QWebFrame::requestedUrlAfterSetAndLoadFailures() +{ + QWebPage page; + QWebFrame* frame = page.mainFrame(); + + QSignalSpy spy(frame, SIGNAL(loadFinished(bool))); + + const QUrl first("http://abcdef.abcdef/"); + frame->setUrl(first); + ::waitForSignal(frame, SIGNAL(loadFinished(bool))); + QCOMPARE(frame->url(), first); + QCOMPARE(frame->requestedUrl(), first); + QVERIFY(!spy.at(0).first().toBool()); + + const QUrl second("http://abcdef.abcdef/another_page.html"); + QVERIFY(first != second); + + page.settings()->setAttribute(QWebSettings::ErrorPageEnabled, false); + + frame->load(second); + ::waitForSignal(frame, SIGNAL(loadFinished(bool))); + QCOMPARE(frame->url(), first); + QCOMPARE(frame->requestedUrl(), second); + QVERIFY(!spy.at(1).first().toBool()); + + page.settings()->setAttribute(QWebSettings::ErrorPageEnabled, true); + + frame->load(second); + ::waitForSignal(frame, SIGNAL(loadFinished(bool))); + QCOMPARE(frame->url(), second); + QCOMPARE(frame->requestedUrl(), second); + QVERIFY(!spy.at(2).first().toBool()); +} + +void tst_QWebFrame::javaScriptWindowObjectCleared_data() +{ + QTest::addColumn("html"); + QTest::addColumn("signalCount"); + QTest::newRow("with

hello world

" << 1; + // NOTE: Empty scripts no longer cause this signal to be emitted. + QTest::newRow("with empty

hello world

" << 0; + QTest::newRow("without

hello world

"); + MyPage page; + m_view->setPage(&page); + page.mainFrame()->setHtml(html); + QCOMPARE(page.alerts, 1); + QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118663", Continue); + QCOMPARE(m_view->page()->mainFrame()->toHtml(), html); +} + +class TestNetworkManager : public QNetworkAccessManager +{ +public: + TestNetworkManager(QObject* parent) : QNetworkAccessManager(parent) {} + + QList requestedUrls; + +protected: + virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest &request, QIODevice* outgoingData) { + requestedUrls.append(request.url()); + QNetworkRequest redirectedRequest = request; + redirectedRequest.setUrl(QUrl("data:text/html,

hello")); + return QNetworkAccessManager::createRequest(op, redirectedRequest, outgoingData); + } +}; + +void tst_QWebFrame::ipv6HostEncoding() +{ + TestNetworkManager* networkManager = new TestNetworkManager(m_page); + m_page->setNetworkAccessManager(networkManager); + networkManager->requestedUrls.clear(); + + QUrl baseUrl = QUrl::fromEncoded("http://[::1]/index.html"); + m_view->setHtml("

Hi", baseUrl); + m_view->page()->mainFrame()->evaluateJavaScript("var r = new XMLHttpRequest();" + "r.open('GET', 'http://[::1]/test.xml', false);" + "r.send(null);" + ); + QCOMPARE(networkManager->requestedUrls.count(), 1); + QCOMPARE(networkManager->requestedUrls.at(0), QUrl::fromEncoded("http://[::1]/test.xml")); +} + +void tst_QWebFrame::metaData() +{ + m_view->setHtml("" + " " + " " + " " + " " + ""); + + QMultiMap metaData = m_view->page()->mainFrame()->metaData(); + + QCOMPARE(metaData.count(), 2); + + QCOMPARE(metaData.value("description"), QString("Test description")); + QCOMPARE(metaData.value("keywords"), QString("HTML, JavaScript, Css")); + QCOMPARE(metaData.value("nonexistant"), QString()); + + m_view->setHtml("" + " " + " " + " " + " " + ""); + + metaData = m_view->page()->mainFrame()->metaData(); + + QCOMPARE(metaData.count(), 2); + + QStringList values = metaData.values("samekey"); + QCOMPARE(values.count(), 2); + + QVERIFY(values.contains("FirstValue")); + QVERIFY(values.contains("SecondValue")); + + QCOMPARE(metaData.value("nonexistant"), QString()); +} + +#if !defined(QT_NO_COMBOBOX) +void tst_QWebFrame::popupFocus() +{ + QWebView view; + view.setHtml("" + " " + " " + " " + " " + " " + ""); + view.resize(400, 100); + // Call setFocus before show to work around http://bugreports.qt.nokia.com/browse/QTBUG-14762 + view.setFocus(); + view.show(); + QTest::qWaitForWindowExposed(&view); + view.activateWindow(); + QTRY_VERIFY(view.hasFocus()); + + // open the popup by clicking. check if focus is on the popup + const QWebElement webCombo = view.page()->mainFrame()->documentElement().findFirst(QLatin1String("select[name=select]")); + QTest::mouseClick(&view, Qt::LeftButton, 0, webCombo.geometry().center()); + + QComboBox* combo = view.findChild(); + QVERIFY(combo != 0); + QTRY_VERIFY(!view.hasFocus() && combo->view()->hasFocus()); // Focus should be on the popup + + // hide the popup and check if focus is on the page + combo->hidePopup(); + QTRY_VERIFY(view.hasFocus()); // Focus should be back on the WebView +} +#endif + +void tst_QWebFrame::inputFieldFocus() +{ + QWebView view; + view.setHtml(""); + view.resize(400, 100); + view.show(); + QTest::qWaitForWindowExposed(&view); + view.activateWindow(); + view.setFocus(); + QTRY_VERIFY(view.hasFocus()); + + // double the flashing time, should at least blink once already + int delay = qApp->cursorFlashTime() * 2; + + // focus the lineedit and check if it blinks + bool autoSipEnabled = qApp->autoSipEnabled(); + qApp->setAutoSipEnabled(false); + const QWebElement inputElement = view.page()->mainFrame()->documentElement().findFirst(QLatin1String("input[type=text]")); + QTest::mouseClick(&view, Qt::LeftButton, 0, inputElement.geometry().center()); + m_inputFieldsTestView = &view; + view.installEventFilter( this ); + QTest::qWait(delay); + QVERIFY2(m_inputFieldTestPaintCount >= 3, + "The input field should have a blinking caret"); + qApp->setAutoSipEnabled(autoSipEnabled); +} + +void tst_QWebFrame::hitTestContent() +{ + QString html("

A paragraph




link text"); + + QWebPage page; + QWebFrame* frame = page.mainFrame(); + frame->setHtml(html); + page.setViewportSize(QSize(200, 0)); //no height so link is not visible + const QWebElement linkElement = frame->documentElement().findFirst(QLatin1String("a#link")); + QWebHitTestResult result = frame->hitTestContent(linkElement.geometry().center()); + QCOMPARE(result.linkText(), QString("link text")); + QWebElement link = result.linkElement(); + QCOMPARE(link.attribute("target"), QString("_foo")); + QCOMPARE(result.element().tagName(), QString("A")); +} + +void tst_QWebFrame::baseUrl_data() +{ + QTest::addColumn("html"); + QTest::addColumn("loadUrl"); + QTest::addColumn("url"); + QTest::addColumn("baseUrl"); + + QTest::newRow("null") << QString() << QUrl() + << QUrl("about:blank") << QUrl("about:blank"); + + QTest::newRow("foo") << QString() << QUrl("http://foobar.baz/") + << QUrl("http://foobar.baz/") << QUrl("http://foobar.baz/"); + + QString html = "" + "" + "" + "" + ""; + QTest::newRow("customBaseUrl") << html << QUrl("http://foobar.baz/") + << QUrl("http://foobar.baz/") << QUrl("http://foobaz.bar/"); +} + +void tst_QWebFrame::baseUrl() +{ + QFETCH(QString, html); + QFETCH(QUrl, loadUrl); + QFETCH(QUrl, url); + QFETCH(QUrl, baseUrl); + + m_page->mainFrame()->setHtml(html, loadUrl); + QEXPECT_FAIL("null", "https://github.com/qtwebkit/qtwebkit/issues/913", Continue); + QCOMPARE(m_page->mainFrame()->url(), url); + QEXPECT_FAIL("null", "https://github.com/qtwebkit/qtwebkit/issues/913", Continue); + QCOMPARE(m_page->mainFrame()->baseUrl(), baseUrl); +} + +void tst_QWebFrame::hasSetFocus() +{ + QString html("

top

" \ + " + + + diff --git a/tests/webkitwidgets/qwebpage/resources/iframe3.html b/tests/webkitwidgets/qwebpage/resources/iframe3.html new file mode 100644 index 000000000..ed6ac5b94 --- /dev/null +++ b/tests/webkitwidgets/qwebpage/resources/iframe3.html @@ -0,0 +1,5 @@ + + +

inner

+ + diff --git a/tests/webkitwidgets/qwebpage/resources/index.html b/tests/webkitwidgets/qwebpage/resources/index.html new file mode 100644 index 000000000..638df364e --- /dev/null +++ b/tests/webkitwidgets/qwebpage/resources/index.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/webkitwidgets/qwebpage/resources/script.html b/tests/webkitwidgets/qwebpage/resources/script.html new file mode 100644 index 000000000..ede986415 --- /dev/null +++ b/tests/webkitwidgets/qwebpage/resources/script.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/webkitwidgets/qwebpage/resources/user.css b/tests/webkitwidgets/qwebpage/resources/user.css new file mode 100644 index 000000000..4ccb2f0fc --- /dev/null +++ b/tests/webkitwidgets/qwebpage/resources/user.css @@ -0,0 +1,3 @@ +p { + background-image: url('http://does.not/exist.png'); +} \ No newline at end of file diff --git a/tests/webkitwidgets/qwebpage/tst_qwebpage.cpp b/tests/webkitwidgets/qwebpage/tst_qwebpage.cpp new file mode 100644 index 000000000..eb50384e7 --- /dev/null +++ b/tests/webkitwidgets/qwebpage/tst_qwebpage.cpp @@ -0,0 +1,3518 @@ +/* + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + Copyright (C) 2009 Girish Ramakrishnan + Copyright (C) 2010 Holger Hans Peter Freyther + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "../util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_QTTESTSUPPORT +#include "../WebCoreSupport/DumpRenderTreeSupportQt.h" +#endif + +static void removeRecursive(const QString& dirname) +{ + QDir dir(dirname); + QFileInfoList entries(dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)); + for (int i = 0; i < entries.count(); ++i) + if (entries[i].isDir()) + removeRecursive(entries[i].filePath()); + else + dir.remove(entries[i].fileName()); + QDir().rmdir(dirname); +} + +class TestInputContext : public QPlatformInputContext +{ +public: + TestInputContext() + : m_visible(false) + { + QInputMethodPrivate* inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = this; + } + + ~TestInputContext() + { + QInputMethodPrivate* inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = 0; + } + + virtual void showInputPanel() + { + m_visible = true; + } + virtual void hideInputPanel() + { + m_visible = false; + } + virtual bool isInputPanelVisible() const + { + return m_visible; + } + + bool m_visible; +}; + +class tst_QWebPage : public QObject +{ + Q_OBJECT + +public: + tst_QWebPage(); + virtual ~tst_QWebPage(); + +public Q_SLOTS: + void init(); + void cleanup(); + void cleanupFiles(); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + +#ifdef HAVE_QTTESTSUPPORT + void thirdPartyCookiePolicy(); +#endif + + void contextMenuCopy(); + void contextMenuPopulatedOnce(); + void acceptNavigationRequest(); + void domainSpecificKeyEvent(); + void geolocationRequestJS(); + void loadFinished(); + void actionStates(); + void popupFormSubmission(); + void acceptNavigationRequestWithNewWindow(); + void userStyleSheet(); + void userStyleSheetFromLocalFileUrl(); + void userStyleSheetFromQrcUrl(); + void loadHtml5Video(); + void modified(); + void contextMenuCrash(); + void updatePositionDependentActionsCrash(); + void database(); + void createPluginWithPluginsEnabled(); + void createPluginWithPluginsDisabled(); + void destroyPlugin_data(); + void destroyPlugin(); + void createViewlessPlugin_data(); + void createViewlessPlugin(); + void graphicsWidgetPlugin(); + +#ifdef HAVE_QTTESTSUPPORT + void multiplePageGroupsAndLocalStorage(); +#endif + + void cursorMovements(); + void textSelection(); + void textEditing(); + void backActionUpdate(); + void frameAt(); + void requestCache(); + void loadCachedPage(); + +#ifdef HAVE_QTTESTSUPPORT + void protectBindingsRuntimeObjectsFromCollector(); +#endif + + void localURLSchemes(); + void testOptionalJSObjects(); + void testLocalStorageVisibility(); + void testEnablePersistentStorage(); + void consoleOutput(); + void inputMethods_data(); + void inputMethods(); + void inputMethodsTextFormat_data(); + void inputMethodsTextFormat(); + void defaultTextEncoding(); + void errorPageExtension(); + void errorPageExtensionInIFrames(); + void errorPageExtensionInFrameset(); + void userAgentApplicationName(); + void userAgentNewlineStripping(); + void undoActionHaveCustomText(); + + void viewModes(); + + void crashTests_LazyInitializationOfMainFrame(); + + void screenshot_data(); + void screenshot(); + + void changeVisibilityState(); + +#if defined(ENABLE_WEBGL) && ENABLE_WEBGL + void acceleratedWebGLScreenshotWithoutView(); + void unacceleratedWebGLScreenshotWithoutView(); +#endif + + void originatingObjectInNetworkRequests(); + void networkReplyParentDidntChange(); + void destroyQNAMBeforeAbortDoesntCrash(); + void testJSPrompt(); + void showModalDialog(); + void testStopScheduledPageRefresh(); + void findText(); + void supportedContentType(); + // [Qt] tst_QWebPage::infiniteLoopJS() timeouts with DFG JIT + // https://bugs.webkit.org/show_bug.cgi?id=79040 + // void infiniteLoopJS(); + void navigatorCookieEnabled(); + void deleteQWebViewTwice(); + void renderOnRepaintRequestedShouldNotRecurse(); + void loadSignalsOrder_data(); + void loadSignalsOrder(); + void openWindowDefaultSize(); + void cssMediaTypeGlobalSetting(); + void cssMediaTypePageSetting(); + +#ifdef Q_OS_MACOS + void macCopyUnicodeToClipboard(); +#endif + +private: + QWebView* m_view { nullptr }; + QWebPage* m_page { nullptr }; + QString tmpDirPath() const + { + static QString tmpd = QDir::tempPath() + "/tst_qwebpage-" + + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss")); + return tmpd; + } +}; + +tst_QWebPage::tst_QWebPage() +{ +} + +tst_QWebPage::~tst_QWebPage() +{ +} + +void tst_QWebPage::init() +{ + m_view = new QWebView(); + m_page = m_view->page(); +} + +void tst_QWebPage::cleanup() +{ + delete m_view; +} + +void tst_QWebPage::cleanupFiles() +{ + removeRecursive(tmpDirPath()); +} + +void tst_QWebPage::initTestCase() +{ + cleanupFiles(); // In case there are old files from previous runs +} + +void tst_QWebPage::cleanupTestCase() +{ + cleanupFiles(); // Be nice +} + +class NavigationRequestOverride : public QWebPage +{ +public: + NavigationRequestOverride(QWebView* parent, bool initialValue) : QWebPage(parent), m_acceptNavigationRequest(initialValue) {} + + bool m_acceptNavigationRequest; +protected: + virtual bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, QWebPage::NavigationType type) { + Q_UNUSED(frame); + Q_UNUSED(request); + Q_UNUSED(type); + + return m_acceptNavigationRequest; + } +}; + +void tst_QWebPage::acceptNavigationRequest() +{ + QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool))); + + NavigationRequestOverride* newPage = new NavigationRequestOverride(m_view, false); + m_view->setPage(newPage); + + m_view->setHtml(QString("
" + "
"), QUrl()); + QTRY_COMPARE(loadSpy.count(), 1); + + m_view->page()->mainFrame()->evaluateJavaScript("tstform.submit();"); + + newPage->m_acceptNavigationRequest = true; + m_view->page()->mainFrame()->evaluateJavaScript("tstform.submit();"); + QTRY_COMPARE(loadSpy.count(), 2); + + QCOMPARE(m_view->page()->mainFrame()->toPlainText(), QString("foo?")); + + // Restore default page + m_view->setPage(0); +} + +void tst_QWebPage::domainSpecificKeyEvent() +{ + QWebView webView; + webView.show(); + QTest::qWaitForWindowExposed(&webView); + + webView.setHtml(QLatin1String("" + "test")); + + // Enable settings to use nativeVirtualKey as DOM key value. + webView.page()->setProperty("_q_useNativeVirtualKeyAsDOMKey", true); + // Simulate domain specific keyevent to WebKit by passing it as nativeVirtualKey in QKeyEvent. + // Qt::Key_Pause --> 0x51 + QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); + QApplication::sendEvent(&webView, &keyEvent); + keyEvent = QKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); + QApplication::sendEvent(&webView, &keyEvent); + const QLatin1String expectedReceivedKeyArray1("keydown:81:0,keyup:81:0"); + QString receivedKeyArray = webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray")).toStringList().join(","); + QVERIFY(receivedKeyArray == expectedReceivedKeyArray1); + + // Normal PC keyboard key converstion flow shouldn't be affected when sending nativeVirtual key as 0. + // Qt::Key_Pause --> VK_PAUSE(0x13) + webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray = new Array()")); // Reset + keyEvent = QKeyEvent(QEvent::KeyPress, Qt::Key_Pause, Qt::NoModifier, 0, 0, 0); + QApplication::sendEvent(&webView, &keyEvent); + keyEvent = QKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 0, 0); + QApplication::sendEvent(&webView, &keyEvent); + const QLatin1String expectedReceivedKeyArray2("keydown:19:0,keyup:19:0"); + receivedKeyArray = webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray")).toStringList().join(","); + QVERIFY(receivedKeyArray == expectedReceivedKeyArray2); + + // Negative case. + // Disable settings to use nativeVirtualKey as DOM key value. + webView.page()->setProperty("_q_useNativeVirtualKeyAsDOMKey", false); + // Qt::Key_Pause --> VK_PAUSE(0x13) + webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray = new Array()")); // Reset + keyEvent = QKeyEvent(QEvent::KeyPress, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); + QApplication::sendEvent(&webView, &keyEvent); + keyEvent = QKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); + QApplication::sendEvent(&webView, &keyEvent); + const QLatin1String expectedReceivedKeyArray3("keydown:19:0,keyup:19:0"); + receivedKeyArray = webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray")).toStringList().join(","); + QVERIFY(receivedKeyArray == expectedReceivedKeyArray3); +} + +class JSTestPage : public QWebPage +{ +Q_OBJECT +public: + JSTestPage(QObject* parent = 0) + : QWebPage(parent) {} + + virtual bool shouldInterruptJavaScript() + { + return true; + } +public Q_SLOTS: + void requestPermission(QWebFrame* frame, QWebPage::Feature feature) + { + if (m_allowGeolocation) + setFeaturePermission(frame, feature, PermissionGrantedByUser); + else + setFeaturePermission(frame, feature, PermissionDeniedByUser); + } + +public: + void setGeolocationPermission(bool allow) + { + m_allowGeolocation = allow; + } + +private: + bool m_allowGeolocation { false }; +}; + +// [Qt] tst_QWebPage::infiniteLoopJS() timeouts with DFG JIT +// https://bugs.webkit.org/show_bug.cgi?id=79040 +/* +void tst_QWebPage::infiniteLoopJS() +{ + JSTestPage* newPage = new JSTestPage(m_view); + m_view->setPage(newPage); + m_view->setHtml(QString("test"), QUrl()); + m_view->page()->mainFrame()->evaluateJavaScript("var run = true;var a = 1;while(run){a++;}"); + delete newPage; +} +*/ + +void tst_QWebPage::geolocationRequestJS() +{ + JSTestPage* newPage = new JSTestPage(m_view); + + if (newPage->mainFrame()->evaluateJavaScript(QLatin1String("!navigator.geolocation")).toBool()) { + delete newPage; + QSKIP("Geolocation is not supported.", SkipSingle); + } + + connect(newPage, SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), + newPage, SLOT(requestPermission(QWebFrame*, QWebPage::Feature))); + + newPage->setGeolocationPermission(false); + m_view->setPage(newPage); + m_view->setHtml(QString("test"), QUrl()); + m_view->page()->mainFrame()->evaluateJavaScript("var errorCode = 0; function error(err) { errorCode = err.code; } function success(pos) { } navigator.geolocation.getCurrentPosition(success, error)"); + QTest::qWait(2000); + QVariant empty = m_view->page()->mainFrame()->evaluateJavaScript("errorCode"); + + QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=102235", Continue); + QVERIFY(empty.type() == QVariant::Double && empty.toInt() != 0); + + newPage->setGeolocationPermission(true); + m_view->page()->mainFrame()->evaluateJavaScript("errorCode = 0; navigator.geolocation.getCurrentPosition(success, error);"); + empty = m_view->page()->mainFrame()->evaluateJavaScript("errorCode"); + + //http://dev.w3.org/geo/api/spec-source.html#position + //PositionError: const unsigned short PERMISSION_DENIED = 1; + QVERIFY(empty.type() == QVariant::Double && empty.toInt() != 1); + delete newPage; +} + +void tst_QWebPage::loadFinished() +{ + qRegisterMetaType("QWebFrame*"); + qRegisterMetaType("QNetworkRequest*"); + QSignalSpy spyLoadStarted(m_view, SIGNAL(loadStarted())); + QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); + + m_view->page()->mainFrame()->load(QUrl("data:text/html,foo \">" + "")); + QTRY_COMPARE(spyLoadFinished.count(), 1); + + QTRY_VERIFY(spyLoadStarted.count() > 1); + QTRY_VERIFY(spyLoadFinished.count() > 1); + + spyLoadFinished.clear(); + + m_view->page()->mainFrame()->load(QUrl("data:text/html,")); + QTRY_COMPARE(spyLoadFinished.count(), 1); + QCOMPARE(spyLoadFinished.count(), 1); +} + +void tst_QWebPage::actionStates() +{ + QWebPage* page = m_view->page(); + + page->mainFrame()->load(QUrl("qrc:///resources/script.html")); + + QAction* reloadAction = page->action(QWebPage::Reload); + QAction* stopAction = page->action(QWebPage::Stop); + + QTRY_VERIFY(reloadAction->isEnabled()); + QTRY_VERIFY(!stopAction->isEnabled()); +} + +class ConsolePage : public QWebPage +{ +public: + ConsolePage(QObject* parent = 0) : QWebPage(parent) {} + + virtual void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) + { + messages.append(message); + lineNumbers.append(lineNumber); + sourceIDs.append(sourceID); + } + + QStringList messages; + QList lineNumbers; + QStringList sourceIDs; +}; + +void tst_QWebPage::consoleOutput() +{ + ConsolePage page; + page.mainFrame()->evaluateJavaScript("this is not valid JavaScript"); + QCOMPARE(page.messages.count(), 1); + QCOMPARE(page.lineNumbers.at(0), 1); +} + +class TestPage : public QWebPage { + Q_OBJECT +public: + TestPage(QObject* parent = 0) : QWebPage(parent) + { + connect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeometryChangeRequested(QRect))); + } + + struct Navigation { + QPointer frame; + QNetworkRequest request; + NavigationType type; + }; + + QList navigations; + QList createdWindows; + QRect requestedGeometry; + + virtual bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type) { + Navigation n; + n.frame = frame; + n.request = request; + n.type = type; + navigations.append(n); + return true; + } + + virtual QWebPage* createWindow(WebWindowType) { + TestPage* page = new TestPage(this); + createdWindows.append(page); + return page; + } + +private Q_SLOTS: + void slotGeometryChangeRequested(const QRect& geom) { + requestedGeometry = geom; + } +}; + +void tst_QWebPage::popupFormSubmission() +{ + TestPage page; + page.settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); + page.mainFrame()->setHtml("
"\ + ""\ + "
"); + page.mainFrame()->evaluateJavaScript("window.open('', 'myNewWin', 'width=500,height=300,toolbar=0')"); + page.mainFrame()->evaluateJavaScript("document.form1.submit();"); + + QTest::qWait(500); + // The number of popup created should be one. + QVERIFY(page.createdWindows.size() == 1); + + QString url = page.createdWindows.takeFirst()->mainFrame()->url().toString(); + // Check if the form submission was OK. + QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118597", Continue); + QVERIFY(url.contains("?foo=bar")); +} + +void tst_QWebPage::acceptNavigationRequestWithNewWindow() +{ + TestPage* page = new TestPage(m_view); + page->settings()->setAttribute(QWebSettings::LinksIncludedInFocusChain, true); + m_page = page; + m_view->setPage(m_page); + + m_view->setUrl(QString("data:text/html,Click me")); + QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); + + QFocusEvent fe(QEvent::FocusIn); + m_page->event(&fe); + + QVERIFY(m_page->focusNextPrevChild(/*next*/ true)); + + QKeyEvent keyEnter(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier); + m_page->event(&keyEnter); + + QCOMPARE(page->navigations.count(), 2); + + TestPage::Navigation n = page->navigations.at(1); + QVERIFY(n.frame.isNull()); + QCOMPARE(n.request.url().toString(), QString("data:text/html,Reached")); + QVERIFY(n.type == QWebPage::NavigationTypeLinkClicked); + + QCOMPARE(page->createdWindows.count(), 1); +} + +class TestNetworkManager : public QNetworkAccessManager +{ +public: + TestNetworkManager(QObject* parent) : QNetworkAccessManager(parent) {} + + QList requestedUrls; + QList requests; + +protected: + virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest &request, QIODevice* outgoingData) { + requests.append(request); + requestedUrls.append(request.url()); + return QNetworkAccessManager::createRequest(op, request, outgoingData); + } +}; + +void tst_QWebPage::userStyleSheet() +{ + TestNetworkManager* networkManager = new TestNetworkManager(m_page); + m_page->setNetworkAccessManager(networkManager); + + m_page->settings()->setUserStyleSheetUrl(QUrl(QString::fromLatin1("data:text/css;charset=utf-8;base64," + + QByteArray("p { background-image: url('http://does.not/exist.png');}").toBase64()))); + m_view->setHtml("

hello world

"); + QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); + + QVERIFY(networkManager->requestedUrls.count() >= 1); + QCOMPARE(networkManager->requestedUrls.at(0), QUrl("http://does.not/exist.png")); +} + +void tst_QWebPage::userStyleSheetFromLocalFileUrl() +{ + TestNetworkManager* networkManager = new TestNetworkManager(m_page); + m_page->setNetworkAccessManager(networkManager); + + QUrl styleSheetUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebpage/resources/user.css")); + m_page->settings()->setUserStyleSheetUrl(styleSheetUrl); + m_view->setHtml("

hello world

"); + QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); + + QVERIFY(networkManager->requestedUrls.count() >= 1); + QCOMPARE(networkManager->requestedUrls.at(0), QUrl("http://does.not/exist.png")); +} + +void tst_QWebPage::userStyleSheetFromQrcUrl() +{ + TestNetworkManager* networkManager = new TestNetworkManager(m_page); + m_page->setNetworkAccessManager(networkManager); + + m_page->settings()->setUserStyleSheetUrl(QUrl("qrc:///resources/user.css")); + m_view->setHtml("

hello world

"); + QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); + + QVERIFY(networkManager->requestedUrls.count() >= 1); + QCOMPARE(networkManager->requestedUrls.at(0), QUrl("http://does.not/exist.png")); +} + +void tst_QWebPage::loadHtml5Video() +{ +#if defined(USE_QT_MULTIMEDIA) && USE_QT_MULTIMEDIA + QByteArray url("http://does.not/exist?a=1%2Cb=2"); + m_view->setHtml("

"); + QTest::qWait(2000); + QUrl mUrl = DumpRenderTreeSupportQt::mediaContentUrlByElementId(m_page->mainFrame()->handle(), "video"); + QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=65452", Continue); + QCOMPARE(mUrl.toEncoded(), url); +#else + QSKIP("This test requires Qt Multimedia", SkipAll); +#endif +} + +void tst_QWebPage::viewModes() +{ + m_view->setHtml(""); + m_page->setProperty("_q_viewMode", "minimized"); + + QVariant empty = m_page->mainFrame()->evaluateJavaScript("window.styleMedia.matchMedium(\"(-webkit-view-mode)\")"); + QVERIFY(empty.type() == QVariant::Bool && empty.toBool()); + + QVariant minimized = m_page->mainFrame()->evaluateJavaScript("window.styleMedia.matchMedium(\"(-webkit-view-mode: minimized)\")"); + QVERIFY(minimized.type() == QVariant::Bool && minimized.toBool()); + + QVariant maximized = m_page->mainFrame()->evaluateJavaScript("window.styleMedia.matchMedium(\"(-webkit-view-mode: maximized)\")"); + QVERIFY(maximized.type() == QVariant::Bool && !maximized.toBool()); +} + +void tst_QWebPage::modified() +{ + m_page->mainFrame()->setUrl(QUrl("data:text/html,blub")); + QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); + + m_page->mainFrame()->setUrl(QUrl("data:text/html,blah")); + QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); + + QVERIFY(!m_page->isModified()); + +// m_page->mainFrame()->evaluateJavaScript("alert(document.getElementById('foo'))"); + m_page->mainFrame()->evaluateJavaScript("document.getElementById('foo').focus()"); + m_page->mainFrame()->evaluateJavaScript("document.execCommand('InsertText', true, 'Test');"); + + QVERIFY(m_page->isModified()); + + m_page->mainFrame()->evaluateJavaScript("document.execCommand('Undo', true);"); + + QVERIFY(!m_page->isModified()); + + m_page->mainFrame()->evaluateJavaScript("document.execCommand('Redo', true);"); + + QVERIFY(m_page->isModified()); + + QVERIFY(m_page->history()->canGoBack()); + QVERIFY(!m_page->history()->canGoForward()); + QCOMPARE(m_page->history()->count(), 2); + QVERIFY(m_page->history()->backItem().isValid()); + QVERIFY(!m_page->history()->forwardItem().isValid()); + + m_page->history()->back(); + QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); + + QVERIFY(!m_page->history()->canGoBack()); + QVERIFY(m_page->history()->canGoForward()); + + QVERIFY(!m_page->isModified()); + + QVERIFY(m_page->history()->currentItemIndex() == 0); + + m_page->history()->setMaximumItemCount(3); + QVERIFY(m_page->history()->maximumItemCount() == 3); + + QVariant variant("string test"); + m_page->history()->currentItem().setUserData(variant); + QVERIFY(m_page->history()->currentItem().userData().toString() == "string test"); + + m_page->mainFrame()->setUrl(QUrl("data:text/html,This is second page")); + m_page->mainFrame()->setUrl(QUrl("data:text/html,This is third page")); + QVERIFY(m_page->history()->count() == 2); + m_page->mainFrame()->setUrl(QUrl("data:text/html,This is fourth page")); + QVERIFY(m_page->history()->count() == 2); + m_page->mainFrame()->setUrl(QUrl("data:text/html,This is fifth page")); + QVERIFY(::waitForSignal(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*,QWebHistoryItem*)))); +} + +// https://bugs.webkit.org/show_bug.cgi?id=51331 +void tst_QWebPage::updatePositionDependentActionsCrash() +{ + QWebView view; + view.setHtml("

test"); + QPoint pos(0, 0); + view.page()->updatePositionDependentActions(pos); + QMenu* contextMenu = 0; + foreach (QObject* child, view.children()) { + contextMenu = qobject_cast(child); + if (contextMenu) + break; + } + QVERIFY(!contextMenu); +} + +// https://bugs.webkit.org/show_bug.cgi?id=20357 +void tst_QWebPage::contextMenuCrash() +{ + QWebView view; + view.setHtml("

test"); + QPoint pos(0, 0); + QContextMenuEvent event(QContextMenuEvent::Mouse, pos); + view.page()->swallowContextMenuEvent(&event); + view.page()->updatePositionDependentActions(pos); + QMenu* contextMenu = 0; + foreach (QObject* child, view.children()) { + contextMenu = qobject_cast(child); + if (contextMenu) + break; + } + QVERIFY(contextMenu); + delete contextMenu; +} + +void tst_QWebPage::database() +{ + QString path = tmpDirPath(); + m_page->settings()->setOfflineStoragePath(path); + QVERIFY(m_page->settings()->offlineStoragePath() == path); + + QWebSettings::setOfflineStorageDefaultQuota(1024 * 1024); + QVERIFY(QWebSettings::offlineStorageDefaultQuota() == 1024 * 1024); + + m_page->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); + m_page->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); + + QString dbFileName = path + "Databases.db"; + + if (QFile::exists(dbFileName)) + QFile::remove(dbFileName); + + qRegisterMetaType("QWebFrame*"); + QSignalSpy spy(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString))); + m_view->setHtml(QString("

"), QUrl("http://www.myexample.com")); + QTRY_COMPARE(spy.count(), 1); + m_page->mainFrame()->evaluateJavaScript("var db2; db2=openDatabase('testdb', '1.0', 'test database API', 50000);"); + QTRY_COMPARE(spy.count(),1); + + m_page->mainFrame()->evaluateJavaScript("localStorage.test='This is a test for local storage';"); + m_view->setHtml(QString("text"), QUrl("http://www.myexample.com")); + + QVariant s1 = m_page->mainFrame()->evaluateJavaScript("localStorage.test"); + QCOMPARE(s1.toString(), QString("This is a test for local storage")); + + m_page->mainFrame()->evaluateJavaScript("sessionStorage.test='This is a test for session storage';"); + m_view->setHtml(QString("text"), QUrl("http://www.myexample.com")); + QVariant s2 = m_page->mainFrame()->evaluateJavaScript("sessionStorage.test"); + QCOMPARE(s2.toString(), QString("This is a test for session storage")); + + m_view->setHtml(QString("
"), QUrl("http://www.myexample.com")); + m_page->mainFrame()->evaluateJavaScript("var db3; db3=openDatabase('testdb', '1.0', 'test database API', 50000);db3.transaction(function(tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS Test (text TEXT)', []); }, function(tx, result) { }, function(tx, error) { });"); + QTest::qWait(200); + + // Remove all databases. + QWebSecurityOrigin origin = m_page->mainFrame()->securityOrigin(); + QList dbs = origin.databases(); + for (int i = 0; i < dbs.count(); i++) { + QString fileName = dbs[i].fileName(); + QVERIFY(QFile::exists(fileName)); + QWebDatabase::removeDatabase(dbs[i]); + QVERIFY(!QFile::exists(fileName)); + } + QVERIFY(!origin.databases().size()); + // Remove removed test :-) + QWebDatabase::removeAllDatabases(); + QVERIFY(!origin.databases().size()); +} + +class PluginPage : public QWebPage +{ +public: + PluginPage(QObject *parent = 0) + : QWebPage(parent) {} + + struct CallInfo + { + CallInfo(const QString &c, const QUrl &u, + const QStringList &pn, const QStringList &pv, + QObject *r) + : classid(c), url(u), paramNames(pn), + paramValues(pv), returnValue(r) + {} + QString classid; + QUrl url; + QStringList paramNames; + QStringList paramValues; + QObject *returnValue; + }; + + QList calls; + +protected: + virtual QObject *createPlugin(const QString &classid, const QUrl &url, + const QStringList ¶mNames, + const QStringList ¶mValues) + { + QObject *result = 0; + if (classid == "pushbutton") + result = new QPushButton(); +#ifndef QT_NO_INPUTDIALOG + else if (classid == "lineedit") + result = new QLineEdit(); +#endif + else if (classid == "graphicswidget") + result = new QGraphicsWidget(); + if (result) + result->setObjectName(classid); + calls.append(CallInfo(classid, url, paramNames, paramValues, result)); + return result; + } +}; + +static void createPlugin(QWebView *view) +{ + QSignalSpy loadSpy(view, SIGNAL(loadFinished(bool))); + + PluginPage* newPage = new PluginPage(view); + view->setPage(newPage); + + // type has to be application/x-qt-plugin + view->setHtml(QString("")); + QTRY_COMPARE(loadSpy.count(), 1); + QCOMPARE(newPage->calls.count(), 0); + + view->setHtml(QString("")); + QTRY_COMPARE(loadSpy.count(), 2); + QCOMPARE(newPage->calls.count(), 1); + { + PluginPage::CallInfo ci = newPage->calls.takeFirst(); + QCOMPARE(ci.classid, QString::fromLatin1("pushbutton")); + QCOMPARE(ci.url, QUrl()); + QCOMPARE(ci.paramNames.count(), 3); + QCOMPARE(ci.paramValues.count(), 3); + QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); + QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); + QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); + QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("pushbutton")); + QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); + QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mybutton")); + QVERIFY(ci.returnValue != 0); + QVERIFY(ci.returnValue->inherits("QPushButton")); + } + // test JS bindings + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("document.getElementById('mybutton').toString()").toString(), + QString::fromLatin1("[object HTMLObjectElement]")); + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mybutton.toString()").toString(), + QString::fromLatin1("[object HTMLObjectElement]")); + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mybutton.objectName").toString(), + QString::fromLatin1("string")); + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mybutton.objectName").toString(), + QString::fromLatin1("pushbutton")); + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mybutton.clicked").toString(), + QString::fromLatin1("function")); + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mybutton.clicked.toString()").toString(), + QString::fromLatin1("function clicked() {\n [native code]\n}")); + + view->setHtml(QString("" + "" + "" + "
"), QUrl("http://foo.bar.baz")); + QTRY_COMPARE(loadSpy.count(), 3); + QCOMPARE(newPage->calls.count(), 2); + { + PluginPage::CallInfo ci = newPage->calls.takeFirst(); + QCOMPARE(ci.classid, QString::fromLatin1("lineedit")); + QCOMPARE(ci.url, QUrl()); + QCOMPARE(ci.paramNames.count(), 3); + QCOMPARE(ci.paramValues.count(), 3); + QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); + QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); + QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); + QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("lineedit")); + QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); + QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("myedit")); + QVERIFY(ci.returnValue != 0); + QVERIFY(ci.returnValue->inherits("QLineEdit")); + } + { + PluginPage::CallInfo ci = newPage->calls.takeFirst(); + QCOMPARE(ci.classid, QString::fromLatin1("pushbutton")); + QCOMPARE(ci.url, QUrl()); + QCOMPARE(ci.paramNames.count(), 3); + QCOMPARE(ci.paramValues.count(), 3); + QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); + QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); + QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); + QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("pushbutton")); + QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); + QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mybutton")); + QVERIFY(ci.returnValue != 0); + QVERIFY(ci.returnValue->inherits("QPushButton")); + } +} + +void tst_QWebPage::graphicsWidgetPlugin() +{ + m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, true); + QGraphicsWebView webView; + + QSignalSpy loadSpy(&webView, SIGNAL(loadFinished(bool))); + + PluginPage* newPage = new PluginPage(&webView); + webView.setPage(newPage); + + // type has to be application/x-qt-plugin + webView.setHtml(QString("")); + QTRY_COMPARE(loadSpy.count(), 1); + QCOMPARE(newPage->calls.count(), 0); + + webView.setHtml(QString("")); + QTRY_COMPARE(loadSpy.count(), 2); + QCOMPARE(newPage->calls.count(), 1); + { + PluginPage::CallInfo ci = newPage->calls.takeFirst(); + QCOMPARE(ci.classid, QString::fromLatin1("graphicswidget")); + QCOMPARE(ci.url, QUrl()); + QCOMPARE(ci.paramNames.count(), 3); + QCOMPARE(ci.paramValues.count(), 3); + QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); + QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); + QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); + QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("graphicswidget")); + QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); + QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mygraphicswidget")); + QVERIFY(ci.returnValue); + QVERIFY(ci.returnValue->inherits("QGraphicsWidget")); + } + // test JS bindings + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("document.getElementById('mygraphicswidget').toString()").toString(), + QString::fromLatin1("[object HTMLObjectElement]")); + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mygraphicswidget.toString()").toString(), + QString::fromLatin1("[object HTMLObjectElement]")); + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mygraphicswidget.objectName").toString(), + QString::fromLatin1("string")); + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mygraphicswidget.objectName").toString(), + QString::fromLatin1("graphicswidget")); + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mygraphicswidget.geometryChanged").toString(), + QString::fromLatin1("function")); + QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mygraphicswidget.geometryChanged.toString()").toString(), + QString::fromLatin1("function geometryChanged() {\n [native code]\n}")); +} + +void tst_QWebPage::createPluginWithPluginsEnabled() +{ + m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, true); + createPlugin(m_view); +} + +void tst_QWebPage::createPluginWithPluginsDisabled() +{ + // Qt Plugins should be loaded by QtWebKit even when PluginsEnabled is + // false. The client decides whether a Qt plugin is enabled or not when + // it decides whether or not to instantiate it. + m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, false); + createPlugin(m_view); +} + +// Standard base class for template PluginTracerPage. In tests it is used as interface. +class PluginCounterPage : public QWebPage { +public: + int m_count; + QPointer m_widget; + QObject* m_pluginParent; + PluginCounterPage(QObject* parent = 0) + : QWebPage(parent) + , m_count(0) + , m_pluginParent(0) + { + settings()->setAttribute(QWebSettings::PluginsEnabled, true); + } + ~PluginCounterPage() + { + if (m_pluginParent) + m_pluginParent->deleteLater(); + } +}; + +template +class PluginTracerPage : public PluginCounterPage { +public: + PluginTracerPage(QObject* parent = 0) + : PluginCounterPage(parent) + { + // this is a dummy parent object for the created plugin + m_pluginParent = new T; + } + virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) + { + m_count++; + m_widget = new T; + // need a cast to the specific type, as QObject::setParent cannot be called, + // because it is not virtual. Instead it is necesary to call QWidget::setParent, + // which also takes a QWidget* instead of a QObject*. Therefore we need to + // upcast to T*, which is a QWidget. + static_cast(m_widget.data())->setParent(static_cast(m_pluginParent)); + return m_widget.data(); + } +}; + +class PluginFactory { +public: + enum FactoredType {QWidgetType, QGraphicsWidgetType}; + static PluginCounterPage* create(FactoredType type, QObject* parent = 0) + { + PluginCounterPage* result = 0; + switch (type) { + case QWidgetType: + result = new PluginTracerPage(parent); + break; + case QGraphicsWidgetType: + result = new PluginTracerPage(parent); + break; + default: {/*Oops*/}; + } + return result; + } + + static void prepareTestData() + { + QTest::addColumn("type"); + QTest::newRow("QWidget") << (int)PluginFactory::QWidgetType; + QTest::newRow("QGraphicsWidget") << (int)PluginFactory::QGraphicsWidgetType; + } +}; + +void tst_QWebPage::destroyPlugin_data() +{ + PluginFactory::prepareTestData(); +} + +void tst_QWebPage::destroyPlugin() +{ + QFETCH(int, type); + PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type, m_view); + m_view->setPage(page); + + // we create the plugin, so the widget should be constructed + QString content(""); + m_view->setHtml(content); + QVERIFY(page->m_widget); + QCOMPARE(page->m_count, 1); + + // navigate away, the plugin widget should be destructed + m_view->setHtml("Hi"); + QTestEventLoop::instance().enterLoop(1); + QVERIFY(!page->m_widget); +} + +void tst_QWebPage::createViewlessPlugin_data() +{ + PluginFactory::prepareTestData(); +} + +void tst_QWebPage::createViewlessPlugin() +{ + QFETCH(int, type); + PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type); + QString content(""); + page->mainFrame()->setHtml(content); + QCOMPARE(page->m_count, 1); + QVERIFY(page->m_widget); + QVERIFY(page->m_pluginParent); + QVERIFY(page->m_widget.data()->parent() == page->m_pluginParent); + delete page; + +} + +#ifdef HAVE_QTTESTSUPPORT +void tst_QWebPage::multiplePageGroupsAndLocalStorage() +{ + QDir dir(tmpDirPath()); + dir.mkdir("path1"); + dir.mkdir("path2"); + + QWebView view1; + QWebView view2; + + view1.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); + view1.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path1")); + DumpRenderTreeSupportQt::webPageSetGroupName(view1.page()->handle(), "group1"); + view2.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); + view2.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path2")); + DumpRenderTreeSupportQt::webPageSetGroupName(view2.page()->handle(), "group2"); + QCOMPARE(DumpRenderTreeSupportQt::webPageGroupName(view1.page()->handle()), QString("group1")); + QCOMPARE(DumpRenderTreeSupportQt::webPageGroupName(view2.page()->handle()), QString("group2")); + + + view1.setHtml(QString(" "), QUrl("http://www.myexample.com")); + view2.setHtml(QString(" "), QUrl("http://www.myexample.com")); + + view1.page()->mainFrame()->evaluateJavaScript("localStorage.test='value1';"); + view2.page()->mainFrame()->evaluateJavaScript("localStorage.test='value2';"); + + view1.setHtml(QString(" "), QUrl("http://www.myexample.com")); + view2.setHtml(QString(" "), QUrl("http://www.myexample.com")); + + QVariant s1 = view1.page()->mainFrame()->evaluateJavaScript("localStorage.test"); + QEXPECT_FAIL("", "https://github.com/qtwebkit/qtwebkit/issues/913", Continue); + QCOMPARE(s1.toString(), QString("value1")); + + QVariant s2 = view2.page()->mainFrame()->evaluateJavaScript("localStorage.test"); + QCOMPARE(s2.toString(), QString("value2")); + + QTest::qWait(1000); + + QFile::remove(QDir::toNativeSeparators(tmpDirPath() + "/path1/http_www.myexample.com_0.localstorage")); + QFile::remove(QDir::toNativeSeparators(tmpDirPath() + "/path2/http_www.myexample.com_0.localstorage")); + dir.rmdir(QDir::toNativeSeparators("./path1")); + dir.rmdir(QDir::toNativeSeparators("./path2")); +} +#endif + +class CursorTrackedPage : public QWebPage +{ +public: + + CursorTrackedPage(QWidget *parent = 0): QWebPage(parent) { + setViewportSize(QSize(1024, 768)); // big space + } + + QString selectedText() { + return mainFrame()->evaluateJavaScript("window.getSelection().toString()").toString(); + } + + int selectionStartOffset() { + return mainFrame()->evaluateJavaScript("window.getSelection().getRangeAt(0).startOffset").toInt(); + } + + int selectionEndOffset() { + return mainFrame()->evaluateJavaScript("window.getSelection().getRangeAt(0).endOffset").toInt(); + } + + // true if start offset == end offset, i.e. no selected text + int isSelectionCollapsed() { + return mainFrame()->evaluateJavaScript("window.getSelection().getRangeAt(0).collapsed").toBool(); + } +}; + +void tst_QWebPage::cursorMovements() +{ + CursorTrackedPage* page = new CursorTrackedPage; + QString content("

The quick brown fox

jumps over the lazy dog

May the source
be with you!

"); + page->mainFrame()->setHtml(content); + + // this will select the first paragraph + QString script = "var range = document.createRange(); " \ + "var node = document.getElementById(\"one\"); " \ + "range.selectNode(node); " \ + "getSelection().addRange(range);"; + page->mainFrame()->evaluateJavaScript(script); + QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox")); + + QRegExp regExp(" style=\".*\""); + regExp.setMinimal(true); + QCOMPARE(page->selectedHtml().trimmed().replace(regExp, ""), QString::fromLatin1("

The quick brown fox

")); + + // these actions must exist + QVERIFY(page->action(QWebPage::MoveToNextChar) != 0); + QVERIFY(page->action(QWebPage::MoveToPreviousChar) != 0); + QVERIFY(page->action(QWebPage::MoveToNextWord) != 0); + QVERIFY(page->action(QWebPage::MoveToPreviousWord) != 0); + QVERIFY(page->action(QWebPage::MoveToNextLine) != 0); + QVERIFY(page->action(QWebPage::MoveToPreviousLine) != 0); + QVERIFY(page->action(QWebPage::MoveToStartOfLine) != 0); + QVERIFY(page->action(QWebPage::MoveToEndOfLine) != 0); + QVERIFY(page->action(QWebPage::MoveToStartOfBlock) != 0); + QVERIFY(page->action(QWebPage::MoveToEndOfBlock) != 0); + QVERIFY(page->action(QWebPage::MoveToStartOfDocument) != 0); + QVERIFY(page->action(QWebPage::MoveToEndOfDocument) != 0); + + // right now they are disabled because contentEditable is false + QCOMPARE(page->action(QWebPage::MoveToNextChar)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::MoveToPreviousChar)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::MoveToNextWord)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::MoveToPreviousWord)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::MoveToNextLine)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::MoveToPreviousLine)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::MoveToStartOfLine)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::MoveToEndOfLine)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::MoveToStartOfBlock)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::MoveToEndOfBlock)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::MoveToStartOfDocument)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::MoveToEndOfDocument)->isEnabled(), false); + + // make it editable before navigating the cursor + page->setContentEditable(true); + + // here the actions are enabled after contentEditable is true + QCOMPARE(page->action(QWebPage::MoveToNextChar)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::MoveToPreviousChar)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::MoveToNextWord)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::MoveToPreviousWord)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::MoveToNextLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::MoveToPreviousLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::MoveToStartOfLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::MoveToEndOfLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::MoveToStartOfBlock)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::MoveToEndOfBlock)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::MoveToStartOfDocument)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::MoveToEndOfDocument)->isEnabled(), true); + + // cursor will be before the word "jump" + page->triggerAction(QWebPage::MoveToNextChar); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 0); + + // cursor will be between 'j' and 'u' in the word "jump" + page->triggerAction(QWebPage::MoveToNextChar); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 1); + + // cursor will be between 'u' and 'm' in the word "jump" + page->triggerAction(QWebPage::MoveToNextChar); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 2); + + // cursor will be after the word "jump" + page->triggerAction(QWebPage::MoveToNextWord); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 5); + + // cursor will be after the word "lazy" + page->triggerAction(QWebPage::MoveToNextWord); + page->triggerAction(QWebPage::MoveToNextWord); + page->triggerAction(QWebPage::MoveToNextWord); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 19); + + // cursor will be between 'z' and 'y' in "lazy" + page->triggerAction(QWebPage::MoveToPreviousChar); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 18); + + // cursor will be between 'a' and 'z' in "lazy" + page->triggerAction(QWebPage::MoveToPreviousChar); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 17); + + // cursor will be before the word "lazy" + page->triggerAction(QWebPage::MoveToPreviousWord); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 15); + + // cursor will be before the word "quick" + page->triggerAction(QWebPage::MoveToPreviousWord); + page->triggerAction(QWebPage::MoveToPreviousWord); + page->triggerAction(QWebPage::MoveToPreviousWord); + page->triggerAction(QWebPage::MoveToPreviousWord); + page->triggerAction(QWebPage::MoveToPreviousWord); + page->triggerAction(QWebPage::MoveToPreviousWord); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 4); + + // cursor will be between 'p' and 's' in the word "jumps" + page->triggerAction(QWebPage::MoveToNextWord); + page->triggerAction(QWebPage::MoveToNextWord); + page->triggerAction(QWebPage::MoveToNextWord); + page->triggerAction(QWebPage::MoveToNextChar); + page->triggerAction(QWebPage::MoveToNextChar); + page->triggerAction(QWebPage::MoveToNextChar); + page->triggerAction(QWebPage::MoveToNextChar); + page->triggerAction(QWebPage::MoveToNextChar); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 4); + + // cursor will be before the word "jumps" + page->triggerAction(QWebPage::MoveToStartOfLine); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 0); + + // cursor will be after the word "dog" + page->triggerAction(QWebPage::MoveToEndOfLine); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 23); + + // cursor will be between 'w' and 'n' in "brown" + page->triggerAction(QWebPage::MoveToStartOfLine); + page->triggerAction(QWebPage::MoveToPreviousWord); + page->triggerAction(QWebPage::MoveToPreviousWord); + page->triggerAction(QWebPage::MoveToNextChar); + page->triggerAction(QWebPage::MoveToNextChar); + page->triggerAction(QWebPage::MoveToNextChar); + page->triggerAction(QWebPage::MoveToNextChar); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 14); + + // cursor will be after the word "fox" + page->triggerAction(QWebPage::MoveToEndOfLine); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 19); + + // cursor will be before the word "The" + page->triggerAction(QWebPage::MoveToStartOfDocument); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 0); + + // cursor will be after the word "you!" + page->triggerAction(QWebPage::MoveToEndOfDocument); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 12); + + // cursor will be before the word "be" + page->triggerAction(QWebPage::MoveToStartOfBlock); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 0); + + // cursor will be after the word "you!" + page->triggerAction(QWebPage::MoveToEndOfBlock); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 12); + + // try to move before the document start + page->triggerAction(QWebPage::MoveToStartOfDocument); + page->triggerAction(QWebPage::MoveToPreviousChar); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 0); + page->triggerAction(QWebPage::MoveToStartOfDocument); + page->triggerAction(QWebPage::MoveToPreviousWord); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 0); + + // try to move past the document end + page->triggerAction(QWebPage::MoveToEndOfDocument); + page->triggerAction(QWebPage::MoveToNextChar); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 12); + page->triggerAction(QWebPage::MoveToEndOfDocument); + page->triggerAction(QWebPage::MoveToNextWord); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 12); + + delete page; +} + +void tst_QWebPage::textSelection() +{ + CursorTrackedPage* page = new CursorTrackedPage; + QString content("

The quick brown fox

" \ + "

jumps over the lazy dog

" \ + "

May the source
be with you!

"); + page->mainFrame()->setHtml(content); + + // these actions must exist + QVERIFY(page->action(QWebPage::SelectAll) != 0); + QVERIFY(page->action(QWebPage::SelectNextChar) != 0); + QVERIFY(page->action(QWebPage::SelectPreviousChar) != 0); + QVERIFY(page->action(QWebPage::SelectNextWord) != 0); + QVERIFY(page->action(QWebPage::SelectPreviousWord) != 0); + QVERIFY(page->action(QWebPage::SelectNextLine) != 0); + QVERIFY(page->action(QWebPage::SelectPreviousLine) != 0); + QVERIFY(page->action(QWebPage::SelectStartOfLine) != 0); + QVERIFY(page->action(QWebPage::SelectEndOfLine) != 0); + QVERIFY(page->action(QWebPage::SelectStartOfBlock) != 0); + QVERIFY(page->action(QWebPage::SelectEndOfBlock) != 0); + QVERIFY(page->action(QWebPage::SelectStartOfDocument) != 0); + QVERIFY(page->action(QWebPage::SelectEndOfDocument) != 0); + + // right now they are disabled because contentEditable is false and + // there isn't an existing selection to modify + QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SelectPreviousWord)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SelectNextLine)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SelectPreviousLine)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SelectStartOfLine)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SelectEndOfLine)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SelectStartOfBlock)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SelectEndOfBlock)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SelectStartOfDocument)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SelectEndOfDocument)->isEnabled(), false); + + // ..but SelectAll is awalys enabled + QCOMPARE(page->action(QWebPage::SelectAll)->isEnabled(), true); + + // Verify hasSelection returns false since there is no selection yet... + QCOMPARE(page->hasSelection(), false); + + // this will select the first paragraph + QString selectScript = "var range = document.createRange(); " \ + "var node = document.getElementById(\"one\"); " \ + "range.selectNode(node); " \ + "getSelection().addRange(range);"; + page->mainFrame()->evaluateJavaScript(selectScript); + QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox")); + QRegExp regExp(" style=\".*\""); + regExp.setMinimal(true); + QCOMPARE(page->selectedHtml().trimmed().replace(regExp, ""), QString::fromLatin1("

The quick brown fox

")); + + // Make sure hasSelection returns true, since there is selected text now... + QCOMPARE(page->hasSelection(), true); + + // here the actions are enabled after a selection has been created + QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectPreviousWord)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectNextLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectPreviousLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectStartOfLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectEndOfLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectStartOfBlock)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectEndOfBlock)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectStartOfDocument)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectEndOfDocument)->isEnabled(), true); + + // make it editable before navigating the cursor + page->setContentEditable(true); + + // cursor will be before the word "The", this makes sure there is a charet + page->triggerAction(QWebPage::MoveToStartOfDocument); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 0); + + // here the actions are enabled after contentEditable is true + QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectPreviousWord)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectNextLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectPreviousLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectStartOfLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectEndOfLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectStartOfBlock)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectEndOfBlock)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectStartOfDocument)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectEndOfDocument)->isEnabled(), true); + + delete page; +} + +void tst_QWebPage::textEditing() +{ + CursorTrackedPage* page = new CursorTrackedPage; + QString content("

The quick brown fox

" \ + "

jumps over the lazy dog

" \ + "

May the source
be with you!

"); + page->mainFrame()->setHtml(content); + + // these actions must exist + QVERIFY(page->action(QWebPage::Cut) != 0); + QVERIFY(page->action(QWebPage::Copy) != 0); + QVERIFY(page->action(QWebPage::Paste) != 0); + QVERIFY(page->action(QWebPage::DeleteStartOfWord) != 0); + QVERIFY(page->action(QWebPage::DeleteEndOfWord) != 0); + QVERIFY(page->action(QWebPage::SetTextDirectionDefault) != 0); + QVERIFY(page->action(QWebPage::SetTextDirectionLeftToRight) != 0); + QVERIFY(page->action(QWebPage::SetTextDirectionRightToLeft) != 0); + QVERIFY(page->action(QWebPage::ToggleBold) != 0); + QVERIFY(page->action(QWebPage::ToggleItalic) != 0); + QVERIFY(page->action(QWebPage::ToggleUnderline) != 0); + QVERIFY(page->action(QWebPage::InsertParagraphSeparator) != 0); + QVERIFY(page->action(QWebPage::InsertLineSeparator) != 0); + QVERIFY(page->action(QWebPage::PasteAndMatchStyle) != 0); + QVERIFY(page->action(QWebPage::RemoveFormat) != 0); + QVERIFY(page->action(QWebPage::ToggleStrikethrough) != 0); + QVERIFY(page->action(QWebPage::ToggleSubscript) != 0); + QVERIFY(page->action(QWebPage::ToggleSuperscript) != 0); + QVERIFY(page->action(QWebPage::InsertUnorderedList) != 0); + QVERIFY(page->action(QWebPage::InsertOrderedList) != 0); + QVERIFY(page->action(QWebPage::Indent) != 0); + QVERIFY(page->action(QWebPage::Outdent) != 0); + QVERIFY(page->action(QWebPage::AlignCenter) != 0); + QVERIFY(page->action(QWebPage::AlignJustified) != 0); + QVERIFY(page->action(QWebPage::AlignLeft) != 0); + QVERIFY(page->action(QWebPage::AlignRight) != 0); + + // right now they are disabled because contentEditable is false + QCOMPARE(page->action(QWebPage::Cut)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::Paste)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::DeleteStartOfWord)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::DeleteEndOfWord)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SetTextDirectionDefault)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SetTextDirectionLeftToRight)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::SetTextDirectionRightToLeft)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::ToggleBold)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::ToggleItalic)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::ToggleUnderline)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::InsertParagraphSeparator)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::InsertLineSeparator)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::PasteAndMatchStyle)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::RemoveFormat)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::ToggleStrikethrough)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::ToggleSubscript)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::ToggleSuperscript)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::InsertUnorderedList)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::InsertOrderedList)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::Indent)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::Outdent)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::AlignCenter)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::AlignJustified)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::AlignLeft)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::AlignRight)->isEnabled(), false); + + // Select everything + page->triggerAction(QWebPage::SelectAll); + + // make sure it is enabled since there is a selection + QCOMPARE(page->action(QWebPage::Copy)->isEnabled(), true); + + // make it editable before navigating the cursor + page->setContentEditable(true); + + // clear the selection + page->triggerAction(QWebPage::MoveToStartOfDocument); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 0); + + // make sure it is disabled since there isn't a selection + QCOMPARE(page->action(QWebPage::Copy)->isEnabled(), false); + + // here the actions are enabled after contentEditable is true + QCOMPARE(page->action(QWebPage::Paste)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::DeleteStartOfWord)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::DeleteEndOfWord)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SetTextDirectionDefault)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SetTextDirectionLeftToRight)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SetTextDirectionRightToLeft)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::ToggleBold)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::ToggleItalic)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::ToggleUnderline)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::InsertParagraphSeparator)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::InsertLineSeparator)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::PasteAndMatchStyle)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::ToggleStrikethrough)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::ToggleSubscript)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::ToggleSuperscript)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::InsertUnorderedList)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::InsertOrderedList)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::Indent)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::Outdent)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::AlignCenter)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::AlignJustified)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::AlignLeft)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::AlignRight)->isEnabled(), true); + + // make sure these are disabled since there isn't a selection + QCOMPARE(page->action(QWebPage::Cut)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::RemoveFormat)->isEnabled(), false); + + // make sure everything is selected + page->triggerAction(QWebPage::SelectAll); + + // this is only true if there is an editable selection + QCOMPARE(page->action(QWebPage::Cut)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::RemoveFormat)->isEnabled(), true); + + delete page; +} + +void tst_QWebPage::requestCache() +{ + TestPage page; + QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); + + page.mainFrame()->setUrl(QString("data:text/html,Click me")); + QTRY_COMPARE(loadSpy.count(), 1); + QTRY_COMPARE(page.navigations.count(), 1); + + page.mainFrame()->setUrl(QString("data:text/html,Click me2")); + QTRY_COMPARE(loadSpy.count(), 2); + QTRY_COMPARE(page.navigations.count(), 2); + + page.triggerAction(QWebPage::Stop); + QVERIFY(page.history()->canGoBack()); + page.triggerAction(QWebPage::Back); + + QTRY_COMPARE(loadSpy.count(), 3); + QTRY_COMPARE(page.navigations.count(), 3); + QCOMPARE(page.navigations.at(0).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(), + (int)QNetworkRequest::PreferNetwork); + QCOMPARE(page.navigations.at(1).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(), + (int)QNetworkRequest::PreferNetwork); + QCOMPARE(page.navigations.at(2).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(), + (int)QNetworkRequest::PreferCache); +} + +void tst_QWebPage::loadCachedPage() +{ + TestPage page; + QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); + page.settings()->setMaximumPagesInCache(3); + + page.mainFrame()->load(QUrl("data:text/html,This is first page")); + + QTRY_COMPARE(loadSpy.count(), 1); + QTRY_COMPARE(page.navigations.count(), 1); + + QUrl firstPageUrl = page.mainFrame()->url(); + page.mainFrame()->load(QUrl("data:text/html,This is second page")); + + QTRY_COMPARE(loadSpy.count(), 2); + QTRY_COMPARE(page.navigations.count(), 2); + + page.triggerAction(QWebPage::Stop); + QVERIFY(page.history()->canGoBack()); + + QSignalSpy urlSpy(page.mainFrame(), SIGNAL(urlChanged(QUrl))); + QVERIFY(urlSpy.isValid()); + + page.triggerAction(QWebPage::Back); + ::waitForSignal(page.mainFrame(), SIGNAL(urlChanged(QUrl))); + QCOMPARE(urlSpy.size(), 1); + + QList arguments1 = urlSpy.takeFirst(); + QCOMPARE(arguments1.at(0).toUrl(), firstPageUrl); + +} +void tst_QWebPage::backActionUpdate() +{ + QWebView view; + QWebPage *page = view.page(); + QAction *action = page->action(QWebPage::Back); + QVERIFY(!action->isEnabled()); + QSignalSpy loadSpy(page, SIGNAL(loadFinished(bool))); + QUrl url = QUrl("qrc:///resources/framedindex.html"); + page->mainFrame()->load(url); + QTRY_COMPARE(loadSpy.count(), 1); + QEXPECT_FAIL("", "https://github.com/qtwebkit/qtwebkit/issues/913", Continue); + QVERIFY(!action->isEnabled()); + QTest::mouseClick(&view, Qt::LeftButton, 0, QPoint(10, 10)); + QTRY_COMPARE(loadSpy.count(), 2); + + QVERIFY(action->isEnabled()); +} + +void frameAtHelper(QWebPage* webPage, QWebFrame* webFrame, QPoint framePosition) +{ + if (!webFrame) + return; + + framePosition += QPoint(webFrame->pos()); + QList children = webFrame->childFrames(); + for (int i = 0; i < children.size(); ++i) { + if (children.at(i)->childFrames().size() > 0) + frameAtHelper(webPage, children.at(i), framePosition); + + QRect frameRect(children.at(i)->pos() + framePosition, children.at(i)->geometry().size()); + QVERIFY(children.at(i) == webPage->frameAt(frameRect.topLeft())); + } +} + +void tst_QWebPage::frameAt() +{ + QWebView webView; + QWebPage* webPage = webView.page(); + QSignalSpy loadSpy(webPage, SIGNAL(loadFinished(bool))); + QUrl url = QUrl("qrc:///resources/iframe.html"); + webPage->mainFrame()->load(url); + QTRY_COMPARE(loadSpy.count(), 1); + frameAtHelper(webPage, webPage->mainFrame(), webPage->mainFrame()->pos()); +} + +void tst_QWebPage::inputMethods_data() +{ + QTest::addColumn("viewType"); + QTest::newRow("QWebView") << "QWebView"; + QTest::newRow("QGraphicsWebView") << "QGraphicsWebView"; +} + +static Qt::InputMethodHints inputMethodHints(QObject* object) +{ + if (QGraphicsObject* o = qobject_cast(object)) + return o->inputMethodHints(); + if (QWidget* w = qobject_cast(object)) + return w->inputMethodHints(); + return Qt::InputMethodHints(); +} + +static bool inputMethodEnabled(QObject* object) +{ + if (QGraphicsObject* o = qobject_cast(object)) + return o->flags() & QGraphicsItem::ItemAcceptsInputMethod; + if (QWidget* w = qobject_cast(object)) + return w->testAttribute(Qt::WA_InputMethodEnabled); + return false; +} + +static void clickOnPage(QWebPage* page, const QPoint& position) +{ + QMouseEvent evpres(QEvent::MouseButtonPress, position, Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + page->event(&evpres); + QMouseEvent evrel(QEvent::MouseButtonRelease, position, Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + page->event(&evrel); +} + +void tst_QWebPage::inputMethods() +{ + QFETCH(QString, viewType); + QWebPage* page = new QWebPage; + QObject* view = 0; + QObject* container = 0; + if (viewType == "QWebView") { + QWebView* wv = new QWebView; + wv->setPage(page); + view = wv; + container = view; + } else if (viewType == "QGraphicsWebView") { + QGraphicsWebView* wv = new QGraphicsWebView; + wv->setPage(page); + view = wv; + + QGraphicsView* gv = new QGraphicsView; + QGraphicsScene* scene = new QGraphicsScene(gv); + gv->setScene(scene); + scene->addItem(wv); + wv->setGeometry(QRect(0, 0, 500, 500)); + + container = gv; + } else + QVERIFY2(false, "Unknown view type"); + + page->settings()->setFontFamily(QWebSettings::SerifFont, page->settings()->fontFamily(QWebSettings::FixedFont)); + page->mainFrame()->setHtml("" \ + "
" \ + "" \ + ""); + page->mainFrame()->setFocus(); + + TestInputContext testContext; + + QWebElementCollection inputs = page->mainFrame()->documentElement().findAll("input"); + QPoint textInputCenter = inputs.at(0).geometry().center(); + + clickOnPage(page, textInputCenter); + + // This part of the test checks if the SIP (Software Input Panel) is triggered, + // which normally happens on mobile platforms, when a user input form receives + // a mouse click. + int inputPanel = 0; + if (viewType == "QWebView") { + if (QWebView* wv = qobject_cast(view)) + inputPanel = wv->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel); + } else if (viewType == "QGraphicsWebView") { + if (QGraphicsWebView* wv = qobject_cast(view)) + inputPanel = wv->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel); + } + + // For non-mobile platforms RequestSoftwareInputPanel event is not called + // because there is no SIP (Software Input Panel) triggered. In the case of a + // mobile platform, an input panel, e.g. virtual keyboard, is usually invoked + // and the RequestSoftwareInputPanel event is called. For these two situations + // this part of the test can verified as the checks below. + if (inputPanel) + QVERIFY(testContext.isInputPanelVisible()); + else + QVERIFY(!testContext.isInputPanelVisible()); + testContext.hideInputPanel(); + + clickOnPage(page, textInputCenter); + QVERIFY(testContext.isInputPanelVisible()); + + //ImMicroFocus + QVariant variant = page->inputMethodQuery(Qt::ImMicroFocus); + QVERIFY(inputs.at(0).geometry().contains(variant.toRect().topLeft())); + + // We assigned the serif font famility to be the same as the fixef font family. + // Then test ImFont on a serif styled element, we should get our fixef font family. + variant = page->inputMethodQuery(Qt::ImFont); + QFont font = variant.value(); + QCOMPARE(page->settings()->fontFamily(QWebSettings::FixedFont), font.family()); + + QList inputAttributes; + + //Insert text. + { + QInputMethodEvent eventText("QtWebKit", inputAttributes); + QSignalSpy signalSpy(page, SIGNAL(microFocusChanged())); + page->event(&eventText); + QCOMPARE(signalSpy.count(), 0); + } + + { + QInputMethodEvent eventText("", inputAttributes); + eventText.setCommitString(QString("QtWebKit"), 0, 0); + page->event(&eventText); + } + + //ImMaximumTextLength + variant = page->inputMethodQuery(Qt::ImMaximumTextLength); + QCOMPARE(20, variant.toInt()); + + //Set selection + inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 3, 2, QVariant()); + QInputMethodEvent eventSelection("",inputAttributes); + page->event(&eventSelection); + + //ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + int anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 3); + + //ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + int cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 5); + + //ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + QString selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("eb")); + + //Set selection with negative length + inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 6, -5, QVariant()); + QInputMethodEvent eventSelection3("",inputAttributes); + page->event(&eventSelection3); + + //ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 1); + + //ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 6); + + //ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("tWebK")); + + //ImSurroundingText + variant = page->inputMethodQuery(Qt::ImSurroundingText); + QString value = variant.value(); + QCOMPARE(value, QString("QtWebKit")); + + { + QList attributes; + // Clear the selection, so the next test does not clear any contents. + QInputMethodEvent::Attribute newSelection(QInputMethodEvent::Selection, 0, 0, QVariant()); + attributes.append(newSelection); + QInputMethodEvent event("composition", attributes); + page->event(&event); + } + + // A ongoing composition should not change the surrounding text before it is committed. + variant = page->inputMethodQuery(Qt::ImSurroundingText); + value = variant.value(); + QCOMPARE(value, QString("QtWebKit")); + + // Cancel current composition first + inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant()); + QInputMethodEvent eventSelection4("", inputAttributes); + page->event(&eventSelection4); + + // START - Tests for Selection when the Editor is NOT in Composition mode + + // LEFT to RIGHT selection + // Deselect the selection by sending MouseButtonPress events + // This moves the current cursor to the end of the text + clickOnPage(page, textInputCenter); + + { + QList attributes; + QInputMethodEvent event(QString(), attributes); + event.setCommitString("XXX", 0, 0); + page->event(&event); + event.setCommitString(QString(), -2, 2); // Erase two characters. + page->event(&event); + event.setCommitString(QString(), -1, 1); // Erase one character. + page->event(&event); + variant = page->inputMethodQuery(Qt::ImSurroundingText); + value = variant.value(); + QCOMPARE(value, QString("QtWebKit")); + } + + //Move to the start of the line + page->triggerAction(QWebPage::MoveToStartOfLine); + + QKeyEvent keyRightEventPress(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier); + QKeyEvent keyRightEventRelease(QEvent::KeyRelease, Qt::Key_Right, Qt::NoModifier); + + //Move 2 characters RIGHT + for (int j = 0; j < 2; ++j) { + page->event(&keyRightEventPress); + page->event(&keyRightEventRelease); + } + + //Select to the end of the line + page->triggerAction(QWebPage::SelectEndOfLine); + + //ImAnchorPosition QtWebKit + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 2); + + //ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 8); + + //ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("WebKit")); + + //RIGHT to LEFT selection + //Deselect the selection (this moves the current cursor to the end of the text) + clickOnPage(page, textInputCenter); + + //ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 8); + + //ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 8); + + //ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("")); + + QKeyEvent keyLeftEventPress(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); + QKeyEvent keyLeftEventRelease(QEvent::KeyRelease, Qt::Key_Left, Qt::NoModifier); + + //Move 2 characters LEFT + for (int i = 0; i < 2; ++i) { + page->event(&keyLeftEventPress); + page->event(&keyLeftEventRelease); + } + + //Select to the start of the line + page->triggerAction(QWebPage::SelectStartOfLine); + + //ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 6); + + //ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 0); + + //ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("QtWebK")); + + //END - Tests for Selection when the Editor is not in Composition mode + + //ImhHiddenText + QPoint passwordInputCenter = inputs.at(1).geometry().center(); + clickOnPage(page, passwordInputCenter); + + QVERIFY(inputMethodEnabled(view)); + QVERIFY(inputMethodHints(view) & Qt::ImhHiddenText); + + clickOnPage(page, textInputCenter); + QVERIFY(!(inputMethodHints(view) & Qt::ImhHiddenText)); + + page->mainFrame()->setHtml("

nothing to input here"); + testContext.hideInputPanel(); + + QWebElement para = page->mainFrame()->findFirstElement("p"); + clickOnPage(page, para.geometry().center()); + + QVERIFY(!testContext.isInputPanelVisible()); + + //START - Test for sending empty QInputMethodEvent + page->mainFrame()->setHtml("" \ + "" \ + ""); + page->mainFrame()->evaluateJavaScript("var inputEle = document.getElementById('input3'); inputEle.focus(); inputEle.select();"); + + //Send empty QInputMethodEvent + QInputMethodEvent emptyEvent; + page->event(&emptyEvent); + + QString inputValue = page->mainFrame()->evaluateJavaScript("document.getElementById('input3').value").toString(); + QCOMPARE(inputValue, QString("QtWebKit2")); + //END - Test for sending empty QInputMethodEvent + + page->mainFrame()->setHtml("" \ + "" \ + ""); + page->mainFrame()->evaluateJavaScript("var inputEle = document.getElementById('input4'); inputEle.focus(); inputEle.select();"); + + // Clear the selection, also cancel the ongoing composition if there is one. + { + QList attributes; + QInputMethodEvent::Attribute newSelection(QInputMethodEvent::Selection, 0, 0, QVariant()); + attributes.append(newSelection); + QInputMethodEvent event("", attributes); + page->event(&event); + } + + // ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("")); + + variant = page->inputMethodQuery(Qt::ImSurroundingText); + QString surroundingValue = variant.value(); + QCOMPARE(surroundingValue, QString("QtWebKit inputMethod")); + + // ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 0); + + // ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 0); + + // 1. Insert a character to the begining of the line. + // Send temporary text, which makes the editor has composition 'm'. + { + QList attributes; + QInputMethodEvent event("m", attributes); + page->event(&event); + } + + // ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("")); + + // ImSurroundingText + variant = page->inputMethodQuery(Qt::ImSurroundingText); + surroundingValue = variant.value(); + QCOMPARE(surroundingValue, QString("QtWebKit inputMethod")); + + // ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 0); + + // ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 0); + + // Send temporary text, which makes the editor has composition 'n'. + { + QList attributes; + QInputMethodEvent event("n", attributes); + page->event(&event); + } + + // ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("")); + + // ImSurroundingText + variant = page->inputMethodQuery(Qt::ImSurroundingText); + surroundingValue = variant.value(); + QCOMPARE(surroundingValue, QString("QtWebKit inputMethod")); + + // ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 0); + + // ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 0); + + // Send commit text, which makes the editor conforms composition. + { + QList attributes; + QInputMethodEvent event("", attributes); + event.setCommitString("o"); + page->event(&event); + } + + // ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("")); + + // ImSurroundingText + variant = page->inputMethodQuery(Qt::ImSurroundingText); + surroundingValue = variant.value(); + QCOMPARE(surroundingValue, QString("oQtWebKit inputMethod")); + + // ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 1); + + // ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 1); + + // 2. insert a character to the middle of the line. + // Send temporary text, which makes the editor has composition 'd'. + { + QList attributes; + QInputMethodEvent event("d", attributes); + page->event(&event); + } + + // ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("")); + + // ImSurroundingText + variant = page->inputMethodQuery(Qt::ImSurroundingText); + surroundingValue = variant.value(); + QCOMPARE(surroundingValue, QString("oQtWebKit inputMethod")); + + // ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 1); + + // ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 1); + + // Send commit text, which makes the editor conforms composition. + { + QList attributes; + QInputMethodEvent event("", attributes); + event.setCommitString("e"); + page->event(&event); + } + + // ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("")); + + // ImSurroundingText + variant = page->inputMethodQuery(Qt::ImSurroundingText); + surroundingValue = variant.value(); + QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethod")); + + // ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 2); + + // ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 2); + + // 3. Insert a character to the end of the line. + page->triggerAction(QWebPage::MoveToEndOfLine); + + // Send temporary text, which makes the editor has composition 't'. + { + QList attributes; + QInputMethodEvent event("t", attributes); + page->event(&event); + } + + // ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("")); + + // ImSurroundingText + variant = page->inputMethodQuery(Qt::ImSurroundingText); + surroundingValue = variant.value(); + QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethod")); + + // ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 22); + + // ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 22); + + // Send commit text, which makes the editor conforms composition. + { + QList attributes; + QInputMethodEvent event("", attributes); + event.setCommitString("t"); + page->event(&event); + } + + // ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("")); + + // ImSurroundingText + variant = page->inputMethodQuery(Qt::ImSurroundingText); + surroundingValue = variant.value(); + QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethodt")); + + // ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 23); + + // ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 23); + + // 4. Replace the selection. + page->triggerAction(QWebPage::SelectPreviousWord); + + // ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("inputMethodt")); + + // ImSurroundingText + variant = page->inputMethodQuery(Qt::ImSurroundingText); + surroundingValue = variant.value(); + QCOMPARE(surroundingValue, QString("oeQtWebKit inputMethodt")); + + // ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 11); + + // ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 23); + + // Send temporary text, which makes the editor has composition 'w'. + { + QList attributes; + QInputMethodEvent event("w", attributes); + page->event(&event); + } + + // ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("")); + + // ImSurroundingText + variant = page->inputMethodQuery(Qt::ImSurroundingText); + surroundingValue = variant.value(); + QCOMPARE(surroundingValue, QString("oeQtWebKit ")); + + // ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 11); + + // ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 11); + + // Send commit text, which makes the editor conforms composition. + { + QList attributes; + QInputMethodEvent event("", attributes); + event.setCommitString("2"); + page->event(&event); + } + + // ImCurrentSelection + variant = page->inputMethodQuery(Qt::ImCurrentSelection); + selectionValue = variant.value(); + QCOMPARE(selectionValue, QString("")); + + // ImSurroundingText + variant = page->inputMethodQuery(Qt::ImSurroundingText); + surroundingValue = variant.value(); + QCOMPARE(surroundingValue, QString("oeQtWebKit 2")); + + // ImCursorPosition + variant = page->inputMethodQuery(Qt::ImCursorPosition); + cursorPosition = variant.toInt(); + QCOMPARE(cursorPosition, 12); + + // ImAnchorPosition + variant = page->inputMethodQuery(Qt::ImAnchorPosition); + anchorPosition = variant.toInt(); + QCOMPARE(anchorPosition, 12); + + // Check sending RequestSoftwareInputPanel event + page->mainFrame()->setHtml("" \ + "" \ + "

abc
"\ + ""); + QWebElement inputElement = page->mainFrame()->findFirstElement("div"); + clickOnPage(page, inputElement.geometry().center()); + + QVERIFY(!testContext.isInputPanelVisible()); + + // START - Newline test for textarea + qApp->processEvents(); + page->mainFrame()->setHtml("" \ + "
+ diff --git a/tests/webkitwidgets/qwebview/resources/scrolltest_page.html b/tests/webkitwidgets/qwebview/resources/scrolltest_page.html new file mode 100644 index 000000000..18fcbbebe --- /dev/null +++ b/tests/webkitwidgets/qwebview/resources/scrolltest_page.html @@ -0,0 +1,6 @@ + +Scrolling test + +
+ + diff --git a/tests/webkitwidgets/qwebview/tst_qwebview.cpp b/tests/webkitwidgets/qwebview/tst_qwebview.cpp new file mode 100644 index 000000000..e793d3fbf --- /dev/null +++ b/tests/webkitwidgets/qwebview/tst_qwebview.cpp @@ -0,0 +1,548 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + Copyright (C) 2009 Torch Mobile Inc. + Copyright (C) 2009 Girish Ramakrishnan + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include "../util.h" + +#include +#include +#include +#include +#include +#include +#include + +#define VERIFY_INPUTMETHOD_HINTS(actual, expect) \ + QVERIFY(actual == expect); + +class tst_QWebView : public QObject +{ + Q_OBJECT + +public Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + +private Q_SLOTS: + void renderingAfterMaxAndBack(); + void renderHints(); + void getWebKitVersion(); + + void reusePage_data(); + void reusePage(); + void microFocusCoordinates(); + void focusInputTypes(); + void horizontalScrollbarTest(); + + void crashTests(); +#if !(defined(USE_QT_MOBILE_THEME) && USE_QT_MOBILE_THEME) + void setPalette_data(); + void setPalette(); +#endif + void innerOuterRect(); +}; + +// This will be called before the first test function is executed. +// It is only called once. +void tst_QWebView::initTestCase() +{ +} + +// This will be called after the last test function is executed. +// It is only called once. +void tst_QWebView::cleanupTestCase() +{ +} + +// This will be called before each test function is executed. +void tst_QWebView::init() +{ +} + +// This will be called after every test function. +void tst_QWebView::cleanup() +{ +} + +void tst_QWebView::renderHints() +{ + QWebView webView; + + // default is only text antialiasing + smooth pixmap transform + QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); + QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); + QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); + QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); + + webView.setRenderHint(QPainter::Antialiasing, true); + QVERIFY(webView.renderHints() & QPainter::Antialiasing); + QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); + QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); + QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); + + webView.setRenderHint(QPainter::Antialiasing, false); + QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); + QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); + QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); + QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); + + webView.setRenderHint(QPainter::SmoothPixmapTransform, true); + QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); + QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); + QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); + QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); + + webView.setRenderHint(QPainter::SmoothPixmapTransform, false); + QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); + QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform)); + QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); +} + +void tst_QWebView::getWebKitVersion() +{ + QVERIFY(qWebKitVersion().toDouble() > 0); +} + +void tst_QWebView::reusePage_data() +{ + QTest::addColumn("html"); + QTest::newRow("WithoutPlugin") << "text"; + QTest::newRow("WindowedPlugin") << QString("text"); + QTest::newRow("WindowlessPlugin") << QString("text"); +} + +void tst_QWebView::reusePage() +{ + if (!QDir(TESTS_SOURCE_DIR).exists()) + QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll); + + QDir::setCurrent(TESTS_SOURCE_DIR); + + QFETCH(QString, html); + QWebView* view1 = new QWebView; + QPointer page = new QWebPage; + view1->setPage(page.data()); + page.data()->settings()->setAttribute(QWebSettings::PluginsEnabled, true); + QWebFrame* mainFrame = page.data()->mainFrame(); + mainFrame->setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR)); + if (html.contains("")) { + // some reasonable time for the PluginStream to feed test.swf to flash and start painting + waitForSignal(view1, SIGNAL(loadFinished(bool)), 2000); + } + + view1->show(); + QTest::qWaitForWindowExposed(view1); + delete view1; + QVERIFY(page != 0); // deleting view must not have deleted the page, since it's not a child of view + + QWebView *view2 = new QWebView; + view2->setPage(page.data()); + view2->show(); // in Windowless mode, you should still be able to see the plugin here + QTest::qWaitForWindowExposed(view2); + delete view2; + + delete page.data(); // must not crash + + QDir::setCurrent(QApplication::applicationDirPath()); +} + +// Class used in crashTests +class WebViewCrashTest : public QObject { + Q_OBJECT + QWebView* m_view; +public: + bool m_executed; + + + WebViewCrashTest(QWebView* view) + : m_view(view) + , m_executed(false) + { + view->connect(view, SIGNAL(loadProgress(int)), this, SLOT(loading(int))); + } + +private Q_SLOTS: + void loading(int progress) + { + if (progress >= 20 && progress < 90) { + QVERIFY(!m_executed); + m_view->stop(); + m_executed = true; + } + } +}; + + +// Should not crash. +void tst_QWebView::crashTests() +{ + QSKIP("https://github.com/qtwebkit/qtwebkit/issues/913"); + + // Test if loading can be stopped in loadProgress handler without crash. + // Test page should have frames. + QWebView view; + WebViewCrashTest tester(&view); + QUrl url("qrc:///resources/index.html"); + view.load(url); + QTRY_VERIFY(tester.m_executed); // If fail it means that the test wasn't executed. +} + +void tst_QWebView::microFocusCoordinates() +{ + QWebPage* page = new QWebPage; + QWebView* webView = new QWebView; + webView->setPage( page ); + + page->mainFrame()->setHtml("" \ + "
" \ + "" \ + "
" \ + "" \ + ""); + + page->mainFrame()->setFocus(); + + QVariant initialMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); + QVERIFY(initialMicroFocus.isValid()); + + page->mainFrame()->scroll(0,50); + + QVariant currentMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); + QVERIFY(currentMicroFocus.isValid()); + + QCOMPARE(initialMicroFocus.toRect().translated(QPoint(0,-50)), currentMicroFocus.toRect()); +} + +void tst_QWebView::focusInputTypes() +{ + QWebView webView; + webView.show(); + QTest::qWaitForWindowExposed(&webView); + + QUrl url("qrc:///resources/input_types.html"); + QWebFrame* const mainFrame = webView.page()->mainFrame(); + mainFrame->load(url); + mainFrame->setFocus(); + + QVERIFY(waitForSignal(&webView, SIGNAL(loadFinished(bool)))); + + // 'text' type + QWebElement inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=text]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QVERIFY(webView.inputMethodHints() == Qt::ImhNone); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); + + // 'password' field + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhHiddenText); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); + + // 'tel' field + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=tel]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhDialableCharactersOnly); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); + + // 'number' field + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=number]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhDigitsOnly); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); + + // 'email' field + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=email]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhEmailCharactersOnly); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); + + // 'url' field + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=url]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhUrlCharactersOnly); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); + + // 'password' field + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhHiddenText); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); + + // 'text' type + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=text]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QVERIFY(webView.inputMethodHints() == Qt::ImhNone); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); + + // 'password' field + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhHiddenText); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); + + // 'text area' field + inputElement = mainFrame->documentElement().findFirst(QLatin1String("textarea")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QVERIFY(webView.inputMethodHints() == Qt::ImhNone); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); +} + +void tst_QWebView::horizontalScrollbarTest() +{ + QWebView webView; + webView.resize(600, 600); + webView.show(); + QTest::qWaitForWindowExposed(&webView); + + QUrl url("qrc:///resources/scrolltest_page.html"); + QWebFrame* const mainFrame = webView.page()->mainFrame(); + mainFrame->load(url); + mainFrame->setFocus(); + + QVERIFY(waitForSignal(&webView, SIGNAL(loadFinished(bool)))); + + QVERIFY(webView.page()->mainFrame()->scrollPosition() == QPoint(0, 0)); + + // Note: The test below assumes that the layout direction is Qt::LeftToRight. + QTest::mouseClick(&webView, Qt::LeftButton, 0, QPoint(550, 595)); + QVERIFY(webView.page()->mainFrame()->scrollPosition().x() > 0); + + // Note: The test below assumes that the layout direction is Qt::LeftToRight. + QTest::mouseClick(&webView, Qt::LeftButton, 0, QPoint(20, 595)); + QVERIFY(webView.page()->mainFrame()->scrollPosition() == QPoint(0, 0)); +} + + +#if !(defined(USE_QT_MOBILE_THEME) && USE_QT_MOBILE_THEME) +void tst_QWebView::setPalette_data() +{ + QTest::addColumn("active"); + QTest::addColumn("background"); + QTest::newRow("activeBG") << true << true; + QTest::newRow("activeFG") << true << false; + QTest::newRow("inactiveBG") << false << true; + QTest::newRow("inactiveFG") << false << false; +} + +// Render a QWebView to a QImage twice, each time with a different palette set, +// verify that images rendered are not the same, confirming WebCore usage of +// custom palette on selections. +void tst_QWebView::setPalette() +{ + QString html = "" + "" + "Some text here" + "" + ""; + + QFETCH(bool, active); + QFETCH(bool, background); + + QWidget* activeView = 0; + + // Use controlView to manage active/inactive state of test views by raising + // or lowering their position in the window stack. + QWebView controlView; + controlView.setHtml(html); + + QWebView view1; + + QPalette palette1; + QBrush brush1(Qt::red); + brush1.setStyle(Qt::SolidPattern); + if (active && background) { + // Rendered image must have red background on an active QWebView. + palette1.setBrush(QPalette::Active, QPalette::Highlight, brush1); + } else if (active && !background) { + // Rendered image must have red foreground on an active QWebView. + palette1.setBrush(QPalette::Active, QPalette::HighlightedText, brush1); + } else if (!active && background) { + // Rendered image must have red background on an inactive QWebView. + palette1.setBrush(QPalette::Inactive, QPalette::Highlight, brush1); + } else if (!active && !background) { + // Rendered image must have red foreground on an inactive QWebView. + palette1.setBrush(QPalette::Inactive, QPalette::HighlightedText, brush1); + } + + view1.setPalette(palette1); + view1.setHtml(html); + view1.page()->setViewportSize(view1.page()->currentFrame()->contentsSize()); + view1.show(); + + QTest::qWaitForWindowExposed(&view1); + + if (!active) { + controlView.show(); + QTest::qWaitForWindowExposed(&controlView); + activeView = &controlView; + controlView.activateWindow(); + } else { + view1.activateWindow(); + activeView = &view1; + } + + QTRY_COMPARE(QApplication::activeWindow(), activeView); + + view1.page()->triggerAction(QWebPage::SelectAll); + + QImage img1(view1.page()->viewportSize(), QImage::Format_ARGB32); + QPainter painter1(&img1); + view1.page()->currentFrame()->render(&painter1); + painter1.end(); + view1.close(); + controlView.close(); + + QWebView view2; + + QPalette palette2; + QBrush brush2(Qt::blue); + brush2.setStyle(Qt::SolidPattern); + if (active && background) { + // Rendered image must have blue background on an active QWebView. + palette2.setBrush(QPalette::Active, QPalette::Highlight, brush2); + } else if (active && !background) { + // Rendered image must have blue foreground on an active QWebView. + palette2.setBrush(QPalette::Active, QPalette::HighlightedText, brush2); + } else if (!active && background) { + // Rendered image must have blue background on an inactive QWebView. + palette2.setBrush(QPalette::Inactive, QPalette::Highlight, brush2); + } else if (!active && !background) { + // Rendered image must have blue foreground on an inactive QWebView. + palette2.setBrush(QPalette::Inactive, QPalette::HighlightedText, brush2); + } + + view2.setPalette(palette2); + view2.setHtml(html); + view2.page()->setViewportSize(view2.page()->currentFrame()->contentsSize()); + view2.show(); + + QTest::qWaitForWindowExposed(&view2); + + if (!active) { + controlView.show(); + QTest::qWaitForWindowExposed(&controlView); + activeView = &controlView; + controlView.activateWindow(); + } else { + view2.activateWindow(); + activeView = &view2; + } + + QTRY_COMPARE(QApplication::activeWindow(), activeView); + + view2.page()->triggerAction(QWebPage::SelectAll); + + QImage img2(view2.page()->viewportSize(), QImage::Format_ARGB32); + QPainter painter2(&img2); + view2.page()->currentFrame()->render(&painter2); + painter2.end(); + + view2.close(); + controlView.close(); + + QVERIFY(img1 != img2); +} +#endif + +void tst_QWebView::renderingAfterMaxAndBack() +{ + QUrl url = QUrl("data:text/html," + "" + "" + ""); + + QWebView view; + view.page()->mainFrame()->load(url); + QVERIFY(waitForSignal(&view, SIGNAL(loadFinished(bool)))); + view.show(); + + view.page()->settings()->setMaximumPagesInCache(3); + + QTest::qWaitForWindowExposed(&view); + + QPixmap reference(view.page()->viewportSize()); + reference.fill(Qt::red); + + QPixmap image(view.page()->viewportSize()); + QPainter painter(&image); + view.page()->currentFrame()->render(&painter); + + QCOMPARE(image, reference); + + QUrl url2 = QUrl("data:text/html," + "" + "" + ""); + view.page()->mainFrame()->load(url2); + + QVERIFY(waitForSignal(&view, SIGNAL(loadFinished(bool)))); + + view.showMaximized(); + + QTest::qWaitForWindowExposed(&view); + + QPixmap reference2(view.page()->viewportSize()); + reference2.fill(Qt::blue); + + QPixmap image2(view.page()->viewportSize()); + QPainter painter2(&image2); + view.page()->currentFrame()->render(&painter2); + + QCOMPARE(image2, reference2); + + view.back(); + + QPixmap reference3(view.page()->viewportSize()); + reference3.fill(Qt::red); + QPixmap image3(view.page()->viewportSize()); + QPainter painter3(&image3); + view.page()->currentFrame()->render(&painter3); + + QCOMPARE(image3, reference3); +} + +void tst_QWebView::innerOuterRect() +{ + QUrl url = QUrl("data:text/html," + "" + "" + ""); + QWebView view; + view.page()->mainFrame()->load(url); + QVERIFY(waitForSignal(&view, SIGNAL(loadFinished(bool)))); + view.showMaximized(); + const QRect frameGeometry = view.frameGeometry(); + const QRect geometry = view.geometry(); + QVariant outerWidth = view.page()->mainFrame()->evaluateJavaScript("window.outerWidth;"); + QCOMPARE(outerWidth.toInt(), frameGeometry.width()); + QVariant innerWidth = view.page()->mainFrame()->evaluateJavaScript("window.innerWidth;"); + QCOMPARE(innerWidth.toInt(), geometry.width()); + QVariant outerHeight = view.page()->mainFrame()->evaluateJavaScript("window.outerHeight;"); + QCOMPARE(outerHeight.toInt(), frameGeometry.height()); + QVariant innerHeight = view.page()->mainFrame()->evaluateJavaScript("window.innerHeight;"); + QCOMPARE(innerHeight.toInt(), geometry.height()); +} + +QTEST_MAIN(tst_QWebView) +#include "tst_qwebview.moc" + diff --git a/tests/webkitwidgets/qwebview/tst_qwebview.qrc b/tests/webkitwidgets/qwebview/tst_qwebview.qrc new file mode 100644 index 000000000..e4b9ad776 --- /dev/null +++ b/tests/webkitwidgets/qwebview/tst_qwebview.qrc @@ -0,0 +1,9 @@ + + + resources/index.html + resources/frame_a.html + resources/input_types.html + resources/scrolltest_page.html + + + diff --git a/tests/webkitwidgets/resources/image2.png b/tests/webkitwidgets/resources/image2.png new file mode 100644 index 000000000..8d703640c Binary files /dev/null and b/tests/webkitwidgets/resources/image2.png differ diff --git a/tests/webkitwidgets/tests.pri b/tests/webkitwidgets/tests.pri new file mode 100644 index 000000000..b48806286 --- /dev/null +++ b/tests/webkitwidgets/tests.pri @@ -0,0 +1,22 @@ +TEMPLATE = app + +VPATH += $$_PRO_FILE_PWD_ +TARGET = tst_$$TARGET + +# Load mobilityconfig if Qt Mobility is available +load(mobilityconfig, true) +contains(MOBILITY_CONFIG, multimedia) { + # This define is used by tests depending on Qt Multimedia + DEFINES -= WTF_USE_QT_MULTIMEDIA=0 + DEFINES += WTF_USE_QT_MULTIMEDIA=1 +} + +SOURCES += $${TARGET}.cpp +INCLUDEPATH += \ + $$PWD \ + $$PWD/../Api + +QT += testlib network webkitwidgets widgets + +# This define is used by some tests to look up resources in the source tree +DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD/\\\" diff --git a/tests/webkitwidgets/util.h b/tests/webkitwidgets/util.h new file mode 100644 index 000000000..19955b810 --- /dev/null +++ b/tests/webkitwidgets/util.h @@ -0,0 +1,79 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +// Functions and macros that really need to be in QTestLib + +#if 0 +#pragma qt_no_master_include +#endif + +#include +#include +#include + +#if !defined(TESTS_SOURCE_DIR) +#define TESTS_SOURCE_DIR "" +#endif + +/** + * Starts an event loop that runs until the given signal is received. + * Optionally the event loop + * can return earlier on a timeout. + * + * \return \p true if the requested signal was received + * \p false on timeout + */ +static inline bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) +{ + QEventLoop loop; + QObject::connect(obj, signal, &loop, SLOT(quit())); + QTimer timer; + QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); + if (timeout > 0) { + QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.setSingleShot(true); + timer.start(timeout); + } + loop.exec(); + return timeoutSpy.isEmpty(); +} + +/** + * Just like QSignalSpy but facilitates sync and async + * signal emission. For example if you want to verify that + * page->foo() emitted a signal, it could be that the + * implementation decides to emit the signal asynchronously + * - in which case we want to spin a local event loop until + * emission - or that the call to foo() emits it right away. + */ +class SignalBarrier : private QSignalSpy +{ +public: + SignalBarrier(const QObject* obj, const char* aSignal) + : QSignalSpy(obj, aSignal) + { } + + bool ensureSignalEmitted() + { + bool result = count() > 0; + if (!result) + result = wait(); + clear(); + return result; + } +}; diff --git a/tests/webkitwidgets/webkitwidgets.pro b/tests/webkitwidgets/webkitwidgets.pro new file mode 100644 index 000000000..8b900139f --- /dev/null +++ b/tests/webkitwidgets/webkitwidgets.pro @@ -0,0 +1,16 @@ +TEMPLATE = subdirs +CONFIG += ordered + +SUBDIRS += \ + cmake \ + qobjectbridge \ + qwebframe \ + qwebpage \ + qwebelement \ + qgraphicswebview \ + qwebhistoryinterface \ + qwebview \ + qwebhistory \ + qwebinspector \ + qwebsecurityorigin \ + hybridPixmap -- cgit v1.2.3 From 2eac3aeb98fca0e6c13aaaff481861c5ef679e68 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Tue, 8 Oct 2019 01:20:22 +0300 Subject: Import QtWebKit commit 5e53102492e5ce85bda2657468f1369a0173c2ce Change-Id: Id71d7c7f5eafe58f7bd8c46a2a07fd0bad015628 Reviewed-by: Konstantin Tokarev --- Source/PlatformQt.cmake | 28 ++++++++++++++++++++++++++-- Source/WebCore/dom/Document.cpp | 6 +++--- Tools/qmake/projects/run_cmake.pro | 2 ++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Source/PlatformQt.cmake b/Source/PlatformQt.cmake index 2d58228dc..c99d89d70 100644 --- a/Source/PlatformQt.cmake +++ b/Source/PlatformQt.cmake @@ -87,6 +87,29 @@ target_include_directories(WebKitWidgets INTERFACE $ ) +if (QT_ORIGIN_RPATH) + set(WEBKIT_SHARED_LIBRARY_TARGETS WebKit) + + if (TARGET WebKitWidgets) + list(APPEND WEBKIT_SHARED_LIBRARY_TARGETS WebKitWidgets) + endif () + + if (TARGET WebKit2) + set(WEBKIT2_EXECUTABLES WebProcess NetworkProcess) + if (ENABLE_PLUGIN_PROCESS) + list(APPEND WEBKIT2_EXECUTABLES PluginProcess) + endif () + if (ENABLE_DATABASE_PROCESS) + list(APPEND WEBKIT2_EXECUTABLES DatabaseProcess) + endif () + set_target_properties(${WEBKIT2_EXECUTABLES} PROPERTIES INSTALL_RPATH "\$ORIGIN/../lib") + set_target_properties(qmlwebkitplugin PROPERTIES INSTALL_RPATH "\$ORIGIN/../../lib") + set_target_properties(qmlwebkitexperimentalplugin PROPERTIES INSTALL_RPATH "\$ORIGIN/../../../lib") + endif () + + set_target_properties(${WEBKIT_SHARED_LIBRARY_TARGETS} PROPERTIES INSTALL_RPATH "\$ORIGIN") +endif () + set(QTWEBKIT_PACKAGE_INIT " macro(find_dependency_with_major_and_minor _dep _major _minor) find_dependency(\${_dep} \"\${_major}.\${_minor}\") @@ -162,17 +185,18 @@ install(FILES COMPONENT Data ) +# We need to install separate config files for debug and release, so use "Code" component install(EXPORT WebKitTargets FILE WebKitTargets.cmake NAMESPACE Qt5:: DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt5WebKit" - COMPONENT Data + COMPONENT Code ) install(EXPORT Qt5WebKitWidgetsTargets FILE Qt5WebKitWidgetsTargets.cmake NAMESPACE Qt5:: DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt5WebKitWidgets" - COMPONENT Data + COMPONENT Code ) # Documentation diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp index 1bca2d0a6..19355f166 100644 --- a/Source/WebCore/dom/Document.cpp +++ b/Source/WebCore/dom/Document.cpp @@ -4407,12 +4407,12 @@ static bool isValidNameNonASCII(const UChar* characters, unsigned length) unsigned i = 0; UChar32 c; - U16_NEXT(characters, i, length, c) + U16_NEXT(characters, i, length, c); if (!isValidNameStart(c)) return false; while (i < length) { - U16_NEXT(characters, i, length, c) + U16_NEXT(characters, i, length, c); if (!isValidNamePart(c)) return false; } @@ -4474,7 +4474,7 @@ bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, S for (unsigned i = 0; i < length;) { UChar32 c; - U16_NEXT(qualifiedName, i, length, c) + U16_NEXT(qualifiedName, i, length, c); if (c == ':') { if (sawColon) { ec = NAMESPACE_ERR; diff --git a/Tools/qmake/projects/run_cmake.pro b/Tools/qmake/projects/run_cmake.pro index 345e43a01..71872664b 100644 --- a/Tools/qmake/projects/run_cmake.pro +++ b/Tools/qmake/projects/run_cmake.pro @@ -86,6 +86,8 @@ build_pass|!debug_and_release { !qt_framework: CMAKE_CONFIG += MACOS_BUILD_FRAMEWORKS=OFF } + linux:isEqual(EXTRA_RPATHS, "."): CMAKE_CONFIG += QT_ORIGIN_RPATH=ON + !isEmpty(use_ninja): cmake_args += "-G Ninja" equals(QMAKE_HOST.os, Windows) { -- cgit v1.2.3