<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[161366] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/161366">161366</a></dd>
<dt>Author</dt> <dd>mrobinson@webkit.org</dd>
<dt>Date</dt> <dd>2014-01-06 13:14:30 -0800 (Mon, 06 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Move all GTK/GObject unit tests to Tools/TestWebKitAPI
https://bugs.webkit.org/show_bug.cgi?id=126342
Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2014-01-04
Reviewed by Gustavo Noronha Silva.
.:
* GNUmakefile.am: Remove unused variable.
* Source/PlatformGTK.cmake: No longer include the old unit tests directories.
Source/WebKit/gtk:
* tests/CMakeLists.txt: Removed.
* tests/GNUmakefile.am: Removed.
Source/WebKit2:
* UIProcess/API/gtk/tests/CMakeLists.txt: Removed.
* UIProcess/API/gtk/tests/GNUmakefile.am: Removed.
Tools:
* CMakeLists.txt: Include the new unit tests subdirectories.
* Scripts/run-gtk-tests: Update to refer to the new build locations.
* Scripts/webkitpy/style/checker.py: Update the style checker.
* Scripts/webkitpy/style/checker_unittest.py:
* TestWebKitAPI/GNUmakefile.am:
* TestWebKitAPI/Tests/WebKit2Gtk/AccessibilityTestServer.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/AccessibilityTestServer.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt: Added.
* TestWebKitAPI/Tests/WebKit2Gtk/DOMDOMWindowTest.cpp: Added.
* TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/DOMNodeTest.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/FrameTest.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/InspectorTestServer.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/InspectorTestServer.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/LoadTrackingTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/LoadTrackingTest.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h.
* TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestAuthentication.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestContextMenu.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestCookieManager.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestDOMDOMWindow.cpp: Added.
* TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestDOMNode.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestFrame.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestInspector.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestInspectorServer.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestInspectorServer.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestMain.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestMain.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h.
* TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestUIClient.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebExtensions.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitAccessibility.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitAccessibility.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFindController.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFindController.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitVersion.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebViewGroup.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebViewGroup.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebViewEditor.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/WebKitTestBus.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/WebKitTestBus.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.h.
* TestWebKitAPI/Tests/WebKit2Gtk/WebKitTestServer.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/WebKitTestServer.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h.
* TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTest.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTest.h.
* TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTestRunner.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTestRunner.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTestRunner.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTestRunner.h.
* TestWebKitAPI/Tests/WebKit2Gtk/WebViewTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp.
* TestWebKitAPI/Tests/WebKit2Gtk/WebViewTest.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h.
* TestWebKitAPI/Tests/WebKit2Gtk/resources/link-title.js: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js.
* TestWebKitAPI/Tests/WebKit2Gtk/resources/test-cert.pem: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/resources/test-cert.pem.
* TestWebKitAPI/Tests/WebKit2Gtk/resources/test-key.pem: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/resources/test-key.pem.
* TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml.
* TestWebKitAPI/Tests/WebKitGtk/CMakeLists.txt: Added.
* TestWebKitAPI/Tests/WebKitGtk/resources/blank.ico: Renamed from Source/WebKit/gtk/tests/resources/blank.ico.
* TestWebKitAPI/Tests/WebKitGtk/resources/test.html: Renamed from Source/WebKit/gtk/tests/resources/test.html.
* TestWebKitAPI/Tests/WebKitGtk/resources/test.ogg: Renamed from Source/WebKit/gtk/tests/resources/test.ogg.
* TestWebKitAPI/Tests/WebKitGtk/resources/test.pdf: Renamed from Source/WebKit/gtk/tests/resources/test.pdf.
* TestWebKitAPI/Tests/WebKitGtk/resources/test.txt: Renamed from Source/WebKit/gtk/tests/resources/test.txt.
* TestWebKitAPI/Tests/WebKitGtk/test_utils.c: Renamed from Source/WebKit/gtk/tests/test_utils.c.
* TestWebKitAPI/Tests/WebKitGtk/test_utils.h: Renamed from Source/WebKit/gtk/tests/test_utils.h.
* TestWebKitAPI/Tests/WebKitGtk/testapplicationcache.c: Renamed from Source/WebKit/gtk/tests/testapplicationcache.c.
* TestWebKitAPI/Tests/WebKitGtk/testatk.c: Renamed from Source/WebKit/gtk/tests/testatk.c.
* TestWebKitAPI/Tests/WebKitGtk/testatkroles.c: Renamed from Source/WebKit/gtk/tests/testatkroles.c.
* TestWebKitAPI/Tests/WebKitGtk/testcontextmenu.c: Renamed from Source/WebKit/gtk/tests/testcontextmenu.c.
* TestWebKitAPI/Tests/WebKitGtk/testcopyandpaste.c: Renamed from Source/WebKit/gtk/tests/testcopyandpaste.c.
* TestWebKitAPI/Tests/WebKitGtk/testdomdocument.c: Renamed from Source/WebKit/gtk/tests/testdomdocument.c.
* TestWebKitAPI/Tests/WebKitGtk/testdomdomwindow.c: Renamed from Source/WebKit/gtk/tests/testdomdomwindow.c.
* TestWebKitAPI/Tests/WebKitGtk/testdomnode.c: Renamed from Source/WebKit/gtk/tests/testdomnode.c.
* TestWebKitAPI/Tests/WebKitGtk/testdownload.c: Renamed from Source/WebKit/gtk/tests/testdownload.c.
* TestWebKitAPI/Tests/WebKitGtk/testfavicondatabase.c: Renamed from Source/WebKit/gtk/tests/testfavicondatabase.c.
* TestWebKitAPI/Tests/WebKitGtk/testglobals.c: Renamed from Source/WebKit/gtk/tests/testglobals.c.
* TestWebKitAPI/Tests/WebKitGtk/testhittestresult.c: Renamed from Source/WebKit/gtk/tests/testhittestresult.c.
* TestWebKitAPI/Tests/WebKitGtk/testhttpbackend.c: Renamed from Source/WebKit/gtk/tests/testhttpbackend.c.
* TestWebKitAPI/Tests/WebKitGtk/testkeyevents.c: Renamed from Source/WebKit/gtk/tests/testkeyevents.c.
* TestWebKitAPI/Tests/WebKitGtk/testloading.c: Renamed from Source/WebKit/gtk/tests/testloading.c.
* TestWebKitAPI/Tests/WebKitGtk/testmimehandling.c: Renamed from Source/WebKit/gtk/tests/testmimehandling.c.
* TestWebKitAPI/Tests/WebKitGtk/testnetworkrequest.c: Renamed from Source/WebKit/gtk/tests/testnetworkrequest.c.
* TestWebKitAPI/Tests/WebKitGtk/testnetworkresponse.c: Renamed from Source/WebKit/gtk/tests/testnetworkresponse.c.
* TestWebKitAPI/Tests/WebKitGtk/testwebbackforwardlist.c: Renamed from Source/WebKit/gtk/tests/testwebbackforwardlist.c.
* TestWebKitAPI/Tests/WebKitGtk/testwebdatasource.c: Renamed from Source/WebKit/gtk/tests/testwebdatasource.c.
* TestWebKitAPI/Tests/WebKitGtk/testwebframe.c: Renamed from Source/WebKit/gtk/tests/testwebframe.c.
* TestWebKitAPI/Tests/WebKitGtk/testwebhistoryitem.c: Renamed from Source/WebKit/gtk/tests/testwebhistoryitem.c.
* TestWebKitAPI/Tests/WebKitGtk/testwebinspector.c: Renamed from Source/WebKit/gtk/tests/testwebinspector.c.
* TestWebKitAPI/Tests/WebKitGtk/testwebplugindatabase.c: Renamed from Source/WebKit/gtk/tests/testwebplugindatabase.c.
* TestWebKitAPI/Tests/WebKitGtk/testwebresource.c: Renamed from Source/WebKit/gtk/tests/testwebresource.c.
* TestWebKitAPI/Tests/WebKitGtk/testwebsettings.c: Renamed from Source/WebKit/gtk/tests/testwebsettings.c.
* TestWebKitAPI/Tests/WebKitGtk/testwebview.c: Renamed from Source/WebKit/gtk/tests/testwebview.c.
* TestWebKitAPI/Tests/WebKitGtk/testwindow.c: Renamed from Source/WebKit/gtk/tests/testwindow.c.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkChangeLog">trunk/ChangeLog</a></li>
<li><a href="#trunkGNUmakefileam">trunk/GNUmakefile.am</a></li>
<li><a href="#trunkSourcePlatformGTKcmake">trunk/Source/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKitgtkChangeLog">trunk/Source/WebKit/gtk/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkToolsCMakeListstxt">trunk/Tools/CMakeLists.txt</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsrungtktests">trunk/Tools/Scripts/run-gtk-tests</a></li>
<li><a href="#trunkToolsScriptswebkitpystylecheckerpy">trunk/Tools/Scripts/webkitpy/style/checker.py</a></li>
<li><a href="#trunkToolsScriptswebkitpystylechecker_unittestpy">trunk/Tools/Scripts/webkitpy/style/checker_unittest.py</a></li>
<li><a href="#trunkToolsTestWebKitAPIGNUmakefileam">trunk/Tools/TestWebKitAPI/GNUmakefile.am</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/</li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkAccessibilityTestServercpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/AccessibilityTestServer.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkCMakeListstxt">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkDOMDOMWindowTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMDOMWindowTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkDOMNodeTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkFrameTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkInspectorTestServercpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/InspectorTestServer.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestAuthenticationcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestBackForwardListcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestContextMenucpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestCookieManagercpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestDOMDOMWindowcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMDOMWindow.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestDOMNodecpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestDownloadscpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestFramecpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestInspectorcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspector.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestInspectorServercpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspectorServer.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestLoaderClientcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestPrintingcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestResourcescpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestSSLcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestUIClientcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebExtensionscpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitAccessibilitycpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitAccessibility.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitFaviconDatabasecpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitFindControllercpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFindController.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitPolicyClientcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitSettingscpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitVersioncpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitVersion.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebContextcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebViewcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebViewGroupcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebViewGroup.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebViewEditorcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkWebExtensionTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkWebProcessTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkWebProcessTesth">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h</a></li>
<li>trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/</li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Gtkresourceslinktitlejs">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/link-title.js</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Gtkresourcestestcertpem">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/test-cert.pem</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Gtkresourcestestkeypem">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/test-key.pem</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Gtkresourceswebkit2gtktestsgresourcexml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml</a></li>
<li>trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/</li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtkCMakeListstxt">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/CMakeLists.txt</a></li>
<li>trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/resources/</li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtkresourcesblankico">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/resources/blank.ico</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtkresourcestesthtml">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/resources/test.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtkresourcestestogg">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/resources/test.ogg</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtkresourcestestpdf">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/resources/test.pdf</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtkresourcestesttxt">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/resources/test.txt</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktest_utilsc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/test_utils.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktest_utilsh">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/test_utils.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestapplicationcachec">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testapplicationcache.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestatkc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testatk.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestatkrolesc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testatkroles.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestcontextmenuc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testcontextmenu.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestcopyandpastec">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testcopyandpaste.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestdomdocumentc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testdomdocument.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestdomdomwindowc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testdomdomwindow.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestdomnodec">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testdomnode.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestdownloadc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testdownload.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestfavicondatabasec">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testfavicondatabase.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestglobalsc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testglobals.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktesthittestresultc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testhittestresult.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktesthttpbackendc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testhttpbackend.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestkeyeventsc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testkeyevents.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestloadingc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testloading.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestmimehandlingc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testmimehandling.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestnetworkrequestc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testnetworkrequest.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestnetworkresponsec">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testnetworkresponse.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestwebbackforwardlistc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testwebbackforwardlist.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestwebdatasourcec">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testwebdatasource.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestwebframec">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testwebframe.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestwebhistoryitemc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testwebhistoryitem.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestwebinspectorc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testwebinspector.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestwebplugindatabasec">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testwebplugindatabase.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestwebresourcec">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testwebresource.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestwebsettingsc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testwebsettings.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestwebviewc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testwebview.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtktestwindowc">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/testwindow.c</a></li>
<li>trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/</li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkLoadTrackingTestcpp">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/LoadTrackingTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkLoadTrackingTesth">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/LoadTrackingTest.h</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkTestMaincpp">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkTestMainh">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebKitTestBuscpp">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebKitTestBush">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.h</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebKitTestServercpp">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestServer.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebKitTestServerh">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestServer.h</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebProcessTestRunnercpp">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebProcessTestRunnerh">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTestcpp">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTesth">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li>trunk/Source/WebKit/gtk/tests/</li>
<li>trunk/Source/WebKit2/UIProcess/API/gtk/tests/</li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/ChangeLog (161365 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/ChangeLog        2014-01-06 21:00:03 UTC (rev 161365)
+++ trunk/ChangeLog        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-01-04 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Move all GTK/GObject unit tests to Tools/TestWebKitAPI
+ https://bugs.webkit.org/show_bug.cgi?id=126342
+
+ Reviewed by Gustavo Noronha Silva.
+
+ * GNUmakefile.am: Remove unused variable.
+ * Source/PlatformGTK.cmake: No longer include the old unit tests directories.
+
</ins><span class="cx"> 2014-01-06 Zan Dobersek <zdobersek@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] configure errors out when building with libc++
</span></span></pre></div>
<a id="trunkGNUmakefileam"></a>
<div class="modfile"><h4>Modified: trunk/GNUmakefile.am (161365 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/GNUmakefile.am        2014-01-06 21:00:03 UTC (rev 161365)
+++ trunk/GNUmakefile.am        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -59,7 +59,6 @@
</span><span class="cx"> noinst_LTLIBRARIES :=
</span><span class="cx"> lib_LTLIBRARIES :=
</span><span class="cx"> IDL_BINDINGS :=
</span><del>-TEST_PROGS :=
</del><span class="cx"> POFILES :=
</span><span class="cx"> PO_LINGUAS :=
</span><span class="cx"> USER_LINGUAS :=
</span><span class="lines">@@ -214,8 +213,6 @@
</span><span class="cx"> include Source/ThirdParty/leveldb/GNUmakefile.am
</span><span class="cx">
</span><span class="cx"> if ENABLE_DEVELOPER_MODE
</span><del>-include Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
-include Source/WebKit/gtk/tests/GNUmakefile.am
</del><span class="cx"> include Source/ThirdParty/gtest/GNUmakefile.am
</span><span class="cx"> include Tools/GNUmakefile.am
</span><span class="cx"> include Tools/TestWebKitAPI/GNUmakefile.am
</span></span></pre></div>
<a id="trunkSourcePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/PlatformGTK.cmake (161365 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/PlatformGTK.cmake        2014-01-06 21:00:03 UTC (rev 161365)
+++ trunk/Source/PlatformGTK.cmake        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -3,15 +3,6 @@
</span><span class="cx"> # This allows exposing a 'gir' target which builds all GObject introspection files.
</span><span class="cx"> add_custom_target(gir ALL DEPENDS ${GObjectIntrospectionTargets})
</span><span class="cx">
</span><del>-if (ENABLE_API_TESTS)
- if (ENABLE_WEBKIT)
- add_subdirectory(${WEBKIT_DIR}/gtk/tests)
- endif ()
- if (ENABLE_WEBKIT2)
- add_subdirectory(${WEBKIT2_DIR}/UIProcess/API/gtk/tests)
- endif ()
-endif ()
-
</del><span class="cx"> set(DocumentationDependencies
</span><span class="cx"> "${CMAKE_SOURCE_DIR}/Source/WebKit/gtk/docs/webkitenvironment.xml"
</span><span class="cx"> )
</span></span></pre></div>
<a id="trunkSourceWebKitgtkChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/gtk/ChangeLog (161365 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/gtk/ChangeLog        2014-01-06 21:00:03 UTC (rev 161365)
+++ trunk/Source/WebKit/gtk/ChangeLog        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-01-04 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Move all GTK/GObject unit tests to Tools/TestWebKitAPI
+ https://bugs.webkit.org/show_bug.cgi?id=126342
+
+ Reviewed by Gustavo Noronha Silva.
+
+ * tests/CMakeLists.txt: Removed.
+ * tests/GNUmakefile.am: Removed.
+
</ins><span class="cx"> 2014-01-06 László Langó <lango@inf.u-szeged.hu>
</span><span class="cx">
</span><span class="cx"> Use unsigned consistently, and check for invalid casts when calling into SharedBuffer from other code.
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (161365 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-01-06 21:00:03 UTC (rev 161365)
+++ trunk/Source/WebKit2/ChangeLog        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-01-04 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Move all GTK/GObject unit tests to Tools/TestWebKitAPI
+ https://bugs.webkit.org/show_bug.cgi?id=126342
+
+ Reviewed by Gustavo Noronha Silva.
+
+ * UIProcess/API/gtk/tests/CMakeLists.txt: Removed.
+ * UIProcess/API/gtk/tests/GNUmakefile.am: Removed.
+
</ins><span class="cx"> 2014-01-06 Enrica Casucci <enrica@apple.com>
</span><span class="cx">
</span><span class="cx"> Add support to retrieve the autocorrection context.
</span></span></pre></div>
<a id="trunkToolsCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Tools/CMakeLists.txt (161365 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/CMakeLists.txt        2014-01-06 21:00:03 UTC (rev 161365)
+++ trunk/Tools/CMakeLists.txt        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -19,10 +19,12 @@
</span><span class="cx"> add_subdirectory(ImageDiff)
</span><span class="cx"> if (ENABLE_WEBKIT2)
</span><span class="cx"> add_subdirectory(MiniBrowser/gtk)
</span><ins>+ add_subdirectory(TestWebKitAPI/Tests/WebKit2Gtk)
</ins><span class="cx"> endif ()
</span><span class="cx"> if (ENABLE_WEBKIT)
</span><span class="cx"> add_subdirectory(GtkLauncher)
</span><span class="cx"> add_subdirectory(DumpRenderTree)
</span><ins>+ add_subdirectory(TestWebKitAPI/Tests/WebKitGtk)
</ins><span class="cx"> endif ()
</span><span class="cx"> add_subdirectory(DumpRenderTree/TestNetscapePlugIn)
</span><span class="cx"> elseif ("${PORT}" STREQUAL "WinCE")
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (161365 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-01-06 21:00:03 UTC (rev 161365)
+++ trunk/Tools/ChangeLog        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -1,3 +1,103 @@
</span><ins>+2014-01-04 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Move all GTK/GObject unit tests to Tools/TestWebKitAPI
+ https://bugs.webkit.org/show_bug.cgi?id=126342
+
+ Reviewed by Gustavo Noronha Silva.
+
+ * CMakeLists.txt: Include the new unit tests subdirectories.
+ * Scripts/run-gtk-tests: Update to refer to the new build locations.
+ * Scripts/webkitpy/style/checker.py: Update the style checker.
+ * Scripts/webkitpy/style/checker_unittest.py:
+ * TestWebKitAPI/GNUmakefile.am:
+ * TestWebKitAPI/Tests/WebKit2Gtk/AccessibilityTestServer.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/AccessibilityTestServer.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt: Added.
+ * TestWebKitAPI/Tests/WebKit2Gtk/DOMDOMWindowTest.cpp: Added.
+ * TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/DOMNodeTest.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/FrameTest.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/InspectorTestServer.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/InspectorTestServer.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/LoadTrackingTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/LoadTrackingTest.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestAuthentication.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestContextMenu.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestCookieManager.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestDOMDOMWindow.cpp: Added.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestDOMNode.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestFrame.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestInspector.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestInspectorServer.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestInspectorServer.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestMain.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestMain.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestUIClient.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebExtensions.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitAccessibility.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitAccessibility.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFindController.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFindController.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitVersion.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebViewGroup.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebViewGroup.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/TestWebViewEditor.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebKitTestBus.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebKitTestBus.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.h.
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebKitTestServer.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebKitTestServer.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h.
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTest.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTest.h.
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTestRunner.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTestRunner.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTestRunner.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTestRunner.h.
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebViewTest.cpp: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp.
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebViewTest.h: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h.
+ * TestWebKitAPI/Tests/WebKit2Gtk/resources/link-title.js: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js.
+ * TestWebKitAPI/Tests/WebKit2Gtk/resources/test-cert.pem: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/resources/test-cert.pem.
+ * TestWebKitAPI/Tests/WebKit2Gtk/resources/test-key.pem: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/resources/test-key.pem.
+ * TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml: Renamed from Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml.
+ * TestWebKitAPI/Tests/WebKitGtk/CMakeLists.txt: Added.
+ * TestWebKitAPI/Tests/WebKitGtk/resources/blank.ico: Renamed from Source/WebKit/gtk/tests/resources/blank.ico.
+ * TestWebKitAPI/Tests/WebKitGtk/resources/test.html: Renamed from Source/WebKit/gtk/tests/resources/test.html.
+ * TestWebKitAPI/Tests/WebKitGtk/resources/test.ogg: Renamed from Source/WebKit/gtk/tests/resources/test.ogg.
+ * TestWebKitAPI/Tests/WebKitGtk/resources/test.pdf: Renamed from Source/WebKit/gtk/tests/resources/test.pdf.
+ * TestWebKitAPI/Tests/WebKitGtk/resources/test.txt: Renamed from Source/WebKit/gtk/tests/resources/test.txt.
+ * TestWebKitAPI/Tests/WebKitGtk/test_utils.c: Renamed from Source/WebKit/gtk/tests/test_utils.c.
+ * TestWebKitAPI/Tests/WebKitGtk/test_utils.h: Renamed from Source/WebKit/gtk/tests/test_utils.h.
+ * TestWebKitAPI/Tests/WebKitGtk/testapplicationcache.c: Renamed from Source/WebKit/gtk/tests/testapplicationcache.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testatk.c: Renamed from Source/WebKit/gtk/tests/testatk.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testatkroles.c: Renamed from Source/WebKit/gtk/tests/testatkroles.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testcontextmenu.c: Renamed from Source/WebKit/gtk/tests/testcontextmenu.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testcopyandpaste.c: Renamed from Source/WebKit/gtk/tests/testcopyandpaste.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testdomdocument.c: Renamed from Source/WebKit/gtk/tests/testdomdocument.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testdomdomwindow.c: Renamed from Source/WebKit/gtk/tests/testdomdomwindow.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testdomnode.c: Renamed from Source/WebKit/gtk/tests/testdomnode.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testdownload.c: Renamed from Source/WebKit/gtk/tests/testdownload.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testfavicondatabase.c: Renamed from Source/WebKit/gtk/tests/testfavicondatabase.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testglobals.c: Renamed from Source/WebKit/gtk/tests/testglobals.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testhittestresult.c: Renamed from Source/WebKit/gtk/tests/testhittestresult.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testhttpbackend.c: Renamed from Source/WebKit/gtk/tests/testhttpbackend.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testkeyevents.c: Renamed from Source/WebKit/gtk/tests/testkeyevents.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testloading.c: Renamed from Source/WebKit/gtk/tests/testloading.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testmimehandling.c: Renamed from Source/WebKit/gtk/tests/testmimehandling.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testnetworkrequest.c: Renamed from Source/WebKit/gtk/tests/testnetworkrequest.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testnetworkresponse.c: Renamed from Source/WebKit/gtk/tests/testnetworkresponse.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testwebbackforwardlist.c: Renamed from Source/WebKit/gtk/tests/testwebbackforwardlist.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testwebdatasource.c: Renamed from Source/WebKit/gtk/tests/testwebdatasource.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testwebframe.c: Renamed from Source/WebKit/gtk/tests/testwebframe.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testwebhistoryitem.c: Renamed from Source/WebKit/gtk/tests/testwebhistoryitem.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testwebinspector.c: Renamed from Source/WebKit/gtk/tests/testwebinspector.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testwebplugindatabase.c: Renamed from Source/WebKit/gtk/tests/testwebplugindatabase.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testwebresource.c: Renamed from Source/WebKit/gtk/tests/testwebresource.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testwebsettings.c: Renamed from Source/WebKit/gtk/tests/testwebsettings.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testwebview.c: Renamed from Source/WebKit/gtk/tests/testwebview.c.
+ * TestWebKitAPI/Tests/WebKitGtk/testwindow.c: Renamed from Source/WebKit/gtk/tests/testwindow.c.
+
</ins><span class="cx"> 2014-01-06 Alexey Proskuryakov <ap@apple.com>
</span><span class="cx">
</span><span class="cx"> Gtk and Efl API test results confuse the dashboard
</span></span></pre></div>
<a id="trunkToolsScriptsrungtktests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-gtk-tests (161365 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/run-gtk-tests        2014-01-06 21:00:03 UTC (rev 161365)
+++ trunk/Tools/Scripts/run-gtk-tests        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -58,35 +58,35 @@
</span><span class="cx"> pass
</span><span class="cx">
</span><span class="cx"> class TestRunner:
</span><del>- TEST_DIRS = [ "WebKit1GObjectAPITests", "WebKit2GObjectAPITests", "TestWebKitAPI" ]
</del><ins>+ TEST_DIRS = [ "WebKit2Gtk", "WebKitGtk", "WebKit2", "JavaScriptCore", "WTF", "WebCore", "WebCoreGtk" ]
</ins><span class="cx">
</span><span class="cx"> SKIPPED = [
</span><del>- SkippedTest("WebKit1GObjectAPITests/testdownload", "/webkit/download/not-found", "Test fails in GTK Linux 64-bit Release bot", 82329),
- SkippedTest("WebKit1GObjectAPITests/testwebinspector", "/webkit/webinspector/close-and-inspect", "Test is flaky in GTK Linux 32-bit Release bot", 82869),
- SkippedTest("WebKit1GObjectAPITests/testwebresource", "/webkit/webresource/loading", "Test fails", 104689),
- SkippedTest("WebKit1GObjectAPITests/testwebresource", "/webkit/webresource/sub_resource_loading", "Test fails in GTK Linux 64-bit Release bot", 82330),
- SkippedTest("WebKit1GObjectAPITests/testwebview", "/webkit/webview/icon-uri", "Test times out in GTK Linux 64-bit Release bot", 82328),
- SkippedTest("WebKit2GObjectAPITests/TestResources", "/webkit2/WebKitWebView/resources", "Test is flaky in GTK Linux 32-bit Release bot", 82868),
- SkippedTest("WebKit2GObjectAPITests/TestUIClient", "/webkit2/WebKitWebView/mouse-target", "Test times out after r150890", 117689),
- SkippedTest("WebKit2GObjectAPITests/TestAuthentication", SkippedTest.ENTIRE_SUITE, "Test times out after r150890", 117689),
- SkippedTest("WebKit2GObjectAPITests/TestContextMenu", SkippedTest.ENTIRE_SUITE, "Test times out after r150890", 117689),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.MouseMoveAfterCrash", "Test is flaky", 85066),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.NewFirstVisuallyNonEmptyLayoutForImages", "Test is flaky", 85066),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.NewFirstVisuallyNonEmptyLayoutFrames", "Test fails", 85037),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.RestoreSessionStateContainingFormData", "Session State is not implemented in GTK+ port", 84960),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.SpacebarScrolling", "Test fails", 84961),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.WKConnection", "Tests fail and time out out", 84959),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.WKPageGetScaleFactorNotZero", "Test fails and times out", 88455),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.ForceRepaint", "Test times out", 105532),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.ReloadPageAfterCrash", "Test flakily times out", 110129),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.DidAssociateFormControls", "Test times out", 120302),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.InjectedBundleFrameHitTest", "Test times out", 120303),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.ResizeReversePaginatedWebView", "Test fails", 120305),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.ScrollPinningBehaviors", "Test fails", 120306),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.TerminateTwice", "Test causes crash on the next test", 121970),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.GeolocationTransitionToHighAccuracy", "Test causes crash on the next test", 125068),
- SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.GeolocationTransitionToLowAccuracy", "Test causes crash on the next test", 125068),
- SkippedTest("WebKit2GObjectAPITests/TestInspectorServer", SkippedTest.ENTIRE_SUITE, "Timing out on the bot", 122571),
</del><ins>+ SkippedTest("WebKitGtk/testdownload", "/webkit/download/not-found", "Test fails in GTK Linux 64-bit Release bot", 82329),
+ SkippedTest("WebKitGtk/testwebinspector", "/webkit/webinspector/close-and-inspect", "Test is flaky in GTK Linux 32-bit Release bot", 82869),
+ SkippedTest("WebKitGtk/testwebresource", "/webkit/webresource/loading", "Test fails", 104689),
+ SkippedTest("WebKitGtk/testwebresource", "/webkit/webresource/sub_resource_loading", "Test fails in GTK Linux 64-bit Release bot", 82330),
+ SkippedTest("WebKitGtk/testwebview", "/webkit/webview/icon-uri", "Test times out in GTK Linux 64-bit Release bot", 82328),
+ SkippedTest("WebKit2Gtk/TestResources", "/webkit2/WebKitWebView/resources", "Test is flaky in GTK Linux 32-bit Release bot", 82868),
+ SkippedTest("WebKit2Gtk/TestUIClient", "/webkit2/WebKitWebView/mouse-target", "Test times out after r150890", 117689),
+ SkippedTest("WebKit2Gtk/TestAuthentication", SkippedTest.ENTIRE_SUITE, "Test times out after r150890", 117689),
+ SkippedTest("WebKit2Gtk/TestContextMenu", SkippedTest.ENTIRE_SUITE, "Test times out after r150890", 117689),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.MouseMoveAfterCrash", "Test is flaky", 85066),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.NewFirstVisuallyNonEmptyLayoutForImages", "Test is flaky", 85066),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.NewFirstVisuallyNonEmptyLayoutFrames", "Test fails", 85037),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.RestoreSessionStateContainingFormData", "Session State is not implemented in GTK+ port", 84960),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.SpacebarScrolling", "Test fails", 84961),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.WKConnection", "Tests fail and time out out", 84959),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.WKPageGetScaleFactorNotZero", "Test fails and times out", 88455),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.ForceRepaint", "Test times out", 105532),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.ReloadPageAfterCrash", "Test flakily times out", 110129),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.DidAssociateFormControls", "Test times out", 120302),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.InjectedBundleFrameHitTest", "Test times out", 120303),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.ResizeReversePaginatedWebView", "Test fails", 120305),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.ScrollPinningBehaviors", "Test fails", 120306),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.TerminateTwice", "Test causes crash on the next test", 121970),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.GeolocationTransitionToHighAccuracy", "Test causes crash on the next test", 125068),
+ SkippedTest("WebKit2/TestWebKit2", "WebKit2.GeolocationTransitionToLowAccuracy", "Test causes crash on the next test", 125068),
+ SkippedTest("WebKit2Gtk/TestInspectorServer", SkippedTest.ENTIRE_SUITE, "Timing out on the bot", 122571),
</ins><span class="cx"> ]
</span><span class="cx">
</span><span class="cx"> def __init__(self, options, tests=[]):
</span><span class="lines">@@ -106,6 +106,9 @@
</span><span class="cx"> self._spi_registryd = None
</span><span class="cx"> self._spi_bus_launcher = None
</span><span class="cx">
</span><ins>+ def _test_programs_base_dir(self):
+ return os.path.join(self._programs_path, "TestWebKitAPI")
+
</ins><span class="cx"> def _get_tests_from_dir(self, test_dir):
</span><span class="cx"> if not os.path.isdir(test_dir):
</span><span class="cx"> return []
</span><span class="lines">@@ -131,7 +134,7 @@
</span><span class="cx">
</span><span class="cx"> tests = []
</span><span class="cx"> for test_dir in self.TEST_DIRS:
</span><del>- absolute_test_dir = os.path.join(self._programs_path, test_dir)
</del><ins>+ absolute_test_dir = os.path.join(self._test_programs_base_dir(), test_dir)
</ins><span class="cx"> tests.extend(self._get_tests_from_dir(absolute_test_dir))
</span><span class="cx"> return tests
</span><span class="cx">
</span><span class="lines">@@ -361,17 +364,18 @@
</span><span class="cx"> return 0
</span><span class="cx">
</span><span class="cx"> def _run_test(self, test_program):
</span><del>- if "GObjectAPITest" in test_program:
</del><ins>+ basedir = os.path.basename(os.path.dirname(test_program))
+ if basedir in ["WebKit2Gtk", "WebKitGtk"]:
</ins><span class="cx"> return self._run_test_glib(test_program)
</span><span class="cx">
</span><del>- if "TestWebKitAPI" in test_program:
</del><ins>+ if basedir in ["WebKit2", "JavaScriptCore", "WTF", "WebCore", "WebCoreGtk"]:
</ins><span class="cx"> return self._run_google_test_suite(test_program)
</span><span class="cx">
</span><span class="cx"> return 1
</span><span class="cx">
</span><span class="cx"> def run_tests(self):
</span><span class="cx"> if not self._tests:
</span><del>- sys.stderr.write("ERROR: tests not found in %s.\n" % (self._programs_path))
</del><ins>+ sys.stderr.write("ERROR: tests not found in %s.\n" % (self._test_programs_base_dir()))
</ins><span class="cx"> sys.stderr.flush()
</span><span class="cx"> return 1
</span><span class="cx">
</span><span class="lines">@@ -405,17 +409,17 @@
</span><span class="cx"> self._tear_down_testing_environment()
</span><span class="cx">
</span><span class="cx"> if failed_tests:
</span><del>- names = [test.replace(self._programs_path, '', 1) for test in failed_tests]
</del><ins>+ names = [test.replace(self._test_programs_base_dir(), '', 1) for test in failed_tests]
</ins><span class="cx"> sys.stdout.write("Tests failed (%d): %s\n" % (len(names), ", ".join(names)))
</span><span class="cx"> sys.stdout.flush()
</span><span class="cx">
</span><span class="cx"> if crashed_tests:
</span><del>- names = [test.replace(self._programs_path, '', 1) for test in crashed_tests]
</del><ins>+ names = [test.replace(self._test_programs_base_dir(), '', 1) for test in crashed_tests]
</ins><span class="cx"> sys.stdout.write("Tests that crashed (%d): %s\n" % (len(names), ", ".join(names)))
</span><span class="cx"> sys.stdout.flush()
</span><span class="cx">
</span><span class="cx"> if timed_out_tests:
</span><del>- names = [test.replace(self._programs_path, '', 1) for test in timed_out_tests]
</del><ins>+ names = [test.replace(self._test_programs_base_dir(), '', 1) for test in timed_out_tests]
</ins><span class="cx"> sys.stdout.write("Tests that timed out (%d): %s\n" % (len(names), ", ".join(names)))
</span><span class="cx"> sys.stdout.flush()
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylecheckerpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (161365 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/checker.py        2014-01-06 21:00:03 UTC (rev 161365)
+++ trunk/Tools/Scripts/webkitpy/style/checker.py        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -317,7 +317,7 @@
</span><span class="cx"> # WebKit maintains some files in Mozilla style on purpose to ease
</span><span class="cx"> # future merges.
</span><span class="cx"> _SKIPPED_FILES_WITH_WARNING = [
</span><del>- "Source/WebKit/gtk/tests/",
</del><ins>+ "Tools/TestWebKitAPI/Tests/WebKitGtk/",
</ins><span class="cx"> # All WebKit*.h files in Source/WebKit2/UIProcess/API/gtk,
</span><span class="cx"> # except those ending in ...Private.h are GTK+ API headers,
</span><span class="cx"> # which differ greatly from WebKit coding style.
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylechecker_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/checker_unittest.py (161365 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/checker_unittest.py        2014-01-06 21:00:03 UTC (rev 161365)
+++ trunk/Tools/Scripts/webkitpy/style/checker_unittest.py        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -280,7 +280,7 @@
</span><span class="cx"> """Test should_skip_with_warning()."""
</span><span class="cx"> # Check skipped files.
</span><span class="cx"> paths_to_skip = [
</span><del>- "Source/WebKit/gtk/tests/testatk.c",
</del><ins>+ "Tools/TestWebKitAPI/Tests/WebKitGtk/testatk.c",
</ins><span class="cx"> "Source/WebKit2/UIProcess/API/gtk/webkit2.h",
</span><span class="cx"> "Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h",
</span><span class="cx"> "Source/WebKit2/UIProcess/API/gtk/WebKitLoader.h",
</span><span class="lines">@@ -297,8 +297,8 @@
</span><span class="cx"> "Source/WebKit2/UIProcess/API/gtk/HelperClass.h",
</span><span class="cx"> "Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp",
</span><span class="cx"> "Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h",
</span><del>- "Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp",
- "Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h",
</del><ins>+ "Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebViewTest.cpp",
+ "Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebViewTest.h",
</ins><span class="cx"> ]
</span><span class="cx">
</span><span class="cx"> for path in paths_not_to_skip:
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIGNUmakefileam"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/GNUmakefile.am (161365 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/GNUmakefile.am        2014-01-06 21:00:03 UTC (rev 161365)
+++ trunk/Tools/TestWebKitAPI/GNUmakefile.am        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -1,6 +1,11 @@
</span><span class="cx"> noinst_LTLIBRARIES += \
</span><span class="cx">         Libraries/libTestWebKitAPIMain.la
</span><span class="cx">
</span><ins>+if ENABLE_WEBKIT2
+noinst_LTLIBRARIES += \
+        Libraries/libTestWebKit2GtkAPI.la
+endif
+
</ins><span class="cx"> Libraries_libTestWebKitAPIMain_la_SOURCES = \
</span><span class="cx">         Tools/TestWebKitAPI/Test.h \
</span><span class="cx">         Tools/TestWebKitAPI/TestsController.cpp \
</span><span class="lines">@@ -20,37 +25,184 @@
</span><span class="cx">         $(javascriptcore_cppflags) \
</span><span class="cx">         $(GTK_CFLAGS)
</span><span class="cx">
</span><ins>+webkitgtk_tests_cflags = \
+        -fno-strict-aliasing \
+        -DTEST_PLUGIN_DIR=\"${shell pwd}/${top_builddir}/TestNetscapePlugin/.libs\" \
+        -I$(srcdir)/Source/JavaScriptCore/ForwardingHeaders \
+        -I$(WebKit) \
+        -I$(GENSOURCES) \
+        -I$(top_builddir)/Source/WebKit/gtk \
+        -I$(top_srcdir)/Source/WebCore/bindings \
+        -I$(top_srcdir)/Source/WebCore/bindings/gobject \
+        $(global_cppflags) \
+        $(global_cflags) \
+        $(javascriptcore_cppflags) \
+        $(FREETYPE_CFLAGS) \
+        $(GLIB_CFLAGS) \
+        $(GTK_CFLAGS) \
+        $(LIBSOUP_CFLAGS) \
+        $(XRENDER_CFLAGS) \
+        $(XT_CFLAGS)
+
+webkitgtk_tests_ldadd = \
+        libjavascriptcoregtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
+        libwebkitgtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
+        $(FREETYPE_LIBS) \
+        $(GTK_LIBS) \
+        $(GLIB_LIBS) \
+        $(LIBSOUP_LIBS) \
+        $(XRENDER_LIBS)
+
+webkitgtk_tests_ldflags = \
+        -no-install
+
+
+webkit2gtk_tests_cppflags = \
+        -DWEBKIT_EXEC_PATH=\"${shell pwd}/$(top_builddir)/Programs\" \
+        -DWEBKIT_SRC_DIR=\"${shell pwd}/${srcdir}\" \
+        -DWEBKIT_DERIVED_SRC_DIR=\"${shell pwd}/${top_builddir}/DerivedSources\" \
+        -DWEBKIT_TEST_PLUGIN_DIR=\"${shell pwd}/${top_builddir}/TestNetscapePlugin/.libs\" \
+        -DWEBKIT_TEST_WEB_EXTENSIONS_DIR=\"${shell pwd}/${top_builddir}/Libraries/WebExtensions/.libs\" \
+        -DWEBKIT_INJECTED_BUNDLE_PATH=\"${shell pwd}/$(top_builddir)/.libs\" \
+        $(javascriptcore_cppflags) \
+        -I$(srcdir)/Source \
+        -I$(srcdir)/Source/WebKit2 \
+        -I$(srcdir)/Source/JavaScriptCore \
+        -I$(srcdir)/Tools/TestWebKitAPI/gtk/WebKit2Gtk \
+        -I$(top_builddir)/DerivedSources/WebKit2/include \
+        -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk \
+        -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk/include \
+        -I$(srcdir)/Source/WebKit2/UIProcess/API/gtk \
+        $(global_cppflags) \
+        $(FREETYPE_CFLAGS) \
+        $(GLIB_CFLAGS) \
+        $(GTK_CFLAGS) \
+        $(LIBSOUP_CFLAGS)
+
+webkit2gtk_tests_ldadd = \
+        Libraries/libTestWebKit2GtkAPI.la \
+        libjavascriptcoregtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
+        libwebkit2gtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
+        $(FREETYPE_LIBS) \
+        $(GEOCLUE_LIBS) \
+        $(GLIB_LIBS) \
+        $(GTK_LIBS) \
+        $(LIBSOUP_LIBS)
+
+webkit2gtk_tests_ldflags = \
+        -no-install
+
+Libraries_libTestWebKit2GtkAPI_la_SOURCES = \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/LoadTrackingTest.cpp \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/LoadTrackingTest.h \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.cpp \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.h \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestServer.cpp \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestServer.h \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.cpp \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp \
+        Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h
+
+Libraries_libTestWebKit2GtkAPI_la_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+
+
</ins><span class="cx"> noinst_PROGRAMS += \
</span><del>-        Programs/TestWebKitAPI/TestWTF \
-        Programs/TestWebKitAPI/TestJavaScriptCore \
-        Programs/TestWebKitAPI/TestWebCore \
-        Programs/TestWebKitAPI/TestGtk
</del><ins>+        Programs/TestWebKitAPI/WTF/TestWTF \
+        Programs/TestWebKitAPI/JavaScriptCore/TestJavaScriptCore \
+        Programs/TestWebKitAPI/WebCore/TestWebCore \
+        Programs/TestWebKitAPI/WebCoreGtk/TestWebCoreGtk
</ins><span class="cx">
</span><ins>+if ENABLE_WEBKIT1
+noinst_PROGRAMS += \
+        Programs/TestWebKitAPI/WebKitGtk/testapplicationcache \
+        Programs/TestWebKitAPI/WebKitGtk/testcontextmenu \
+        Programs/TestWebKitAPI/WebKitGtk/testdomdocument \
+        Programs/TestWebKitAPI/WebKitGtk/testdomdomwindow \
+        Programs/TestWebKitAPI/WebKitGtk/testdomnode \
+        Programs/TestWebKitAPI/WebKitGtk/testhttpbackend \
+        Programs/TestWebKitAPI/WebKitGtk/testfavicondatabase \
+        Programs/TestWebKitAPI/WebKitGtk/testloading \
+        Programs/TestWebKitAPI/WebKitGtk/testglobals \
+        Programs/TestWebKitAPI/WebKitGtk/testmimehandling \
+        Programs/TestWebKitAPI/WebKitGtk/testnetworkrequest \
+        Programs/TestWebKitAPI/WebKitGtk/testnetworkresponse \
+        Programs/TestWebKitAPI/WebKitGtk/testwebframe \
+        Programs/TestWebKitAPI/WebKitGtk/testwebbackforwardlist \
+        Programs/TestWebKitAPI/WebKitGtk/testwebhistoryitem \
+        Programs/TestWebKitAPI/WebKitGtk/testwindow \
+        Programs/TestWebKitAPI/WebKitGtk/testdownload \
+        Programs/TestWebKitAPI/WebKitGtk/testatk \
+        Programs/TestWebKitAPI/WebKitGtk/testatkroles \
+        Programs/TestWebKitAPI/WebKitGtk/testhittestresult \
+        Programs/TestWebKitAPI/WebKitGtk/testwebinspector \
+        Programs/TestWebKitAPI/WebKitGtk/testwebsettings \
+        Programs/TestWebKitAPI/WebKitGtk/testwebresource \
+        Programs/TestWebKitAPI/WebKitGtk/testwebdatasource \
+        Programs/TestWebKitAPI/WebKitGtk/testwebplugindatabase \
+        Programs/TestWebKitAPI/WebKitGtk/testwebview \
+        Programs/TestWebKitAPI/WebKitGtk/testkeyevents \
+        Programs/TestWebKitAPI/WebKitGtk/testcopyandpaste
+endif
+
</ins><span class="cx"> if ENABLE_WEBKIT2
</span><span class="cx"> noinst_PROGRAMS += \
</span><del>-        Programs/TestWebKitAPI/TestWebKit2
</del><ins>+        Programs/TestWebKitAPI/WebKit2/TestWebKit2 \
+        Programs/TestWebKitAPI/WebKit2Gtk/InspectorTestServer \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestAuthentication \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestBackForwardList \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestContextMenu \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestCookieManager \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestDOMNode \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestDownloads \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestFrame \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestInspector \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestInspectorServer \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestLoaderClient \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestPrinting \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestResources \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestSSL \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestUIClient \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestWebExtensions \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestWebKitVersion \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestWebKitFaviconDatabase \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestWebKitFindController \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestWebKitPolicyClient \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestWebKitSettings \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestWebKitWebContext \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestWebKitWebView \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestWebKitWebViewGroup \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestWebViewEditor
+
+if HAVE_ATSPI2
+noinst_PROGRAMS += \
+        Programs/TestWebKitAPI/WebKit2Gtk/AccessibilityTestServer \
+        Programs/TestWebKitAPI/WebKit2Gtk/TestWebKitAccessibility
+endif
</ins><span class="cx"> endif # ENABLE_WEBKIT2
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWTF_CPPFLAGS = \
</del><ins>+Programs_TestWebKitAPI_WTF_TestWTF_CPPFLAGS = \
</ins><span class="cx">         $(Libraries_libTestWebKitAPIMain_la_CPPFLAGS) \
</span><span class="cx">         $(GLIB_LIBS) \
</span><span class="cx">         $(CAIRO_CFLAGS)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWTF_CXXFLAGS = \
</del><ins>+Programs_TestWebKitAPI_WTF_TestWTF_CXXFLAGS = \
</ins><span class="cx">         -DGTEST_HAS_RTTI=0 \
</span><span class="cx">         $(global_cxxflags)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWTF_LDADD = \
</del><ins>+Programs_TestWebKitAPI_WTF_TestWTF_LDADD = \
</ins><span class="cx">         Libraries/libTestWebKitAPIMain.la \
</span><span class="cx">         Libraries/libgtest.la \
</span><span class="cx">         libWTF.la \
</span><span class="cx">         $(GTK_LIBS) \
</span><span class="cx">         $(GLIB_LIBS)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWTF_LDFLAGS = \
</del><ins>+Programs_TestWebKitAPI_WTF_TestWTF_LDFLAGS = \
</ins><span class="cx">         -no-install
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWTF_SOURCES = \
</del><ins>+Programs_TestWebKitAPI_WTF_TestWTF_SOURCES = \
</ins><span class="cx">         Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp \
</span><span class="cx">         Tools/TestWebKitAPI/Tests/WTF/CString.cpp \
</span><span class="cx">         Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp \
</span><span class="lines">@@ -78,23 +230,23 @@
</span><span class="cx">         Tools/TestWebKitAPI/Tests/WTF/Vector.cpp \
</span><span class="cx">         Tools/TestWebKitAPI/WTFStringUtilities.h
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestJavaScriptCore_CPPFLAGS = \
</del><ins>+Programs_TestWebKitAPI_JavaScriptCore_TestJavaScriptCore_CPPFLAGS = \
</ins><span class="cx">         $(Libraries_libTestWebKitAPIMain_la_CPPFLAGS)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestJavaScriptCore_CXXFLAGS = \
</del><ins>+Programs_TestWebKitAPI_JavaScriptCore_TestJavaScriptCore_CXXFLAGS = \
</ins><span class="cx">         -DGTEST_HAS_RTTI=0 \
</span><span class="cx">         $(global_cxxflags)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestJavaScriptCore_LDADD = \
</del><ins>+Programs_TestWebKitAPI_JavaScriptCore_TestJavaScriptCore_LDADD = \
</ins><span class="cx">         Libraries/libTestWebKitAPIMain.la \
</span><span class="cx">         Libraries/libgtest.la \
</span><span class="cx">         libWTF.la \
</span><span class="cx">         $(GTK_LIBS)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestJavaScriptCore_LDFLAGS = \
</del><ins>+Programs_TestWebKitAPI_JavaScriptCore_TestJavaScriptCore_LDFLAGS = \
</ins><span class="cx">         -no-install
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestJavaScriptCore_SOURCES = \
</del><ins>+Programs_TestWebKitAPI_JavaScriptCore_TestJavaScriptCore_SOURCES = \
</ins><span class="cx">         Tools/TestWebKitAPI/Tests/JavaScriptCore/VMInspector.cpp
</span><span class="cx">
</span><span class="cx"> webcore_layer_deps = \
</span><span class="lines">@@ -129,15 +281,15 @@
</span><span class="cx"> DISTCLEANFILES += \
</span><span class="cx">         $(top_builddir)/libWebCoreLayer.a
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWebCore_CPPFLAGS = \
</del><ins>+Programs_TestWebKitAPI_WebCore_TestWebCore_CPPFLAGS = \
</ins><span class="cx">         $(Libraries_libTestWebKitAPIMain_la_CPPFLAGS) \
</span><span class="cx">         -I$(top_builddir)/DerivedSources/WebCore/include
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWebCore_CXXFLAGS = \
</del><ins>+Programs_TestWebKitAPI_WebCore_TestWebCore_CXXFLAGS = \
</ins><span class="cx">         -DGTEST_HAS_RTTI=0 \
</span><span class="cx">         $(global_cxxflags)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWebCore_LDADD = \
</del><ins>+Programs_TestWebKitAPI_WebCore_TestWebCore_LDADD = \
</ins><span class="cx">         Libraries/libTestWebKitAPIMain.la \
</span><span class="cx">         Libraries/libgtest.la \
</span><span class="cx">         libjavascriptcoregtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
</span><span class="lines">@@ -164,15 +316,15 @@
</span><span class="cx">         $(XT_LIBS) \
</span><span class="cx">         $(ZLIB_LIBS)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWebCore_LDFLAGS = \
</del><ins>+Programs_TestWebKitAPI_WebCore_TestWebCore_LDFLAGS = \
</ins><span class="cx">         -no-install
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWebCore_SOURCES = \
</del><ins>+Programs_TestWebKitAPI_WebCore_TestWebCore_SOURCES = \
</ins><span class="cx">         Tools/TestWebKitAPI/Tests/WebCore/URL.cpp \
</span><span class="cx">         Tools/TestWebKitAPI/Tests/WebCore/LayoutUnit.cpp
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestGtk_CPPFLAGS = \
-        $(Programs_TestWebKitAPI_TestWTF_CPPFLAGS) \
</del><ins>+Programs_TestWebKitAPI_WebCoreGtk_TestWebCoreGtk_CPPFLAGS = \
+        $(Programs_TestWebKitAPI_WTF_TestWTF_CPPFLAGS) \
</ins><span class="cx">         $(platform_cppflags) \
</span><span class="cx">         $(platformgtk_cppflags) \
</span><span class="cx">         $(webcore_cppflags) \
</span><span class="lines">@@ -182,11 +334,11 @@
</span><span class="cx">         $(GTK_CFLAGS) \
</span><span class="cx">         $(LIBSOUP_CFLAGS)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestGtk_CXXFLAGS = \
</del><ins>+Programs_TestWebKitAPI_WebCoreGtk_TestWebCoreGtk_CXXFLAGS = \
</ins><span class="cx">         -DGTEST_HAS_RTTI=0 \
</span><span class="cx">         $(global_cxxflags)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestGtk_LDADD = \
</del><ins>+Programs_TestWebKitAPI_WebCoreGtk_TestWebCoreGtk_LDADD = \
</ins><span class="cx">         Libraries/libTestWebKitAPIMain.la \
</span><span class="cx">         Libraries/libgtest.la \
</span><span class="cx">         libjavascriptcoregtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
</span><span class="lines">@@ -198,10 +350,10 @@
</span><span class="cx">         $(GTK_LIBS) \
</span><span class="cx">         $(LIBSOUP_LIBS)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestGtk_LDFLAGS = \
-        $(Programs_TestWebKitAPI_TestWTF_LDFLAGS)
</del><ins>+Programs_TestWebKitAPI_WebCoreGtk_TestWebCoreGtk_LDFLAGS = \
+        $(Programs_TestWebKitAPI_WTF_TestWTF_LDFLAGS)
</ins><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestGtk_SOURCES = \
</del><ins>+Programs_TestWebKitAPI_WebCoreGtk_TestWebCoreGtk_SOURCES = \
</ins><span class="cx">         Source/WebCore/platform/graphics/IntPoint.cpp \
</span><span class="cx">         Source/WebCore/platform/graphics/IntRect.cpp \
</span><span class="cx">         Source/WebCore/platform/graphics/IntSize.cpp \
</span><span class="lines">@@ -211,19 +363,192 @@
</span><span class="cx">         Tools/TestWebKitAPI/config.h \
</span><span class="cx">         Tools/TestWebKitAPI/Tests/gtk/InputMethodFilter.cpp
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWebKit2_CPPFLAGS = \
-        $(Programs_TestWebKitAPI_TestWTF_CPPFLAGS) \
</del><ins>+Programs_TestWebKitAPI_WebKitGtk_testapplicationcache_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testapplicationcache.c
+Programs_TestWebKitAPI_WebKitGtk_testapplicationcache_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testapplicationcache_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testapplicationcache_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testcontextmenu_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testcontextmenu.c
+Programs_TestWebKitAPI_WebKitGtk_testcontextmenu_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testcontextmenu_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testcontextmenu_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testdomdocument_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testdomdocument.c
+Programs_TestWebKitAPI_WebKitGtk_testdomdocument_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testdomdocument_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testdomdocument_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testdomdomwindow_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testdomdomwindow.c
+Programs_TestWebKitAPI_WebKitGtk_testdomdomwindow_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testdomdomwindow_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testdomdomwindow_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testdomnode_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testdomnode.c
+Programs_TestWebKitAPI_WebKitGtk_testdomnode_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testdomnode_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testdomnode_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testhttpbackend_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testhttpbackend.c
+Programs_TestWebKitAPI_WebKitGtk_testhttpbackend_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testhttpbackend_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testhttpbackend_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testfavicondatabase_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testfavicondatabase.c \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/test_utils.c
+Programs_TestWebKitAPI_WebKitGtk_testfavicondatabase_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testfavicondatabase_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testfavicondatabase_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testglobals_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testglobals.c
+Programs_TestWebKitAPI_WebKitGtk_testglobals_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testglobals_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testglobals_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testloading_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testloading.c
+Programs_TestWebKitAPI_WebKitGtk_testloading_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testloading_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testloading_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testmimehandling_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testmimehandling.c \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/test_utils.c
+Programs_TestWebKitAPI_WebKitGtk_testmimehandling_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testmimehandling_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testmimehandling_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testnetworkrequest_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testnetworkrequest.c
+Programs_TestWebKitAPI_WebKitGtk_testnetworkrequest_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testnetworkrequest_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testnetworkrequest_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testnetworkresponse_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testnetworkresponse.c
+Programs_TestWebKitAPI_WebKitGtk_testnetworkresponse_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testnetworkresponse_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testnetworkresponse_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testwebframe_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testwebframe.c
+Programs_TestWebKitAPI_WebKitGtk_testwebframe_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testwebframe_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testwebframe_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testwebplugindatabase_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testwebplugindatabase.c
+Programs_TestWebKitAPI_WebKitGtk_testwebplugindatabase_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testwebplugindatabase_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testwebplugindatabase_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testwebbackforwardlist_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testwebbackforwardlist.c
+Programs_TestWebKitAPI_WebKitGtk_testwebbackforwardlist_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testwebbackforwardlist_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testwebbackforwardlist_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testwebhistoryitem_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testwebhistoryitem.c
+Programs_TestWebKitAPI_WebKitGtk_testwebhistoryitem_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testwebhistoryitem_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testwebhistoryitem_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testwindow_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testwindow.c
+Programs_TestWebKitAPI_WebKitGtk_testwindow_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testwindow_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testwindow_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testdownload_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testdownload.c
+Programs_TestWebKitAPI_WebKitGtk_testdownload_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testdownload_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testdownload_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testatk_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testatk.c
+Programs_TestWebKitAPI_WebKitGtk_testatk_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testatk_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testatk_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testatkroles_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testatkroles.c
+Programs_TestWebKitAPI_WebKitGtk_testatkroles_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testatkroles_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testatkroles_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testwebinspector_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testwebinspector.c \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/test_utils.c
+Programs_TestWebKitAPI_WebKitGtk_testwebinspector_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testwebinspector_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testwebinspector_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testwebsettings_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testwebsettings.c
+Programs_TestWebKitAPI_WebKitGtk_testwebsettings_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testwebsettings_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testwebsettings_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testwebresource_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testwebresource.c
+Programs_TestWebKitAPI_WebKitGtk_testwebresource_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testwebresource_LDADD = $(webkitgtk_tests_ldadd)
+
+Programs_TestWebKitAPI_WebKitGtk_testwebdatasource_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testwebdatasource.c
+Programs_TestWebKitAPI_WebKitGtk_testwebdatasource_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testwebdatasource_LDADD = $(webkitgtk_tests_ldadd)
+
+Programs_TestWebKitAPI_WebKitGtk_testwebview_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testwebview.c Tools/TestWebKitAPI/Tests/WebKitGtk/test_utils.c
+Programs_TestWebKitAPI_WebKitGtk_testwebview_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testwebview_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testwebview_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testhittestresult_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testhittestresult.c
+Programs_TestWebKitAPI_WebKitGtk_testhittestresult_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testhittestresult_LDADD = $(webkitgtk_tests_ldadd)
+
+Programs_TestWebKitAPI_WebKitGtk_testkeyevents_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testkeyevents.c
+Programs_TestWebKitAPI_WebKitGtk_testkeyevents_CFLAGS = $(webkitgtk_tests_cflags)
+Programs_TestWebKitAPI_WebKitGtk_testkeyevents_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testkeyevents_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKitGtk_testcopyandpaste_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/testcopyandpaste.c \
+        Source/WebCore/platform/gtk/GtkVersioning.c
+Programs_TestWebKitAPI_WebKitGtk_testcopyandpaste_CFLAGS = \
+        $(webkitgtk_tests_cflags) \
+        -I$(srcdir)/Source/WebCore/platform/gtk \
+        -I$(srcdir)/Source/WebCore
+Programs_TestWebKitAPI_WebKitGtk_testcopyandpaste_LDADD = $(webkitgtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKitGtk_testcopyandpaste_LDFLAGS = $(webkitgtk_tests_ldflags)
+
+
+Programs_TestWebKitAPI_WebKit2_TestWebKit2_CPPFLAGS = \
+        $(Programs_TestWebKitAPI_WTF_TestWTF_CPPFLAGS) \
</ins><span class="cx">         -I$(top_builddir)/DerivedSources/WebKit2/include \
</span><span class="cx">         $(FREETYPE_CFLAGS) \
</span><span class="cx">         $(GLIB_CFLAGS) \
</span><span class="cx">         $(GTK_CFLAGS) \
</span><span class="cx">         $(LIBSOUP_CFLAGS)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWebKit2_CXXFLAGS = \
</del><ins>+Programs_TestWebKitAPI_WebKit2_TestWebKit2_CXXFLAGS = \
</ins><span class="cx">         -DGTEST_HAS_RTTI=0 \
</span><span class="cx">         $(global_cxxflags)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWebKit2_LDADD = \
</del><ins>+Programs_TestWebKitAPI_WebKit2_TestWebKit2_LDADD = \
</ins><span class="cx">         Libraries/libTestWebKitAPIMain.la \
</span><span class="cx">         Libraries/libgtest.la \
</span><span class="cx">         libjavascriptcoregtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
</span><span class="lines">@@ -233,10 +558,10 @@
</span><span class="cx">         $(GTK_LIBS) \
</span><span class="cx">         $(LIBSOUP_LIBS)
</span><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWebKit2_LDFLAGS = \
-        $(Programs_TestWebKitAPI_TestWTF_LDFLAGS)
</del><ins>+Programs_TestWebKitAPI_WebKit2_TestWebKit2_LDFLAGS = \
+        $(Programs_TestWebKitAPI_WTF_TestWTF_LDFLAGS)
</ins><span class="cx">
</span><del>-Programs_TestWebKitAPI_TestWebKit2_SOURCES = \
</del><ins>+Programs_TestWebKitAPI_WebKit2_TestWebKit2_SOURCES = \
</ins><span class="cx">         Tools/TestWebKitAPI/config.h \
</span><span class="cx">         Tools/TestWebKitAPI/gtk/PlatformUtilitiesGtk.cpp \
</span><span class="cx">         Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp \
</span><span class="lines">@@ -357,11 +682,245 @@
</span><span class="cx">         $(global_cflags)
</span><span class="cx">
</span><span class="cx">
</span><del>-stamp-testwebkitapi-webcore-forwarding-headers: $(WebKit2)/Scripts/generate-forwarding-headers.pl $(Programs_TestWebKitAPI_TestWebCore_SOURCES)
</del><ins>+if ENABLE_WEBKIT2
+noinst_LTLIBRARIES += Libraries/WebExtensions/libWebExtensionTest.la
+endif
+
+Libraries_WebExtensions_libWebExtensionTest_la_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp
+
+Libraries_WebExtensions_libWebExtensionTest_la_LDFLAGS = \
+        -rpath ${shell pwd}/$(top_builddir)/Libraries/WebExtensions/.libs \
+        $(no_undefined) \
+        -avoid-version \
+        -module
+
+Libraries_WebExtensions_libWebExtensionTest_la_CPPFLAGS = \
+        -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle/API/gtk \
+        -I$(top_builddir)/DerivedSources \
+        -I$(top_builddir)/DerivedSources/WebKit2/webkit2extension/include \
+        -DWEBKIT2_COMPILATION \
+        $(webkit2gtk_tests_cppflags)
+
+Libraries_WebExtensions_libWebExtensionTest_la_CXXFLAGS = \
+ $(global_cxxflags)
+
+Libraries_WebExtensions_libWebExtensionTest_la_CFLAGS = \
+ $(global_cflags)
+
+
+if ENABLE_WEBKIT2
+noinst_LTLIBRARIES += Libraries/WebExtensions/libWebProcessTest.la
+endif
+
+Libraries_WebExtensions_libWebProcessTest_la_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h
+
+Libraries_WebExtensions_libWebProcessTest_la_LDFLAGS = \
+        -rpath ${shell pwd}/$(top_builddir)/Libraries/WebExtensions/.libs \
+        $(no_undefined) \
+        -avoid-version \
+        -module
+
+Libraries_WebExtensions_libWebProcessTest_la_CPPFLAGS = \
+        -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle/API/gtk \
+        -I$(top_builddir)/DerivedSources \
+        -I$(top_builddir)/DerivedSources/WebKit2/webkit2extension/include \
+        -DWEBKIT2_COMPILATION \
+        $(webkit2gtk_tests_cppflags)
+
+Libraries_WebExtensions_libWebProcessTest_la_CXXFLAGS = \
+        $(global_cxxflags)
+
+Libraries_WebExtensions_libWebProcessTest_la_CFLAGS = \
+        $(global_cflags)
+
+
+Programs/TestWebKitAPI/WebKit2Gtk/resources/webkit2gtk-tests-resources.gresource: Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml)
+        $(AM_V_at)mkdir -p ${GENPROGRAMS}/TestWebKitAPI/WebKit2Gtk/resources
+        $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) $<
+
+DISTCLEANFILES += \
+        Programs/TestWebKitAPI/WebKit2Gtk/resources/webkit2gtk-tests-resources.gresource
+
+noinst_DATA += \
+        Programs/TestWebKitAPI/WebKit2Gtk/resources/webkit2gtk-tests-resources.gresource
+
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebContext_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebContext_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebContext_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebContext_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebView_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebView_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebView_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebView_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestLoaderClient_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestLoaderClient_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestLoaderClient_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestLoaderClient_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitSettings_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitSettings_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitSettings_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitSettings_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_InspectorTestServer_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/InspectorTestServer.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_InspectorTestServer_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_InspectorTestServer_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_InspectorTestServer_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestBackForwardList_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestBackForwardList_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestBackForwardList_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestBackForwardList_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitPolicyClient_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitPolicyClient_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitPolicyClient_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitPolicyClient_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+if HAVE_ATSPI2
+Programs_TestWebKitAPI_WebKit2Gtk_AccessibilityTestServer_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/AccessibilityTestServer.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_AccessibilityTestServer_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_AccessibilityTestServer_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_AccessibilityTestServer_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitAccessibility_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitAccessibility.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitAccessibility_CPPFLAGS = $(webkit2gtk_tests_cppflags) $(ATSPI2_CFLAGS)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitAccessibility_LDADD = $(webkit2gtk_tests_ldadd) $(ATSPI2_LIBS)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitAccessibility_LDFLAGS = $(webkit2gtk_tests_ldflags)
+endif
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestDownloads_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestDownloads_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestDownloads_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestDownloads_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebViewEditor_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebViewEditor_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebViewEditor_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebViewEditor_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestPrinting_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestPrinting_CPPFLAGS = $(webkit2gtk_tests_cppflags) $(GTK_UNIX_PRINTING_CFLAGS)
+Programs_TestWebKitAPI_WebKit2Gtk_TestPrinting_LDADD = $(webkit2gtk_tests_ldadd) $(GTK_UNIX_PRINTING_LIBS)
+Programs_TestWebKitAPI_WebKit2Gtk_TestPrinting_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitFaviconDatabase_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitFaviconDatabase_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitFaviconDatabase_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitFaviconDatabase_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitFindController_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFindController.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitFindController_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitFindController_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitFindController_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestResources_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestResources_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestResources_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestResources_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestCookieManager_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestCookieManager_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestCookieManager_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestCookieManager_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestInspector_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspector.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestInspector_CPPFLAGS = \
+        $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestInspector_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestInspector_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestInspectorServer_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspectorServer.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestInspectorServer_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestInspectorServer_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestInspectorServer_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitVersion_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitVersion.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitVersion_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitVersion_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitVersion_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestContextMenu_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestContextMenu_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestContextMenu_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestContextMenu_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestSSL_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestSSL_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestSSL_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestSSL_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebExtensions_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebExtensions_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebExtensions_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebExtensions_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebViewGroup_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebViewGroup.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebViewGroup_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebViewGroup_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitWebViewGroup_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestDOMNode_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestDOMNode_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestDOMNode_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestDOMNode_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestFrame_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestFrame_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestFrame_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestFrame_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestAuthentication_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestAuthentication_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestAuthentication_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestAuthentication_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+Programs_TestWebKitAPI_WebKit2Gtk_TestUIClient_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestUIClient_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestUIClient_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestUIClient_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
+
+stamp-testwebkitapi-webcore-forwarding-headers: $(WebKit2)/Scripts/generate-forwarding-headers.pl $(Programs_TestWebKitAPI_WebCore_TestWebCore_SOURCES)
</ins><span class="cx">         $(AM_V_GEN)$(PERL) $< $(srcdir)/Tools/TestWebKitAPI/Tests/WebCore $(GENSOURCES_WEBCORE)/include gtk \
</span><span class="cx">         && echo timestamp > $(@F)
</span><span class="cx">
</span><del>-stamp-testwebkitapi-webkit2-forwarding-headers: $(WebKit2)/Scripts/generate-forwarding-headers.pl $(Programs_TestWebKitAPI_TestWebKit2_SOURCES) $(Libraries_libTestWebKitAPIInjectedBundle_la_SOURCES)
</del><ins>+stamp-testwebkitapi-webkit2-forwarding-headers: $(WebKit2)/Scripts/generate-forwarding-headers.pl $(Programs_TestWebKitAPI_WebKit2_TestWebKit2_SOURCES) $(Libraries_libTestWebKitAPIInjectedBundle_la_SOURCES)
</ins><span class="cx">         $(AM_V_GEN)$(PERL) $< $(srcdir)/Tools/TestWebKitAPI $(GENSOURCES_WEBKIT2)/include gtk \
</span><span class="cx">         && echo timestamp > $(@F)
</span><span class="cx">
</span><span class="lines">@@ -386,4 +945,14 @@
</span><span class="cx">         Tools/TestWebKitAPI/Tests/WebKit2/simple.html \
</span><span class="cx">         Tools/TestWebKitAPI/Tests/WebKit2/simple-iframe.html \
</span><span class="cx">         Tools/TestWebKitAPI/Tests/WebKit2/simple-tall.html \
</span><del>-        Tools/TestWebKitAPI/Tests/WebKit2/spacebar-scrolling.html
</del><ins>+        Tools/TestWebKitAPI/Tests/WebKit2/spacebar-scrolling.html \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/test-cert.pem \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/test-key.pem \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/link-title.js \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/test_utils.h \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/resources/blank.ico \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/resources/test.html \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/resources/test.ogg \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/resources/test.pdf \
+        Tools/TestWebKitAPI/Tests/WebKitGtk/resources/test.txt
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkAccessibilityTestServercppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsAccessibilityTestServercpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/AccessibilityTestServer.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/AccessibilityTestServer.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/AccessibilityTestServer.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/AccessibilityTestServer.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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,1 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 <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+static void loadChangedCallback(WebKitWebView*, WebKitLoadEvent loadEvent, gpointer)
+{
+ // Send a message to the parent process when we're ready.
+ if (loadEvent == WEBKIT_LOAD_FINISHED)
+ g_print("OK");
+}
+
+int main(int argc, char** argv)
+{
+ // Make sure that the ATK bridge is loaded.
+ g_setenv("GTK_MODULES", "atk-bridge", TRUE);
+
+ gtk_init(&argc, &argv);
+
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ webkit_web_view_load_html(webView,
+ "<html>"
+ " <body>"
+ " <h1>This is a test</h1>"
+ " <p>This is a paragraph with some plain text.</p>"
+ " <p>This paragraph contains <a href=\"http://www.webkitgtk.org\">a link</a> in the middle.</p>"
+ " </body>"
+ "</html>",
+ 0);
+
+ GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView));
+ gtk_widget_show_all(window);
+
+ g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), 0);
+ g_signal_connect(webView, "load-changed", G_CALLBACK(loadChangedCallback), 0);
+
+ gtk_main();
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkAccessibilityTestServercpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/AccessibilityTestServer.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkCMakeListstxtfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsCMakeListstxt"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/CMakeLists.txt) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,108 @@
</span><ins>+set(TEST_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/WebKit2GtkAPITests)
+set(TEST_BINARY_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/TestWebKitAPI/WebKit2Gtk)
+set(TEST_RESOURCES_DIR ${TEST_BINARY_DIR}/resources)
+file(MAKE_DIRECTORY ${TEST_RESOURCES_DIR})
+
+add_definitions(
+ -DWEBKIT_TEST_PLUGIN_DIR="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
+ -DWEBKIT_EXEC_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
+ -DWEBKIT_SRC_DIR="${CMAKE_SOURCE_DIR}"
+ -DWEBKIT_TEST_WEB_EXTENSIONS_DIR="${TEST_LIBRARY_DIR}"
+ -DWEBKIT_INJECTED_BUNDLE_PATH="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
+)
+
+include_directories(
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/Source
+ ${CMAKE_SOURCE_DIR}/Source/WTF
+ ${DERIVED_SOURCES_DIR}
+ ${DERIVED_SOURCES_WEBKIT2GTK_DIR}
+ ${FORWARDING_HEADERS_DIR}
+ ${FORWARDING_HEADERS_WEBKIT2GTK_DIR}
+ ${FORWARDING_HEADERS_WEBKIT2GTK_EXTENSION_DIR}
+ ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk
+ ${ATSPI_INCLUDE_DIRS}
+ ${GLIB_INCLUDE_DIRS}
+ ${GTK3_INCLUDE_DIRS}
+ ${LIBSOUP_INCLUDE_DIRS}
+)
+
+add_library(WebKit2APITestCore STATIC
+ ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/LoadTrackingTest.cpp
+ ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.cpp
+ ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestServer.cpp
+ ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp
+ ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.cpp
+ ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp
+)
+target_link_libraries(WebKit2APITestCore WebKit2)
+
+add_custom_target(test-gresource-bundle
+ DEPENDS resources/webkit2gtk-tests.gresource.xml
+ resources/link-title.js
+ COMMAND glib-compile-resources
+ --target=${TEST_RESOURCES_DIR}/webkit2gtk-tests-resources.gresource
+ --sourcedir=${CMAKE_SOURCE_DIR}
+ ${CMAKE_CURRENT_LIST_DIR}/resources/webkit2gtk-tests.gresource.xml
+)
+
+macro(ADD_WK2_TEST_WEB_EXTENSION extension_name)
+ add_library(${extension_name} MODULE ${ARGN})
+ add_dependencies(${extension_name} WebKit2)
+ set_property(
+ TARGET ${extension_name}
+ APPEND
+ PROPERTY COMPILE_DEFINITIONS WEBKIT2_COMPILATION
+ )
+ set_target_properties(${extension_name} PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY ${TEST_LIBRARY_DIR}
+ )
+endmacro()
+
+macro(ADD_WK2_TEST test_name)
+ add_executable(${test_name} ${ARGN})
+ add_dependencies(${test_name}
+ test-gresource-bundle
+ WebExtensionTest
+ )
+ target_link_libraries(${test_name}
+ JavaScriptCore
+ WebKit2
+ WebKit2APITestCore
+ ${ATSPI_LIBRARIES}
+ ${GLIB_LIBRARIES}
+ ${GTK3_LIBRARIES}
+ ${LIBSOUP_LIBRARIES}
+ )
+ set_target_properties(${test_name} PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${TEST_BINARY_DIR}
+ )
+endmacro()
+
+ADD_WK2_TEST_WEB_EXTENSION(WebExtensionTest WebExtensionTest.cpp)
+ADD_WK2_TEST_WEB_EXTENSION(WebProcessTest DOMNodeTest.cpp FrameTest.cpp WebProcessTest.cpp)
+
+ADD_WK2_TEST(InspectorTestServer InspectorTestServer.cpp)
+ADD_WK2_TEST(TestBackForwardList TestBackForwardList.cpp)
+ADD_WK2_TEST(TestContextMenu TestContextMenu.cpp)
+ADD_WK2_TEST(TestCookieManager TestCookieManager.cpp)
+ADD_WK2_TEST(TestDOMNode TestDOMNode.cpp)
+ADD_WK2_TEST(TestDownloads TestDownloads.cpp)
+ADD_WK2_TEST(TestFrame TestFrame.cpp)
+ADD_WK2_TEST(TestInspector TestInspector.cpp)
+ADD_WK2_TEST(TestInspectorServer TestInspectorServer.cpp)
+ADD_WK2_TEST(TestLoaderClient TestLoaderClient.cpp)
+ADD_WK2_TEST(TestPrinting TestPrinting.cpp)
+ADD_WK2_TEST(TestSSL TestSSL.cpp)
+ADD_WK2_TEST(TestWebExtensions TestWebExtensions.cpp)
+ADD_WK2_TEST(TestWebKitPolicyClient TestWebKitPolicyClient.cpp)
+ADD_WK2_TEST(TestWebKitSettings TestWebKitSettings.cpp)
+ADD_WK2_TEST(TestWebKitVersion TestWebKitVersion.cpp)
+ADD_WK2_TEST(TestWebKitWebViewGroup TestWebKitWebViewGroup.cpp)
+ADD_WK2_TEST(TestWebKitWebContext TestWebKitWebContext.cpp)
+ADD_WK2_TEST(TestWebKitWebView TestWebKitWebView.cpp)
+
+if (ATSPI_FOUND)
+ ADD_WK2_TEST(AccessibilityTestServer AccessibilityTestServer.cpp)
+ ADD_WK2_TEST(TestWebKitAccessibility TestWebKitAccessibility.cpp)
+endif ()
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkCMakeListstxt"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkDOMDOMWindowTestcpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMDOMWindowTest.cpp (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMDOMWindowTest.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMDOMWindowTest.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,221 @@
</span><ins>+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * 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 "WebProcessTest.h"
+#include <gio/gio.h>
+#include <webkit2/webkit-web-extension.h>
+#include <wtf/RunLoop.h>
+
+class WebKitDOMDOMWindowTest;
+static gboolean loadedCallback(WebKitDOMDOMWindow*, WebKitDOMEvent*, WebKitDOMDOMWindowTest*);
+static gboolean clickedCallback(WebKitDOMDOMWindow*, WebKitDOMEvent*, WebKitDOMDOMWindowTest*);
+
+class WebKitDOMDOMWindowTest : public WebProcessTest {
+public:
+ static PassOwnPtr<WebProcessTest> create() { return adoptPtr(new WebKitDOMDOMWindowTest()); }
+
+private:
+ guint64 webPageFromArgs(GVariant* args)
+ {
+ GVariantIter iter;
+ g_variant_iter_init(&iter, args);
+
+ const char* key;
+ GVariant* value;
+ while (g_variant_iter_loop(&iter, "{&sv}", &key, &value)) {
+ if (!strcmp(key, "pageID") && g_variant_classify(value) == G_VARIANT_CLASS_UINT64)
+ return g_variant_get_uint64(value);
+ }
+
+ g_assert_not_reached();
+ return 0;
+ }
+
+ bool testSignals(WebKitWebExtension* extension, GVariant* args)
+ {
+ notify("ready", "");
+
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+
+ WebKitDOMDOMWindow* domWindow = webkit_dom_document_get_default_view(document);
+ g_assert(domWindow);
+
+ // The "load" WebKitDOMDOMWindow signal is issued before this test is
+ // called. There's no way to capture it here. We simply assume that
+ // the document is loaded and notify the uiprocess accordingly
+ // notify("loaded", "");
+
+ webkit_dom_event_target_add_event_listener(
+ WEBKIT_DOM_EVENT_TARGET(domWindow),
+ "load",
+ G_CALLBACK(loadedCallback),
+ false,
+ this);
+
+ // loadedCallback() will stop this loop
+ RunLoop::run();
+
+ document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+
+ WebKitDOMElement* element = webkit_dom_document_get_element_by_id(document, "test");
+ g_assert(element);
+
+ webkit_dom_event_target_add_event_listener(
+ WEBKIT_DOM_EVENT_TARGET(element),
+ "click",
+ G_CALLBACK(clickedCallback),
+ false,
+ this);
+
+ // The "click" action will be issued in the uiprocess and that will
+ // trigger the dom event here.
+ // clickedCallback() will stop this loop
+ RunLoop::run();
+
+ return true;
+ }
+
+ bool testDispatchEvent(WebKitWebExtension* extension, GVariant* args)
+ {
+ notify("ready", "");
+
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+
+ WebKitDOMDOMWindow* domWindow = webkit_dom_document_get_default_view(document);
+ g_assert(domWindow);
+
+ // The "load" WebKitDOMDOMWindow signal is issued before this test is
+ // called. There's no way to capture it here. We simply assume that
+ // the document is loaded and notify the uiprocess accordingly
+ // notify("loaded", "");
+
+ webkit_dom_event_target_add_event_listener(
+ WEBKIT_DOM_EVENT_TARGET(domWindow),
+ "load",
+ G_CALLBACK(loadedCallback),
+ false,
+ this);
+
+ // loadedCallback() will stop this loop
+ RunLoop::run();
+
+ document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+
+ WebKitDOMElement* element = webkit_dom_document_get_element_by_id(document, "test");
+ g_assert(element);
+
+ WebKitDOMEvent* event = webkit_dom_document_create_event(document, "MouseEvent", 0);
+ g_assert(event);
+ g_assert(WEBKIT_DOM_IS_EVENT(event));
+ g_assert(WEBKIT_DOM_IS_MOUSE_EVENT(event));
+
+ glong clientX, clientY;
+ clientX = webkit_dom_element_get_client_left(element);
+ clientY = webkit_dom_element_get_client_top(element);
+
+ webkit_dom_event_target_add_event_listener(
+ WEBKIT_DOM_EVENT_TARGET(element),
+ "click",
+ G_CALLBACK(clickedCallback),
+ false,
+ this);
+
+ webkit_dom_mouse_event_init_mouse_event(WEBKIT_DOM_MOUSE_EVENT(event),
+ "click", TRUE, TRUE,
+ domWindow, 0, 0, 0, clientX, clientY,
+ FALSE, FALSE, FALSE, FALSE,
+ 1, WEBKIT_DOM_EVENT_TARGET(element));
+
+ webkit_dom_event_target_dispatch_event(WEBKIT_DOM_EVENT_TARGET(element), event, 0);
+
+ // clickedCallback() will stop this loop
+ RunLoop::run();
+
+ return true;
+ }
+
+ bool testGetComputedStyle(WebKitWebExtension* extension, GVariant* args)
+ {
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+ WebKitDOMDOMWindow* domWindow = webkit_dom_document_get_default_view(document);
+ g_assert(domWindow);
+ WebKitDOMElement* element = webkit_dom_document_get_element_by_id(document, "test");
+ g_assert(element);
+ g_assert(WEBKIT_DOM_IS_ELEMENT(element));
+ WebKitDOMCSSStyleDeclaration* cssStyle = webkit_dom_dom_window_get_computed_style(domWindow, element, 0);
+ gchar* fontSize = webkit_dom_css_style_declaration_get_property_value(cssStyle, "font-size");
+ g_assert_cmpstr(fontSize, ==, "16px");
+
+ return true;
+ }
+
+ virtual bool runTest(const char* testName, WebKitWebExtension* extension, GVariant* args)
+ {
+ if (!strcmp(testName, "signals"))
+ return testSignals(extension, args);
+ if (!strcmp(testName, "dispatch-event"))
+ return testDispatchEvent(extension, args);
+ if (!strcmp(testName, "get-computed-style"))
+ return testGetComputedStyle(extension, args);
+
+ g_assert_not_reached();
+ return false;
+ }
+};
+
+static void __attribute__((constructor)) registerTests()
+{
+ REGISTER_TEST(WebKitDOMDOMWindowTest, "WebKitDOMDOMWindow/signals");
+ REGISTER_TEST(WebKitDOMDOMWindowTest, "WebKitDOMDOMWindow/dispatch-event");
+ REGISTER_TEST(WebKitDOMDOMWindowTest, "WebKitDOMDOMWindow/get-computed-style");
+}
+
+static gboolean loadedCallback(WebKitDOMDOMWindow* view, WebKitDOMEvent* event, WebKitDOMDOMWindowTest* test)
+{
+ test->notify("loaded", "");
+
+ // Stop the loop and let testSignals() or testDispatchEvent() continue its course
+ RunLoop::current()->stop();
+
+ return FALSE;
+}
+
+static gboolean clickedCallback(WebKitDOMDOMWindow* view, WebKitDOMEvent* event, WebKitDOMDOMWindowTest* test)
+{
+ test->notify("clicked", "");
+ test->notify("finish", "");
+
+ // Stop the loop and let testSignals() or testDispatchEvent() continue its course
+ RunLoop::current()->stop();
+
+ return FALSE;
+}
</ins><span class="cx">Property changes on: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMDOMWindowTest.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkDOMNodeTestcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsDOMNodeTestcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/DOMNodeTest.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,216 @@
</span><ins>+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * 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 "WebProcessTest.h"
+#include <gio/gio.h>
+#include <webkit2/webkit-web-extension.h>
+#include <wtf/gobject/GOwnPtr.h>
+
+class WebKitDOMNodeTest : public WebProcessTest {
+public:
+ static PassOwnPtr<WebProcessTest> create() { return adoptPtr(new WebKitDOMNodeTest()); }
+
+private:
+ guint64 webPageFromArgs(GVariant* args)
+ {
+ GVariantIter iter;
+ g_variant_iter_init(&iter, args);
+
+ const char* key;
+ GVariant* value;
+ while (g_variant_iter_loop(&iter, "{&sv}", &key, &value)) {
+ if (!strcmp(key, "pageID") && g_variant_classify(value) == G_VARIANT_CLASS_UINT64)
+ return g_variant_get_uint64(value);
+ }
+
+ g_assert_not_reached();
+ return 0;
+ }
+
+ bool testHierarchyNavigation(WebKitWebExtension* extension, GVariant* args)
+ {
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+
+ WebKitDOMHTMLHeadElement* head = webkit_dom_document_get_head(document);
+ g_assert(WEBKIT_DOM_IS_HTML_HEAD_ELEMENT(head));
+
+ // Title, head's child.
+ g_assert(webkit_dom_node_has_child_nodes(WEBKIT_DOM_NODE(head)));
+ GRefPtr<WebKitDOMNodeList> list = adoptGRef(webkit_dom_node_get_child_nodes(WEBKIT_DOM_NODE(head)));
+ g_assert(WEBKIT_DOM_IS_NODE_LIST(list.get()));
+ g_assert_cmpint(webkit_dom_node_list_get_length(list.get()), ==, 1);
+ WebKitDOMNode* node = webkit_dom_node_list_item(list.get(), 0);
+ g_assert(WEBKIT_DOM_IS_HTML_TITLE_ELEMENT(node));
+
+ // Body, Head sibling.
+ node = webkit_dom_node_get_next_sibling(WEBKIT_DOM_NODE(head));
+ g_assert(WEBKIT_DOM_IS_HTML_BODY_ELEMENT(node));
+ WebKitDOMHTMLBodyElement* body = WEBKIT_DOM_HTML_BODY_ELEMENT(node);
+
+ // There is no third sibling
+ g_assert(!webkit_dom_node_get_next_sibling(node));
+
+ // Body's previous sibling is Head.
+ node = webkit_dom_node_get_previous_sibling(WEBKIT_DOM_NODE(body));
+ g_assert(WEBKIT_DOM_IS_HTML_HEAD_ELEMENT(node));
+
+ // Body has 3 children.
+ g_assert(webkit_dom_node_has_child_nodes(WEBKIT_DOM_NODE(body)));
+ list = adoptGRef(webkit_dom_node_get_child_nodes(WEBKIT_DOM_NODE(body)));
+ unsigned long length = webkit_dom_node_list_get_length(list.get());
+ g_assert_cmpint(length, ==, 3);
+
+ // The three of them are P tags.
+ for (unsigned long i = 0; i < length; i++) {
+ node = webkit_dom_node_list_item(list.get(), i);
+ g_assert(WEBKIT_DOM_IS_HTML_PARAGRAPH_ELEMENT(node));
+ }
+
+ // Go backwards
+ unsigned i;
+ for (i = 0; node; node = webkit_dom_node_get_previous_sibling(node), i++) { }
+ g_assert_cmpint(i, ==, 3);
+
+ return true;
+ }
+
+ bool testInsertion(WebKitWebExtension* extension, GVariant* args)
+ {
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+
+ WebKitDOMHTMLElement* body = webkit_dom_document_get_body(document);
+ g_assert(WEBKIT_DOM_IS_HTML_ELEMENT(body));
+
+ // Body shouldn't have any children at this point.
+ g_assert(!webkit_dom_node_has_child_nodes(WEBKIT_DOM_NODE(body)));
+
+ // Insert one P element.
+ WebKitDOMElement* p = webkit_dom_document_create_element(document, "P", 0);
+ g_assert(WEBKIT_DOM_IS_HTML_ELEMENT(p));
+ webkit_dom_node_append_child(WEBKIT_DOM_NODE(body), WEBKIT_DOM_NODE(p), 0);
+
+ // Now it should have one, the same that we inserted.
+ g_assert(webkit_dom_node_has_child_nodes(WEBKIT_DOM_NODE(body)));
+ GRefPtr<WebKitDOMNodeList> list = adoptGRef(webkit_dom_node_get_child_nodes(WEBKIT_DOM_NODE(body)));
+ g_assert(WEBKIT_DOM_IS_NODE_LIST(list.get()));
+ g_assert_cmpint(webkit_dom_node_list_get_length(list.get()), ==, 1);
+ WebKitDOMNode* node = webkit_dom_node_list_item(list.get(), 0);
+ g_assert(WEBKIT_DOM_IS_HTML_ELEMENT(node));
+ g_assert(webkit_dom_node_is_same_node(WEBKIT_DOM_NODE(p), node));
+
+ // Replace the P tag with a DIV tag.
+ WebKitDOMElement* div = webkit_dom_document_create_element(document, "DIV", 0);
+ g_assert(WEBKIT_DOM_IS_HTML_ELEMENT(div));
+ webkit_dom_node_replace_child(WEBKIT_DOM_NODE(body), WEBKIT_DOM_NODE(div), WEBKIT_DOM_NODE(p), 0);
+ g_assert(webkit_dom_node_has_child_nodes(WEBKIT_DOM_NODE(body)));
+ list = adoptGRef(webkit_dom_node_get_child_nodes(WEBKIT_DOM_NODE(body)));
+ g_assert(WEBKIT_DOM_IS_NODE_LIST(list.get()));
+ g_assert_cmpint(webkit_dom_node_list_get_length(list.get()), ==, 1);
+ node = webkit_dom_node_list_item(list.get(), 0);
+ g_assert(WEBKIT_DOM_IS_HTML_ELEMENT(node));
+ g_assert(webkit_dom_node_is_same_node(WEBKIT_DOM_NODE(div), node));
+
+ // Now remove the tag.
+ webkit_dom_node_remove_child(WEBKIT_DOM_NODE(body), node, 0);
+ list = adoptGRef(webkit_dom_node_get_child_nodes(WEBKIT_DOM_NODE(body)));
+ g_assert(WEBKIT_DOM_IS_NODE_LIST(list.get()));
+ g_assert_cmpint(webkit_dom_node_list_get_length(list.get()), ==, 0);
+
+ // Test insert before. If refChild is null, insert newChild as last element of parent.
+ div = webkit_dom_document_create_element(document, "DIV", 0);
+ g_assert(WEBKIT_DOM_IS_HTML_ELEMENT(div));
+ webkit_dom_node_insert_before(WEBKIT_DOM_NODE(body), WEBKIT_DOM_NODE(div), 0, 0);
+ g_assert(webkit_dom_node_has_child_nodes(WEBKIT_DOM_NODE(body)));
+ list = adoptGRef(webkit_dom_node_get_child_nodes(WEBKIT_DOM_NODE(body)));
+ g_assert(WEBKIT_DOM_IS_NODE_LIST(list.get()));
+ g_assert_cmpint(webkit_dom_node_list_get_length(list.get()), ==, 1);
+ node = webkit_dom_node_list_item(list.get(), 0);
+ g_assert(WEBKIT_DOM_IS_HTML_ELEMENT(node));
+ g_assert(webkit_dom_node_is_same_node(WEBKIT_DOM_NODE(div), node));
+
+ // Now insert a 'p' before 'div'.
+ p = webkit_dom_document_create_element(document, "P", 0);
+ g_assert(WEBKIT_DOM_IS_HTML_ELEMENT(p));
+ webkit_dom_node_insert_before(WEBKIT_DOM_NODE(body), WEBKIT_DOM_NODE(p), WEBKIT_DOM_NODE(div), 0);
+ g_assert(webkit_dom_node_has_child_nodes(WEBKIT_DOM_NODE(body)));
+ list = adoptGRef(webkit_dom_node_get_child_nodes(WEBKIT_DOM_NODE(body)));
+ g_assert(WEBKIT_DOM_IS_NODE_LIST(list.get()));
+ g_assert_cmpint(webkit_dom_node_list_get_length(list.get()), ==, 2);
+ node = webkit_dom_node_list_item(list.get(), 0);
+ g_assert(WEBKIT_DOM_IS_HTML_ELEMENT(node));
+ g_assert(webkit_dom_node_is_same_node(WEBKIT_DOM_NODE(p), node));
+ node = webkit_dom_node_list_item(list.get(), 1);
+ g_assert(WEBKIT_DOM_IS_HTML_ELEMENT(node));
+ g_assert(webkit_dom_node_is_same_node(WEBKIT_DOM_NODE(div), node));
+
+ return true;
+ }
+
+ bool testTagNames(WebKitWebExtension* extension, GVariant* args)
+ {
+ static const char* expectedTagNames[] = { "HTML", "HEAD", "BODY", "VIDEO", "SOURCE", "VIDEO", "SOURCE", "INPUT" };
+
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+
+ WebKitDOMNodeList* list = webkit_dom_document_get_elements_by_tag_name(document, "*");
+ gulong nodeCount = webkit_dom_node_list_get_length(list);
+ g_assert_cmpuint(nodeCount, ==, G_N_ELEMENTS(expectedTagNames));
+ for (unsigned i = 0; i < nodeCount; i++) {
+ WebKitDOMNode* node = webkit_dom_node_list_item(list, i);
+ g_assert(WEBKIT_DOM_IS_NODE(node));
+ GOwnPtr<char> tagName(webkit_dom_node_get_node_name(node));
+ g_assert_cmpstr(tagName.get(), ==, expectedTagNames[i]);
+ }
+
+ return true;
+ }
+
+ virtual bool runTest(const char* testName, WebKitWebExtension* extension, GVariant* args)
+ {
+ if (!strcmp(testName, "hierarchy-navigation"))
+ return testHierarchyNavigation(extension, args);
+ if (!strcmp(testName, "insertion"))
+ return testInsertion(extension, args);
+ if (!strcmp(testName, "tag-names"))
+ return testTagNames(extension, args);
+
+ g_assert_not_reached();
+ return false;
+ }
+};
+
+static void __attribute__((constructor)) registerTests()
+{
+ REGISTER_TEST(WebKitDOMNodeTest, "WebKitDOMNode/hierarchy-navigation");
+ REGISTER_TEST(WebKitDOMNodeTest, "WebKitDOMNode/insertion");
+ REGISTER_TEST(WebKitDOMNodeTest, "WebKitDOMNode/tag-names");
+}
+
+
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkDOMNodeTestcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkFrameTestcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsFrameTestcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/FrameTest.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,102 @@
</span><ins>+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * 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 "WebProcessTest.h"
+#include <gio/gio.h>
+#include <webkit2/webkit-web-extension.h>
+
+class WebKitFrameTest : public WebProcessTest {
+public:
+ static PassOwnPtr<WebProcessTest> create() { return adoptPtr(new WebKitFrameTest()); }
+
+private:
+ guint64 webPageFromArgs(GVariant* args)
+ {
+ GVariantIter iter;
+ g_variant_iter_init(&iter, args);
+
+ const char* key;
+ GVariant* value;
+ while (g_variant_iter_loop(&iter, "{&sv}", &key, &value)) {
+ if (!strcmp(key, "pageID") && g_variant_classify(value) == G_VARIANT_CLASS_UINT64)
+ return g_variant_get_uint64(value);
+ }
+
+ g_assert_not_reached();
+ return 0;
+ }
+
+ bool testMainFrame(WebKitWebExtension* extension, GVariant* args)
+ {
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+
+ WebKitFrame* frame = webkit_web_page_get_main_frame(page);
+ g_assert(WEBKIT_IS_FRAME(frame));
+ g_assert(webkit_frame_is_main_frame(frame));
+
+ return true;
+ }
+
+ bool testURI(WebKitWebExtension* extension, GVariant* args)
+ {
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+
+ WebKitFrame* frame = webkit_web_page_get_main_frame(page);
+ g_assert(WEBKIT_IS_FRAME(frame));
+ g_assert_cmpstr(webkit_web_page_get_uri(page), ==, webkit_frame_get_uri(frame));
+
+ return true;
+ }
+
+ bool testJavaScriptContext(WebKitWebExtension* extension, GVariant* args)
+ {
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+
+ WebKitFrame* frame = webkit_web_page_get_main_frame(page);
+ g_assert(WEBKIT_IS_FRAME(frame));
+ g_assert(webkit_frame_get_javascript_global_context(frame));
+
+ return true;
+ }
+
+ virtual bool runTest(const char* testName, WebKitWebExtension* extension, GVariant* args)
+ {
+ if (!strcmp(testName, "main-frame"))
+ return testMainFrame(extension, args);
+ if (!strcmp(testName, "uri"))
+ return testURI(extension, args);
+ if (!strcmp(testName, "javascript-context"))
+ return testJavaScriptContext(extension, args);
+
+ g_assert_not_reached();
+ return false;
+ }
+};
+
+static void __attribute__((constructor)) registerTests()
+{
+ REGISTER_TEST(WebKitFrameTest, "WebKitFrame/main-frame");
+ REGISTER_TEST(WebKitFrameTest, "WebKitFrame/uri");
+ REGISTER_TEST(WebKitFrameTest, "WebKitFrame/javascript-context");
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkFrameTestcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkInspectorTestServercppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsInspectorTestServercpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/InspectorTestServer.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/InspectorTestServer.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/InspectorTestServer.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/InspectorTestServer.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+/*
+ * Copyright (C) 2012 Samsung Electronics Ltd. All Rights Reserved.
+ *
+ * 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+static void loadChangedCallback(WebKitWebView*, WebKitLoadEvent loadEvent, gpointer)
+{
+ // Send a message to the parent process when we're ready.
+ if (loadEvent == WEBKIT_LOAD_FINISHED)
+ g_print("OK");
+}
+
+int main(int argc, char** argv)
+{
+ gtk_init(&argc, &argv);
+
+ // Overwrite WEBKIT_INSPECTOR_SERVER variable with default value.
+ g_setenv("WEBKIT_INSPECTOR_SERVER", "127.0.0.1:2999", TRUE);
+
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ webkit_settings_set_enable_developer_extras(webkit_web_view_get_settings(webView), TRUE);
+ webkit_web_view_load_html(webView,
+ "<html><body><p>WebKitGTK+ Inspector Test Server</p></body></html>",
+ "http://127.0.0.1:2999/");
+
+ GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView));
+ gtk_widget_show_all(window);
+
+ g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), 0);
+ g_signal_connect(webView, "load-changed", G_CALLBACK(loadChangedCallback), 0);
+
+ gtk_main();
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkInspectorTestServercpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/InspectorTestServer.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestAuthenticationcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestAuthenticationcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestAuthentication.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,286 @@
</span><ins>+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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,1 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 "LoadTrackingTest.h"
+#include "WebKitTestServer.h"
+#include <wtf/gobject/GRefPtr.h>
+
+static WebKitTestServer* kServer;
+
+class AuthenticationTest: public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(AuthenticationTest);
+
+ AuthenticationTest()
+ {
+ g_signal_connect(m_webView, "authenticate", G_CALLBACK(runAuthenticationCallback), this);
+ }
+
+ ~AuthenticationTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ static int authenticationRetries;
+ static bool authenticationCancelledReceived;
+
+ void loadURI(const char* uri)
+ {
+ // Reset the retry count of the fake server when a page is loaded.
+ authenticationRetries = 0;
+ authenticationCancelledReceived = false;
+ LoadTrackingTest::loadURI(uri);
+ }
+
+ static gboolean runAuthenticationCallback(WebKitWebView*, WebKitAuthenticationRequest* request, AuthenticationTest* test)
+ {
+ g_signal_connect(request, "cancelled", G_CALLBACK(authenticationCancelledCallback), test);
+ test->runAuthentication(request);
+ return TRUE;
+ }
+
+ static void authenticationCancelledCallback(WebKitAuthenticationRequest*, AuthenticationTest*)
+ {
+ authenticationCancelledReceived = true;
+ }
+
+ void runAuthentication(WebKitAuthenticationRequest* request)
+ {
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+ m_authenticationRequest = request;
+ g_main_loop_quit(m_mainLoop);
+ }
+
+ WebKitAuthenticationRequest* waitForAuthenticationRequest()
+ {
+ g_main_loop_run(m_mainLoop);
+ return m_authenticationRequest.get();
+ }
+
+private:
+ GRefPtr<WebKitAuthenticationRequest> m_authenticationRequest;
+};
+
+int AuthenticationTest::authenticationRetries = 0;
+bool AuthenticationTest::authenticationCancelledReceived = false;
+
+static const char authTestUsername[] = "username";
+static const char authTestPassword[] = "password";
+static const char authExpectedSuccessTitle[] = "WebKit2Gtk+ Authentication test";
+static const char authExpectedFailureTitle[] = "401 Authorization Required";
+static const char authExpectedAuthorization[] = "Basic dXNlcm5hbWU6cGFzc3dvcmQ="; // Base64 encoding of "username:password".
+static const char authSuccessHTMLString[] =
+ "<html>"
+ "<head><title>WebKit2Gtk+ Authentication test</title></head>"
+ "<body></body></html>";
+static const char authFailureHTMLString[] =
+ "<html>"
+ "<head><title>401 Authorization Required</title></head>"
+ "<body></body></html>";
+
+static void testWebViewAuthenticationRequest(AuthenticationTest* test, gconstpointer)
+{
+ // Test authentication request getters match soup authentication header.
+ test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+ WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+ g_assert_cmpstr(webkit_authentication_request_get_host(request), ==, soup_uri_get_host(kServer->baseURI()));
+ g_assert_cmpuint(webkit_authentication_request_get_port(request), ==, soup_uri_get_port(kServer->baseURI()));
+ g_assert_cmpstr(webkit_authentication_request_get_realm(request), ==, "my realm");
+ g_assert(webkit_authentication_request_get_scheme(request) == WEBKIT_AUTHENTICATION_SCHEME_HTTP_BASIC);
+ g_assert(!webkit_authentication_request_is_for_proxy(request));
+ g_assert(!webkit_authentication_request_is_retry(request));
+}
+
+static void testWebViewAuthenticationCancel(AuthenticationTest* test, gconstpointer)
+{
+ // Test cancel.
+ test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+ WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+ webkit_authentication_request_cancel(request);
+ // Server doesn't ask for new credentials.
+ test->waitUntilLoadFinished();
+
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+ g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::ProvisionalLoadFailed);
+ g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+
+ g_assert_error(test->m_error.get(), WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED);
+}
+
+static void testWebViewAuthenticationLoadCancelled(AuthenticationTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+ test->waitForAuthenticationRequest();
+ webkit_web_view_stop_loading(test->m_webView);
+ // Expect empty page.
+ test->waitUntilLoadFinished();
+ g_assert(test->authenticationCancelledReceived);
+
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+ g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::ProvisionalLoadFailed);
+ g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+
+ g_assert_error(test->m_error.get(), WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED);
+}
+
+static void testWebViewAuthenticationFailure(AuthenticationTest* test, gconstpointer)
+{
+ // Test authentication failures.
+ test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+ WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+ g_assert(!webkit_authentication_request_is_retry(request));
+ WebKitCredential* credential = webkit_credential_new(authTestUsername, "wrongpassword", WEBKIT_CREDENTIAL_PERSISTENCE_NONE);
+ webkit_authentication_request_authenticate(request, credential);
+ webkit_credential_free(credential);
+ // Expect a second authentication request.
+ request = test->waitForAuthenticationRequest();
+ g_assert(webkit_authentication_request_is_retry(request));
+ // Test second failure.
+ credential = webkit_credential_new(authTestUsername, "wrongpassword2", WEBKIT_CREDENTIAL_PERSISTENCE_NONE);
+ webkit_authentication_request_authenticate(request, credential);
+ webkit_credential_free(credential);
+ // Expect authentication failed page.
+ test->waitUntilLoadFinished();
+
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+ g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+ g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedFailureTitle);
+}
+
+static void testWebViewAuthenticationNoCredential(AuthenticationTest* test, gconstpointer)
+{
+ // Test continue without credentials.
+ test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+ WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+ webkit_authentication_request_authenticate(request, 0);
+ // Server doesn't ask for new credentials.
+ test->waitUntilLoadFinished();
+
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+ g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+ g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedFailureTitle);
+}
+
+static void testWebViewAuthenticationStorage(AuthenticationTest* test, gconstpointer)
+{
+ // Enable private browsing before authentication request to test that credentials can't be saved.
+ webkit_settings_set_enable_private_browsing(webkit_web_view_get_settings(test->m_webView), TRUE);
+ test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+ WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+ g_assert(!webkit_authentication_request_get_proposed_credential(request));
+ g_assert(!webkit_authentication_request_can_save_credentials(request));
+
+ // If WebKit has been compiled with libsecret, and private browsing is disabled
+ // then check that credentials can be saved.
+#if ENABLE(CREDENTIAL_STORAGE)
+ webkit_settings_set_enable_private_browsing(webkit_web_view_get_settings(test->m_webView), FALSE);
+ test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+ request = test->waitForAuthenticationRequest();
+ g_assert(!webkit_authentication_request_get_proposed_credential(request));
+ g_assert(webkit_authentication_request_can_save_credentials(request));
+#endif
+}
+
+static void testWebViewAuthenticationSuccess(AuthenticationTest* test, gconstpointer)
+{
+ // Test correct authentication.
+ test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+ WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+ WebKitCredential* credential = webkit_credential_new(authTestUsername, authTestPassword, WEBKIT_CREDENTIAL_PERSISTENCE_FOR_SESSION);
+ webkit_authentication_request_authenticate(request, credential);
+ webkit_credential_free(credential);
+ test->waitUntilLoadFinished();
+
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+ g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+ g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedSuccessTitle);
+
+ // Test loading the same (authorized) page again.
+ test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+ // There is no authentication challenge.
+ test->waitUntilLoadFinished();
+
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+ g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+ g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedSuccessTitle);
+}
+
+static void serverCallback(SoupServer*, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, void*)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ if (!strcmp(path, "/auth-test.html")) {
+ const char* authorization = soup_message_headers_get_one(message->request_headers, "Authorization");
+ // Require authentication.
+ if (!g_strcmp0(authorization, authExpectedAuthorization)) {
+ // Successful authentication.
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, authSuccessHTMLString, strlen(authSuccessHTMLString));
+ AuthenticationTest::authenticationRetries = 0;
+ } else if (++AuthenticationTest::authenticationRetries < 3) {
+ // No or invalid authorization header provided by the client, request authentication twice then fail.
+ soup_message_set_status(message, SOUP_STATUS_UNAUTHORIZED);
+ soup_message_headers_append(message->response_headers, "WWW-Authenticate", "Basic realm=\"my realm\"");
+ // Include a failure message in case the user attempts to proceed without authentication.
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, authFailureHTMLString, strlen(authFailureHTMLString));
+ } else {
+ // Authentication not successful, display a "401 Authorization Required" page.
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, authFailureHTMLString, strlen(authFailureHTMLString));
+ }
+ } else
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+
+ soup_message_body_complete(message->response_body);
+}
+
+void beforeAll()
+{
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ AuthenticationTest::add("WebKitWebView", "authentication-request", testWebViewAuthenticationRequest);
+ AuthenticationTest::add("WebKitWebView", "authentication-cancel", testWebViewAuthenticationCancel);
+ AuthenticationTest::add("WebKitWebView", "authentication-load-cancelled", testWebViewAuthenticationLoadCancelled);
+ AuthenticationTest::add("WebKitWebView", "authentication-failure", testWebViewAuthenticationFailure);
+ AuthenticationTest::add("WebKitWebView", "authentication-no-credential", testWebViewAuthenticationNoCredential);
+ AuthenticationTest::add("WebKitWebView", "authentication-storage", testWebViewAuthenticationStorage);
+ // Testing authentication success must be done last because libsoup will never fire
+ // the authenticate signal again once authentication is successful.
+ AuthenticationTest::add("WebKitWebView", "authentication-success", testWebViewAuthenticationSuccess);
+}
+
+void afterAll()
+{
+ delete kServer;
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestAuthenticationcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestBackForwardListcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestBackForwardListcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,280 @@
</span><ins>+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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 "WebKitTestServer.h"
+#include "WebViewTest.h"
+#include <gtk/gtk.h>
+#include <libsoup/soup.h>
+#include <string.h>
+#include <webkit2/webkit2.h>
+
+// Back forward list limit is 100 by default.
+static const int kBackForwardListLimit = 100;
+
+static WebKitTestServer* kServer;
+
+static void serverCallback(SoupServer* server, SoupMessage* msg, const char* path, GHashTable* query, SoupClientContext* context, gpointer data)
+{
+ if (msg->method != SOUP_METHOD_GET) {
+ soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ if (g_str_has_suffix(path, "favicon.ico")) {
+ soup_message_set_status(msg, SOUP_STATUS_NOT_FOUND);
+ return;
+ }
+
+ soup_message_set_status(msg, SOUP_STATUS_OK);
+
+ char* body = g_strdup_printf("<html><title>%s</title><body>%s</body></html>", path + 1, path + 1);
+ soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, body, strlen(body));
+
+ soup_message_body_complete(msg->response_body);
+}
+
+class BackForwardListTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(BackForwardListTest);
+
+ enum {
+ Backward,
+ Forward
+ };
+
+ enum {
+ CurrentItem = 1 << 0,
+ AddedItem = 1 << 1,
+ RemovedItems = 1 << 2
+ };
+
+ static void checkItem(WebKitBackForwardListItem* item, const char* title, const char* uri, const char* originalURI)
+ {
+ g_assert(item);
+ g_assert_cmpstr(webkit_back_forward_list_item_get_uri(item), ==, uri);
+ g_assert_cmpstr(webkit_back_forward_list_item_get_title(item), == , title);
+ g_assert_cmpstr(webkit_back_forward_list_item_get_original_uri(item), ==, originalURI);
+ }
+
+ static void checkItemIndex(WebKitBackForwardList* list)
+ {
+ g_assert(webkit_back_forward_list_get_nth_item(list, -1) == webkit_back_forward_list_get_back_item(list));
+ g_assert(webkit_back_forward_list_get_nth_item(list, 0) == webkit_back_forward_list_get_current_item(list));
+ g_assert(webkit_back_forward_list_get_nth_item(list, 1) == webkit_back_forward_list_get_forward_item(list));
+ }
+
+ static void checkList(WebKitBackForwardList* list, unsigned type, WebKitBackForwardListItem** items, unsigned nItems)
+ {
+ GList* listItems = type == BackForwardListTest::Backward ? webkit_back_forward_list_get_back_list(list) :
+ webkit_back_forward_list_get_forward_list(list);
+ g_assert(listItems);
+
+ unsigned i = 0;
+ for (GList* listItem = listItems; listItem; listItem = g_list_next(listItem), i++) {
+ g_assert_cmpuint(i, <, nItems);
+ g_assert(listItem->data == items[i]);
+ }
+ g_list_free(listItems);
+ }
+
+ static void backForwardListChanged(WebKitBackForwardList* list, WebKitBackForwardListItem* addedItem, GList* removedItems, BackForwardListTest* test)
+ {
+ test->m_hasChanged = true;
+
+ if (test->m_changedFlags & BackForwardListTest::AddedItem) {
+ g_assert(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(addedItem));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(addedItem));
+ } else
+ g_assert(!addedItem);
+
+ if (test->m_changedFlags & BackForwardListTest::RemovedItems) {
+ g_assert(removedItems);
+ for (GList* iter = removedItems; iter; iter = iter->next) {
+ g_assert(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(iter->data));
+ if (test->m_expectedRemovedItems)
+ g_assert(g_list_find(test->m_expectedRemovedItems, iter->data));
+ }
+
+ } else
+ g_assert(!removedItems);
+ }
+
+ BackForwardListTest()
+ : m_list(webkit_web_view_get_back_forward_list(m_webView))
+ , m_changedFlags(0)
+ , m_hasChanged(false)
+ , m_expectedRemovedItems(0)
+ {
+ g_signal_connect(m_list, "changed", G_CALLBACK(backForwardListChanged), this);
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_list));
+ }
+
+ ~BackForwardListTest()
+ {
+ g_signal_handlers_disconnect_matched(m_list, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void waitUntilLoadFinished()
+ {
+ m_hasChanged = false;
+ WebViewTest::waitUntilLoadFinished();
+ g_assert(m_hasChanged);
+ }
+
+ void waitUntilLoadFinishedAndCheckRemovedItems(GList* removedItems)
+ {
+ m_expectedRemovedItems = removedItems;
+ waitUntilLoadFinished();
+ m_expectedRemovedItems = 0;
+ }
+
+ WebKitBackForwardList* m_list;
+ unsigned long m_changedFlags;
+ bool m_hasChanged;
+ GList* m_expectedRemovedItems;
+};
+
+static void testBackForwardListNavigation(BackForwardListTest* test, gconstpointer)
+{
+ WebKitBackForwardListItem* items[1];
+
+ g_assert(!webkit_web_view_can_go_back(test->m_webView));
+ g_assert(!webkit_web_view_can_go_forward(test->m_webView));
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 0);
+ g_assert(!webkit_back_forward_list_get_current_item(test->m_list));
+ g_assert(!webkit_back_forward_list_get_back_item(test->m_list));
+ g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
+ BackForwardListTest::checkItemIndex(test->m_list);
+ g_assert(!webkit_back_forward_list_get_back_list(test->m_list));
+ g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
+
+ CString uriPage1 = kServer->getURIForPath("/Page1");
+ test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
+ test->loadURI(uriPage1.data());
+ test->waitUntilLoadFinished();
+
+ g_assert(!webkit_web_view_can_go_back(test->m_webView));
+ g_assert(!webkit_web_view_can_go_forward(test->m_webView));
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 1);
+ WebKitBackForwardListItem* itemPage1 = webkit_back_forward_list_get_current_item(test->m_list);
+ BackForwardListTest::checkItem(itemPage1, "Page1", uriPage1.data(), uriPage1.data());
+ g_assert(!webkit_back_forward_list_get_back_item(test->m_list));
+ g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
+ BackForwardListTest::checkItemIndex(test->m_list);
+ g_assert(!webkit_back_forward_list_get_back_list(test->m_list));
+ g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
+
+ CString uriPage2 = kServer->getURIForPath("/Page2");
+ test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
+ test->loadURI(uriPage2.data());
+ test->waitUntilLoadFinished();
+
+ g_assert(webkit_web_view_can_go_back(test->m_webView));
+ g_assert(!webkit_web_view_can_go_forward(test->m_webView));
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2);
+ WebKitBackForwardListItem* itemPage2 = webkit_back_forward_list_get_current_item(test->m_list);
+ BackForwardListTest::checkItem(itemPage2, "Page2", uriPage2.data(), uriPage2.data());
+ g_assert(webkit_back_forward_list_get_back_item(test->m_list) == itemPage1);
+ g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
+ BackForwardListTest::checkItemIndex(test->m_list);
+ items[0] = itemPage1;
+ BackForwardListTest::checkList(test->m_list, BackForwardListTest::Backward, items, 1);
+ g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
+
+ test->m_changedFlags = BackForwardListTest::CurrentItem;
+ test->goBack();
+ test->waitUntilLoadFinished();
+
+ g_assert(!webkit_web_view_can_go_back(test->m_webView));
+ g_assert(webkit_web_view_can_go_forward(test->m_webView));
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2);
+ g_assert(itemPage1 == webkit_back_forward_list_get_current_item(test->m_list));
+ BackForwardListTest::checkItem(webkit_back_forward_list_get_current_item(test->m_list), "Page1", uriPage1.data(), uriPage1.data());
+ g_assert(!webkit_back_forward_list_get_back_item(test->m_list));
+ g_assert(webkit_back_forward_list_get_forward_item(test->m_list) == itemPage2);
+ BackForwardListTest::checkItemIndex(test->m_list);
+ g_assert(!webkit_back_forward_list_get_back_list(test->m_list));
+ items[0] = itemPage2;
+ BackForwardListTest::checkList(test->m_list, BackForwardListTest::Forward, items, 1);
+
+ test->m_changedFlags = BackForwardListTest::CurrentItem;
+ test->goForward();
+ test->waitUntilLoadFinished();
+
+ g_assert(webkit_web_view_can_go_back(test->m_webView));
+ g_assert(!webkit_web_view_can_go_forward(test->m_webView));
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2);
+ g_assert(itemPage2 == webkit_back_forward_list_get_current_item(test->m_list));
+ BackForwardListTest::checkItem(webkit_back_forward_list_get_current_item(test->m_list), "Page2", uriPage2.data(), uriPage2.data());
+ g_assert(webkit_back_forward_list_get_back_item(test->m_list) == itemPage1);
+ g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
+ BackForwardListTest::checkItemIndex(test->m_list);
+ items[0] = itemPage1;
+ BackForwardListTest::checkList(test->m_list, BackForwardListTest::Backward, items, 1);
+ g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
+
+ test->m_changedFlags = BackForwardListTest::CurrentItem;
+ test->goToBackForwardListItem(itemPage1);
+ test->waitUntilLoadFinished();
+
+ g_assert(itemPage1 == webkit_back_forward_list_get_current_item(test->m_list));
+}
+
+static void testBackForwardListLimitAndCache(BackForwardListTest* test, gconstpointer)
+{
+ for (int i = 0; i < kBackForwardListLimit; i++) {
+ GOwnPtr<char> path(g_strdup_printf("/Page%d", i));
+ test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
+ test->loadURI(kServer->getURIForPath(path.get()).data());
+ test->waitUntilLoadFinished();
+ }
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, kBackForwardListLimit);
+ WebKitBackForwardListItem* itemPageFirst = webkit_back_forward_list_get_nth_item(test->m_list, -(kBackForwardListLimit - 1));
+ GOwnPtr<GList> removedItems(g_list_prepend(0, itemPageFirst));
+
+ GOwnPtr<char> path(g_strdup_printf("/Page%d", kBackForwardListLimit));
+ test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem | BackForwardListTest::RemovedItems;
+ test->loadURI(kServer->getURIForPath(path.get()).data());
+ test->waitUntilLoadFinishedAndCheckRemovedItems(removedItems.get());
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, kBackForwardListLimit);
+}
+
+void beforeAll()
+{
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ BackForwardListTest::add("BackForwardList", "navigation", testBackForwardListNavigation);
+ BackForwardListTest::add("BackForwardList", "list-limit-and-cache", testBackForwardListLimitAndCache);
+}
+
+void afterAll()
+{
+ delete kServer;
+}
+
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestBackForwardListcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestContextMenucppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestContextMenucpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestContextMenu.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,867 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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,1 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 "WebViewTest.h"
+#include <wtf/gobject/GRefPtr.h>
+
+class ContextMenuTest: public WebViewTest {
+public:
+ enum ContextMenuItemStateFlags {
+ Visible = 1 << 0,
+ Enabled = 1 << 1,
+ Checked = 1 << 2
+ };
+
+ void checkContextMenuEvent(GdkEvent* event)
+ {
+ g_assert(event);
+ g_assert_cmpint(event->type, ==, GDK_BUTTON_PRESS);
+ g_assert_cmpint(event->button.button, ==, 3);
+ g_assert_cmpint(event->button.x, ==, m_menuPositionX);
+ g_assert_cmpint(event->button.y, ==, m_menuPositionY);
+ }
+
+ static gboolean contextMenuCallback(WebKitWebView* webView, WebKitContextMenu* contextMenu, GdkEvent* event, WebKitHitTestResult* hitTestResult, ContextMenuTest* test)
+ {
+ g_assert(WEBKIT_IS_CONTEXT_MENU(contextMenu));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(contextMenu));
+ test->checkContextMenuEvent(event);
+ g_assert(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(hitTestResult));
+
+ return test->contextMenu(contextMenu, event, hitTestResult);
+ }
+
+ static void contextMenuDismissedCallback(WebKitWebView*, ContextMenuTest* test)
+ {
+ test->contextMenuDismissed();
+ }
+
+ ContextMenuTest()
+ : m_menuPositionX(0)
+ , m_menuPositionY(0)
+ {
+ g_signal_connect(m_webView, "context-menu", G_CALLBACK(contextMenuCallback), this);
+ g_signal_connect(m_webView, "context-menu-dismissed", G_CALLBACK(contextMenuDismissedCallback), this);
+ }
+
+ ~ContextMenuTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ virtual bool contextMenu(WebKitContextMenu*, GdkEvent*, WebKitHitTestResult*) = 0;
+
+ virtual void contextMenuDismissed()
+ {
+ quitMainLoop();
+ }
+
+ GtkMenu* getPopupMenu()
+ {
+ GOwnPtr<GList> toplevels(gtk_window_list_toplevels());
+ for (GList* iter = toplevels.get(); iter; iter = g_list_next(iter)) {
+ if (!GTK_IS_WINDOW(iter->data))
+ continue;
+
+ GtkWidget* child = gtk_bin_get_child(GTK_BIN(iter->data));
+ if (!GTK_IS_MENU(child))
+ continue;
+
+ if (gtk_menu_get_attach_widget(GTK_MENU(child)) == GTK_WIDGET(m_webView))
+ return GTK_MENU(child);
+ }
+ g_assert_not_reached();
+ return 0;
+ }
+
+ bool shouldShowInputMethodsMenu()
+ {
+ GtkSettings* settings = gtk_widget_get_settings(GTK_WIDGET(m_webView));
+ if (!settings)
+ return true;
+
+ gboolean showInputMethodMenu;
+ g_object_get(settings, "gtk-show-input-method-menu", &showInputMethodMenu, NULL);
+ return showInputMethodMenu;
+ }
+
+ void checkActionState(GtkAction* action, unsigned state)
+ {
+ if (state & Visible)
+ g_assert(gtk_action_get_visible(action));
+ else
+ g_assert(!gtk_action_get_visible(action));
+
+ if (state & Enabled)
+ g_assert(gtk_action_get_sensitive(action));
+ else
+ g_assert(!gtk_action_get_sensitive(action));
+
+ if (GTK_IS_TOGGLE_ACTION(action)) {
+ if (state & Checked)
+ g_assert(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
+ else
+ g_assert(!gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
+ }
+ }
+
+ GList* checkCurrentItemIsStockActionAndGetNext(GList* items, WebKitContextMenuAction stockAction, unsigned state)
+ {
+ g_assert(items);
+ g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(items->data));
+
+ WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(items->data);
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item));
+
+ GtkAction* action = webkit_context_menu_item_get_action(item);
+ g_assert(GTK_IS_ACTION(action));
+
+ g_assert_cmpint(webkit_context_menu_item_get_stock_action(item), ==, stockAction);
+
+ checkActionState(action, state);
+
+ return g_list_next(items);
+ }
+
+ GList* checkCurrentItemIsCustomActionAndGetNext(GList* items, const char* label, unsigned state)
+ {
+ g_assert(items);
+ g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(items->data));
+
+ WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(items->data);
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item));
+
+ GtkAction* action = webkit_context_menu_item_get_action(item);
+ g_assert(GTK_IS_ACTION(action));
+
+ g_assert_cmpint(webkit_context_menu_item_get_stock_action(item), ==, WEBKIT_CONTEXT_MENU_ACTION_CUSTOM);
+ g_assert_cmpstr(gtk_action_get_label(action), ==, label);
+
+ checkActionState(action, state);
+
+ return g_list_next(items);
+ }
+
+ GList* checkCurrentItemIsSubMenuAndGetNext(GList* items, const char* label, unsigned state, GList** subMenuIter)
+ {
+ g_assert(items);
+ g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(items->data));
+
+ WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(items->data);
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item));
+
+ GtkAction* action = webkit_context_menu_item_get_action(item);
+ g_assert(GTK_IS_ACTION(action));
+
+ g_assert_cmpstr(gtk_action_get_label(action), ==, label);
+ checkActionState(action, state);
+
+ WebKitContextMenu* subMenu = webkit_context_menu_item_get_submenu(item);
+ g_assert(WEBKIT_IS_CONTEXT_MENU(subMenu));
+ if (subMenuIter)
+ *subMenuIter = webkit_context_menu_get_items(subMenu);
+
+ return g_list_next(items);
+ }
+
+ GList* checkCurrentItemIsSeparatorAndGetNext(GList* items)
+ {
+ g_assert(items);
+ g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(items->data));
+
+ WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(items->data);
+ g_assert(webkit_context_menu_item_is_separator(item));
+
+ return g_list_next(items);
+ }
+
+ static gboolean doRightClickIdleCallback(ContextMenuTest* test)
+ {
+ test->clickMouseButton(test->m_menuPositionX, test->m_menuPositionY, 3);
+ return FALSE;
+ }
+
+ void showContextMenuAtPositionAndWaitUntilFinished(int x, int y)
+ {
+ m_menuPositionX = x;
+ m_menuPositionY = y;
+ g_idle_add(reinterpret_cast<GSourceFunc>(doRightClickIdleCallback), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ void showContextMenuAndWaitUntilFinished()
+ {
+ showContextMenuAtPositionAndWaitUntilFinished(0, 0);
+ }
+
+ static gboolean simulateEscKeyIdleCallback(ContextMenuTest* test)
+ {
+ test->keyStroke(GDK_KEY_Escape);
+ return FALSE;
+ }
+
+ void dismissContextMenuAndWaitUntilFinished()
+ {
+ g_idle_add(reinterpret_cast<GSourceFunc>(simulateEscKeyIdleCallback), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ double m_menuPositionX;
+ double m_menuPositionY;
+};
+
+class ContextMenuDefaultTest: public ContextMenuTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ContextMenuDefaultTest);
+
+ enum DefaultMenuType {
+ Navigation,
+ Link,
+ Image,
+ LinkImage,
+ Video,
+ Audio,
+ Editable
+ };
+
+ ContextMenuDefaultTest()
+ : m_expectedMenuType(Navigation)
+ {
+ }
+
+ bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent* event, WebKitHitTestResult* hitTestResult)
+ {
+ GList* iter = webkit_context_menu_get_items(contextMenu);
+
+ switch (m_expectedMenuType) {
+ case Navigation:
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_GO_BACK, Visible);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD, Visible);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_STOP, Visible);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_RELOAD, Visible | Enabled);
+ break;
+ case Link:
+ g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK_IN_NEW_WINDOW, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_LINK_TO_CLIPBOARD, Visible | Enabled);
+ break;
+ case Image:
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_IMAGE_IN_NEW_WINDOW, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_IMAGE_TO_DISK, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_TO_CLIPBOARD, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_URL_TO_CLIPBOARD, Visible | Enabled);
+ break;
+ case LinkImage:
+ g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK_IN_NEW_WINDOW, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_LINK_TO_CLIPBOARD, Visible | Enabled);
+ iter = checkCurrentItemIsSeparatorAndGetNext(iter);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_IMAGE_IN_NEW_WINDOW, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_IMAGE_TO_DISK, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_TO_CLIPBOARD, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_URL_TO_CLIPBOARD, Visible | Enabled);
+ break;
+ case Video:
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE, Visible);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS, Visible | Enabled | Checked);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_ENTER_VIDEO_FULLSCREEN, Visible | Enabled);
+ iter = checkCurrentItemIsSeparatorAndGetNext(iter);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_VIDEO_LINK_TO_CLIPBOARD, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_VIDEO_IN_NEW_WINDOW, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_VIDEO_TO_DISK, Visible | Enabled);
+ break;
+ case Audio:
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE, Visible);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS, Visible | Enabled | Checked);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_ENTER_VIDEO_FULLSCREEN, Visible);
+ iter = checkCurrentItemIsSeparatorAndGetNext(iter);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_AUDIO_LINK_TO_CLIPBOARD, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_AUDIO_IN_NEW_WINDOW, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_AUDIO_TO_DISK, Visible | Enabled);
+ break;
+ case Editable:
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_editable(hitTestResult));
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_CUT, Visible);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY, Visible);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_PASTE, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DELETE, Visible);
+ iter = checkCurrentItemIsSeparatorAndGetNext(iter);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_SELECT_ALL, Visible | Enabled);
+ iter = checkCurrentItemIsSeparatorAndGetNext(iter);
+ if (shouldShowInputMethodsMenu())
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_UNICODE, Visible | Enabled);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+
+ if (webkit_settings_get_enable_developer_extras(webkit_web_view_get_settings(m_webView))) {
+ iter = checkCurrentItemIsSeparatorAndGetNext(iter);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT, Visible | Enabled);
+ }
+ g_assert(!iter);
+
+ quitMainLoop();
+
+ return true;
+ }
+
+ DefaultMenuType m_expectedMenuType;
+};
+
+static void testContextMenuDefaultMenu(ContextMenuDefaultTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+
+ const char* linksHTML =
+ "<html><body>"
+ " <a style='position:absolute; left:1; top:1' href='http://www.webkitgtk.org' title='WebKitGTK+ Title'>WebKitGTK+ Website</a>"
+ " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>"
+ " <a style='position:absolute; left:1; top:20' href='http://www.webkitgtk.org/logo' title='WebKitGTK+ Logo'><img src='0xdeadbeef' width=5 height=5></img></a>"
+ " <input style='position:absolute; left:1; top:30' size='10'></input>"
+ " <video style='position:absolute; left:1; top:50' width='300' height='300' controls='controls' preload='none'><source src='movie.ogg' type='video/ogg' /></video>"
+ " <audio style='position:absolute; left:1; top:60' width='50' height='20' controls='controls' preload='none'><source src='track.mp3' type='audio/mp3' /></audio>"
+ "</body></html>";
+ test->loadHtml(linksHTML, "file:///");
+ test->waitUntilLoadFinished();
+
+ // Context menu for document.
+ test->m_expectedMenuType = ContextMenuDefaultTest::Navigation;
+ test->showContextMenuAtPositionAndWaitUntilFinished(0, 0);
+
+ // Context menu for link.
+ test->m_expectedMenuType = ContextMenuDefaultTest::Link;
+ test->showContextMenuAtPositionAndWaitUntilFinished(1, 1);
+
+ // Context menu for image.
+ test->m_expectedMenuType = ContextMenuDefaultTest::Image;
+ test->showContextMenuAtPositionAndWaitUntilFinished(1, 10);
+
+ // Enable developer extras now, so that inspector element
+ // will be shown in the default context menu.
+ webkit_settings_set_enable_developer_extras(webkit_web_view_get_settings(test->m_webView), TRUE);
+
+ // Context menu for image link.
+ test->m_expectedMenuType = ContextMenuDefaultTest::LinkImage;
+ test->showContextMenuAtPositionAndWaitUntilFinished(1, 20);
+
+ // Context menu for video.
+ test->m_expectedMenuType = ContextMenuDefaultTest::Video;
+ test->showContextMenuAtPositionAndWaitUntilFinished(1, 50);
+
+ // Context menu for audio.
+ test->m_expectedMenuType = ContextMenuDefaultTest::Audio;
+ test->showContextMenuAtPositionAndWaitUntilFinished(1, 60);
+
+ // Context menu for editable.
+ test->m_expectedMenuType = ContextMenuDefaultTest::Editable;
+ test->showContextMenuAtPositionAndWaitUntilFinished(5, 35);
+}
+
+class ContextMenuCustomTest: public ContextMenuTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ContextMenuCustomTest);
+
+ ContextMenuCustomTest()
+ : m_itemToActivateLabel(0)
+ , m_activated(false)
+ , m_toggled(false)
+ {
+ }
+
+ bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult)
+ {
+ // Append our custom item to the default menu.
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new(m_action.get()));
+ quitMainLoop();
+
+ return false;
+ }
+
+ GtkMenuItem* getMenuItem(GtkMenu* menu, const gchar* itemLabel)
+ {
+ GOwnPtr<GList> items(gtk_container_get_children(GTK_CONTAINER(menu)));
+ for (GList* iter = items.get(); iter; iter = g_list_next(iter)) {
+ GtkMenuItem* child = GTK_MENU_ITEM(iter->data);
+ if (g_str_equal(itemLabel, gtk_menu_item_get_label(child)))
+ return child;
+ }
+ g_assert_not_reached();
+ return 0;
+ }
+
+ void activateMenuItem()
+ {
+ g_assert(m_itemToActivateLabel);
+ GtkMenu* menu = getPopupMenu();
+ GtkMenuItem* item = getMenuItem(menu, m_itemToActivateLabel);
+ gtk_menu_shell_activate_item(GTK_MENU_SHELL(menu), GTK_WIDGET(item), TRUE);
+ m_itemToActivateLabel = 0;
+ }
+
+ static gboolean activateMenuItemIdleCallback(gpointer userData)
+ {
+ ContextMenuCustomTest* test = static_cast<ContextMenuCustomTest*>(userData);
+ test->activateMenuItem();
+ return FALSE;
+ }
+
+ void activateCustomMenuItemAndWaitUntilActivated(const char* actionLabel)
+ {
+ m_activated = m_toggled = false;
+ m_itemToActivateLabel = actionLabel;
+ g_idle_add(activateMenuItemIdleCallback, this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ void toggleCustomMenuItemAndWaitUntilToggled(const char* actionLabel)
+ {
+ activateCustomMenuItemAndWaitUntilActivated(actionLabel);
+ }
+
+ static void actionActivatedCallback(GtkAction*, ContextMenuCustomTest* test)
+ {
+ test->m_activated = true;
+ }
+
+ static void actionToggledCallback(GtkAction*, ContextMenuCustomTest* test)
+ {
+ test->m_toggled = true;
+ }
+
+ void setAction(GtkAction* action)
+ {
+ m_action = action;
+ if (GTK_IS_TOGGLE_ACTION(action))
+ g_signal_connect(action, "toggled", G_CALLBACK(actionToggledCallback), this);
+ else
+ g_signal_connect(action, "activate", G_CALLBACK(actionActivatedCallback), this);
+ }
+
+ GRefPtr<GtkAction> m_action;
+ const char* m_itemToActivateLabel;
+ bool m_activated;
+ bool m_toggled;
+};
+
+static void testContextMenuPopulateMenu(ContextMenuCustomTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+
+ test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///");
+ test->waitUntilLoadFinished();
+
+ // Create a custom menu item.
+ GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTK+CustomAction", "Custom _Action", 0, 0));
+ test->setAction(action.get());
+ test->showContextMenuAndWaitUntilFinished();
+ test->activateCustomMenuItemAndWaitUntilActivated(gtk_action_get_label(action.get()));
+ g_assert(test->m_activated);
+ g_assert(!test->m_toggled);
+
+ // Create a custom toggle menu item.
+ GRefPtr<GtkAction> toggleAction = adoptGRef(GTK_ACTION(gtk_toggle_action_new("WebKitGTK+CustomToggleAction", "Custom _Toggle Action", 0, 0)));
+ test->setAction(toggleAction.get());
+ test->showContextMenuAndWaitUntilFinished();
+ test->toggleCustomMenuItemAndWaitUntilToggled(gtk_action_get_label(toggleAction.get()));
+ g_assert(!test->m_activated);
+ g_assert(test->m_toggled);
+}
+
+class ContextMenuCustomFullTest: public ContextMenuTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ContextMenuCustomFullTest);
+
+ bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*)
+ {
+ // Clear proposed menu and build our own.
+ webkit_context_menu_remove_all(contextMenu);
+ g_assert_cmpint(webkit_context_menu_get_n_items(contextMenu), ==, 0);
+
+ // Add actions from stock.
+ webkit_context_menu_prepend(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_GO_BACK));
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD));
+ webkit_context_menu_insert(contextMenu, webkit_context_menu_item_new_separator(), 2);
+
+ // Add custom actions.
+ GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTK+CustomAction", "Custom _Action", 0, 0));
+ gtk_action_set_sensitive(action.get(), FALSE);
+ webkit_context_menu_insert(contextMenu, webkit_context_menu_item_new(action.get()), -1);
+ GRefPtr<GtkAction> toggleAction = adoptGRef(GTK_ACTION(gtk_toggle_action_new("WebKitGTK+CustomToggleAction", "Custom _Toggle Action", 0, 0)));
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(toggleAction.get()), TRUE);
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new(toggleAction.get()));
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator());
+
+ // Add a submenu.
+ GRefPtr<WebKitContextMenu> subMenu = adoptGRef(webkit_context_menu_new());
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(subMenu.get()));
+ webkit_context_menu_insert(subMenu.get(), webkit_context_menu_item_new_from_stock_action_with_label(WEBKIT_CONTEXT_MENU_ACTION_STOP, "Stop Load"), 0);
+ webkit_context_menu_insert(subMenu.get(), webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_RELOAD), -1);
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_with_submenu("Load options", subMenu.get()));
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator());
+
+ // Move Load submenu before custom actions.
+ webkit_context_menu_move_item(contextMenu, webkit_context_menu_last(contextMenu), 3);
+ webkit_context_menu_move_item(contextMenu, webkit_context_menu_last(contextMenu), 3);
+
+ // If last item is a separator, remove it.
+ if (webkit_context_menu_item_is_separator(webkit_context_menu_last(contextMenu)))
+ webkit_context_menu_remove(contextMenu, webkit_context_menu_last(contextMenu));
+
+ // Check the menu.
+ GList* iter = webkit_context_menu_get_items(contextMenu);
+
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_GO_BACK, Visible | Enabled);
+ iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD, Visible | Enabled);
+ iter = checkCurrentItemIsSeparatorAndGetNext(iter);
+
+ GList* subMenuIter = 0;
+ iter = checkCurrentItemIsSubMenuAndGetNext(iter, "Load options", Visible | Enabled, &subMenuIter);
+ subMenuIter = checkCurrentItemIsStockActionAndGetNext(subMenuIter, WEBKIT_CONTEXT_MENU_ACTION_STOP, Visible | Enabled);
+ subMenuIter = checkCurrentItemIsStockActionAndGetNext(subMenuIter, WEBKIT_CONTEXT_MENU_ACTION_RELOAD, Visible | Enabled);
+ iter = checkCurrentItemIsSeparatorAndGetNext(iter);
+
+ iter = checkCurrentItemIsCustomActionAndGetNext(iter, "Custom _Action", Visible);
+ iter = checkCurrentItemIsCustomActionAndGetNext(iter, "Custom _Toggle Action", Visible | Enabled | Checked);
+ g_assert(!iter);
+
+ quitMainLoop();
+
+ return true;
+ }
+};
+
+static void testContextMenuCustomMenu(ContextMenuCustomFullTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+
+ test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///");
+ test->waitUntilLoadFinished();
+
+ test->showContextMenuAndWaitUntilFinished();
+}
+
+class ContextMenuDisabledTest: public ContextMenuTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ContextMenuDisabledTest);
+
+ enum DisableMode {
+ IgnoreClicks,
+ IgnoreDefaultMenu
+ };
+
+ static gboolean buttonPressEventCallback(GtkWidget*, GdkEvent* event, ContextMenuDisabledTest* test)
+ {
+ if (event->button.button != 3)
+ return FALSE;
+ return test->rightButtonPressed();
+ }
+
+ ContextMenuDisabledTest()
+ : m_disableMode(IgnoreClicks)
+ {
+ g_signal_connect(m_webView, "button-press-event", G_CALLBACK(buttonPressEventCallback), this);
+ }
+
+ bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*)
+ {
+ if (m_disableMode == IgnoreClicks)
+ g_assert_not_reached();
+ else
+ quitMainLoop();
+
+ return true;
+ }
+
+ bool rightButtonPressed()
+ {
+ if (m_disableMode == IgnoreClicks) {
+ quitMainLoopAfterProcessingPendingEvents();
+ return true;
+ }
+ return false;
+ }
+
+ DisableMode m_disableMode;
+};
+
+static void testContextMenuDisableMenu(ContextMenuDisabledTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+
+ test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///");
+ test->waitUntilLoadFinished();
+
+ test->m_disableMode = ContextMenuDisabledTest::IgnoreDefaultMenu;
+ test->showContextMenuAndWaitUntilFinished();
+
+ test->m_disableMode = ContextMenuDisabledTest::IgnoreClicks;
+ test->showContextMenuAndWaitUntilFinished();
+}
+
+class ContextMenuSubmenuTest: public ContextMenuTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ContextMenuSubmenuTest);
+
+ bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*)
+ {
+ size_t menuSize = webkit_context_menu_get_n_items(contextMenu);
+ GRefPtr<WebKitContextMenu> subMenu = adoptGRef(webkit_context_menu_new());
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_with_submenu("SubMenuItem", subMenu.get()));
+ g_assert_cmpuint(webkit_context_menu_get_n_items(contextMenu), ==, menuSize + 1);
+
+ GRefPtr<WebKitContextMenu> subMenu2 = adoptGRef(webkit_context_menu_new());
+ GRefPtr<WebKitContextMenuItem> item = webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK);
+
+ // Add submenu to newly created item.
+ g_assert(!webkit_context_menu_item_get_submenu(item.get()));
+ webkit_context_menu_item_set_submenu(item.get(), subMenu2.get());
+ g_assert(webkit_context_menu_item_get_submenu(item.get()) == subMenu2.get());
+
+ // Replace the submenu.
+ webkit_context_menu_item_set_submenu(item.get(), 0);
+ g_assert(!webkit_context_menu_item_get_submenu(item.get()));
+
+ // Try to add a submenu already added to another item.
+ removeLogFatalFlag(G_LOG_LEVEL_WARNING);
+ webkit_context_menu_item_set_submenu(item.get(), subMenu.get());
+ addLogFatalFlag(G_LOG_LEVEL_WARNING);
+ g_assert(!webkit_context_menu_item_get_submenu(item.get()));
+
+ // A removed submenu shouldn't have a parent.
+ webkit_context_menu_item_set_submenu(item.get(), subMenu2.get());
+ g_assert(webkit_context_menu_item_get_submenu(item.get()) == subMenu2.get());
+
+ quitMainLoop();
+
+ return true;
+ }
+};
+
+static void testContextMenuSubMenu(ContextMenuSubmenuTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+
+ test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///");
+ test->waitUntilLoadFinished();
+
+ test->showContextMenuAndWaitUntilFinished();
+}
+
+class ContextMenuDismissedTest: public ContextMenuTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ContextMenuDismissedTest);
+
+ ContextMenuDismissedTest()
+ : m_dismissed(false)
+ {
+ }
+
+ bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*)
+ {
+ quitMainLoop();
+ // Show the default context menu.
+ return false;
+ }
+
+ void contextMenuDismissed()
+ {
+ m_dismissed = true;
+ ContextMenuTest::contextMenuDismissed();
+ }
+
+ void showContextMenuAndWaitUntilDismissed()
+ {
+ showContextMenuAndWaitUntilFinished();
+ dismissContextMenuAndWaitUntilFinished();
+ }
+
+ bool m_dismissed;
+};
+
+static void testContextMenuDismissed(ContextMenuDismissedTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+
+ test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///");
+ test->waitUntilLoadFinished();
+
+ test->showContextMenuAndWaitUntilDismissed();
+ g_assert(test->m_dismissed);
+}
+
+class ContextMenuSmartSeparatorsTest: public ContextMenuTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ContextMenuSmartSeparatorsTest);
+
+ bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*)
+ {
+ webkit_context_menu_remove_all(contextMenu);
+
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator());
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator());
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_GO_BACK));
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD));
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator());
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator());
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_COPY));
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator());
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT));
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator());
+ webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator());
+
+ quitMainLoop();
+
+ return false;
+ }
+
+ GtkMenu* showContextMenuAndGetGtkMenu()
+ {
+ showContextMenuAndWaitUntilFinished();
+ return getPopupMenu();
+ }
+};
+
+static void testContextMenuSmartSeparators(ContextMenuSmartSeparatorsTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+
+ test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///");
+ test->waitUntilLoadFinished();
+
+ GtkMenu* menu = test->showContextMenuAndGetGtkMenu();
+ g_assert(menu);
+
+ // Leading and trailing separators are not added to the context menu.
+ GOwnPtr<GList> menuItems(gtk_container_get_children(GTK_CONTAINER(menu)));
+ g_assert_cmpuint(g_list_length(menuItems.get()), ==, 6);
+ GtkWidget* item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 0));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 1));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 2));
+ g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 3));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 4));
+ g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 5));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+
+ // Hiding a menu item between two separators hides the following separator.
+ GtkAction* action = gtk_activatable_get_related_action(GTK_ACTIVATABLE(g_list_nth_data(menuItems.get(), 3)));
+ gtk_action_set_visible(action, FALSE);
+ menuItems.set(gtk_container_get_children(GTK_CONTAINER(menu)));
+ g_assert_cmpuint(g_list_length(menuItems.get()), ==, 6);
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 0));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 1));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 2));
+ g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 3));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && !gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 4));
+ g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && !gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 5));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ gtk_action_set_visible(action, TRUE);
+
+ // Showing an action between two separators shows the hidden separator.
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 0));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 1));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 2));
+ g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 3));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 4));
+ g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 5));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+
+ // Trailing separators are hidden too.
+ action = gtk_activatable_get_related_action(GTK_ACTIVATABLE(g_list_nth_data(menuItems.get(), 5)));
+ gtk_action_set_visible(action, FALSE);
+ menuItems.set(gtk_container_get_children(GTK_CONTAINER(menu)));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 0));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 1));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 2));
+ g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 3));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 4));
+ g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && !gtk_widget_get_visible(item));
+ item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 5));
+ g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && !gtk_widget_get_visible(item));
+}
+
+void beforeAll()
+{
+ ContextMenuDefaultTest::add("WebKitWebView", "default-menu", testContextMenuDefaultMenu);
+ ContextMenuCustomTest::add("WebKitWebView", "populate-menu", testContextMenuPopulateMenu);
+ ContextMenuCustomFullTest::add("WebKitWebView", "custom-menu", testContextMenuCustomMenu);
+ ContextMenuDisabledTest::add("WebKitWebView", "disable-menu", testContextMenuDisableMenu);
+ ContextMenuSubmenuTest::add("WebKitWebView", "submenu", testContextMenuSubMenu);
+ ContextMenuDismissedTest::add("WebKitWebView", "menu-dismissed", testContextMenuDismissed);
+ ContextMenuSmartSeparatorsTest::add("WebKitWebView", "smart-separators", testContextMenuSmartSeparators);
+}
+
+void afterAll()
+{
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestContextMenucpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestCookieManagercppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestCookieManagercpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestCookieManager.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,331 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 "WebKitTestServer.h"
+#include "WebViewTest.h"
+#include <glib/gstdio.h>
+
+static WebKitTestServer* kServer;
+static char* kTempDirectory;
+
+static const char* kFirstPartyDomain = "127.0.0.1";
+static const char* kThirdPartyDomain = "localhost";
+static const char* kIndexHtmlFormat =
+ "<html><body>"
+ " <p>WebKitGTK+ Cookie Manager test</p>"
+ " <img src='http://localhost:%u/image.png' width=5 height=5></img>"
+ "</body></html>";
+
+class CookieManagerTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(CookieManagerTest);
+
+ static void cookiesChangedCallback(WebKitCookieManager*, CookieManagerTest* test)
+ {
+ test->m_cookiesChanged = true;
+ if (test->m_finishLoopWhenCookiesChange)
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ CookieManagerTest()
+ : WebViewTest()
+ , m_cookieManager(webkit_web_context_get_cookie_manager(webkit_web_view_get_context(m_webView)))
+ , m_acceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY)
+ , m_domains(0)
+ , m_cookiesChanged(false)
+ , m_finishLoopWhenCookiesChange(false)
+ {
+ g_signal_connect(m_cookieManager, "changed", G_CALLBACK(cookiesChangedCallback), this);
+ }
+
+ ~CookieManagerTest()
+ {
+ g_strfreev(m_domains);
+ g_signal_handlers_disconnect_matched(m_cookieManager, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ if (m_cookiesTextFile)
+ g_unlink(m_cookiesTextFile.get());
+ if (m_cookiesSQLiteFile)
+ g_unlink(m_cookiesSQLiteFile.get());
+ }
+
+ void setPersistentStorage(WebKitCookiePersistentStorage storage)
+ {
+ const char* filename = 0;
+ switch (storage) {
+ case WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT:
+ if (!m_cookiesTextFile)
+ m_cookiesTextFile.set(g_build_filename(kTempDirectory, "cookies.txt", NULL));
+ filename = m_cookiesTextFile.get();
+ break;
+ case WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE:
+ if (!m_cookiesSQLiteFile)
+ m_cookiesSQLiteFile.set(g_build_filename(kTempDirectory, "cookies.db", NULL));
+ filename = m_cookiesSQLiteFile.get();
+ break;
+ default:
+ g_assert_not_reached();
+ }
+ webkit_cookie_manager_set_persistent_storage(m_cookieManager, filename, storage);
+ }
+
+ static void getAcceptPolicyReadyCallback(GObject* object, GAsyncResult* result, gpointer userData)
+ {
+ GOwnPtr<GError> error;
+ WebKitCookieAcceptPolicy policy = webkit_cookie_manager_get_accept_policy_finish(WEBKIT_COOKIE_MANAGER(object), result, &error.outPtr());
+ g_assert(!error.get());
+
+ CookieManagerTest* test = static_cast<CookieManagerTest*>(userData);
+ test->m_acceptPolicy = policy;
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ WebKitCookieAcceptPolicy getAcceptPolicy()
+ {
+ m_acceptPolicy = WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY;
+ webkit_cookie_manager_get_accept_policy(m_cookieManager, 0, getAcceptPolicyReadyCallback, this);
+ g_main_loop_run(m_mainLoop);
+
+ return m_acceptPolicy;
+ }
+
+ void setAcceptPolicy(WebKitCookieAcceptPolicy policy)
+ {
+ webkit_cookie_manager_set_accept_policy(m_cookieManager, policy);
+ }
+
+ static void getDomainsReadyCallback(GObject* object, GAsyncResult* result, gpointer userData)
+ {
+ GOwnPtr<GError> error;
+ char** domains = webkit_cookie_manager_get_domains_with_cookies_finish(WEBKIT_COOKIE_MANAGER(object), result, &error.outPtr());
+ g_assert(!error.get());
+
+ CookieManagerTest* test = static_cast<CookieManagerTest*>(userData);
+ test->m_domains = domains;
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ char** getDomains()
+ {
+ g_strfreev(m_domains);
+ m_domains = 0;
+ webkit_cookie_manager_get_domains_with_cookies(m_cookieManager, 0, getDomainsReadyCallback, this);
+ g_main_loop_run(m_mainLoop);
+
+ return m_domains;
+ }
+
+ bool hasDomain(const char* domain)
+ {
+ if (!m_domains)
+ return false;
+
+ for (size_t i = 0; m_domains[i]; ++i)
+ if (g_str_equal(m_domains[i], domain))
+ return true;
+ return false;
+ }
+
+ void deleteCookiesForDomain(const char* domain)
+ {
+ webkit_cookie_manager_delete_cookies_for_domain(m_cookieManager, domain);
+ }
+
+ void deleteAllCookies()
+ {
+ webkit_cookie_manager_delete_all_cookies(m_cookieManager);
+ }
+
+ void waitUntilCookiesChanged()
+ {
+ m_cookiesChanged = false;
+ m_finishLoopWhenCookiesChange = true;
+ g_main_loop_run(m_mainLoop);
+ m_finishLoopWhenCookiesChange = false;
+ }
+
+ WebKitCookieManager* m_cookieManager;
+ WebKitCookieAcceptPolicy m_acceptPolicy;
+ char** m_domains;
+ bool m_cookiesChanged;
+ bool m_finishLoopWhenCookiesChange;
+ GOwnPtr<char> m_cookiesTextFile;
+ GOwnPtr<char> m_cookiesSQLiteFile;
+};
+
+static void testCookieManagerAcceptPolicy(CookieManagerTest* test, gconstpointer)
+{
+ // Default policy is NO_THIRD_PARTY.
+ g_assert_cmpint(test->getAcceptPolicy(), ==, WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY);
+ test->loadURI(kServer->getURIForPath("/index.html").data());
+ test->waitUntilLoadFinished();
+ char** domains = test->getDomains();
+ g_assert(domains);
+ g_assert_cmpint(g_strv_length(domains), ==, 1);
+ g_assert_cmpstr(domains[0], ==, kFirstPartyDomain);
+ test->deleteAllCookies();
+
+ test->setAcceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
+ g_assert_cmpint(test->getAcceptPolicy(), ==, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
+ test->loadURI(kServer->getURIForPath("/index.html").data());
+ test->waitUntilLoadFinished();
+ domains = test->getDomains();
+ g_assert(domains);
+ g_assert_cmpint(g_strv_length(domains), ==, 2);
+ g_assert(test->hasDomain(kFirstPartyDomain));
+ g_assert(test->hasDomain(kThirdPartyDomain));
+ test->deleteAllCookies();
+
+ test->setAcceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_NEVER);
+ g_assert_cmpint(test->getAcceptPolicy(), ==, WEBKIT_COOKIE_POLICY_ACCEPT_NEVER);
+ test->loadURI(kServer->getURIForPath("/index.html").data());
+ test->waitUntilLoadFinished();
+ domains = test->getDomains();
+ g_assert(domains);
+ g_assert_cmpint(g_strv_length(domains), ==, 0);
+}
+
+static void testCookieManagerDeleteCookies(CookieManagerTest* test, gconstpointer)
+{
+ test->setAcceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
+ test->loadURI(kServer->getURIForPath("/index.html").data());
+ test->waitUntilLoadFinished();
+ g_assert_cmpint(g_strv_length(test->getDomains()), ==, 2);
+
+ // Delete first party cookies.
+ test->deleteCookiesForDomain(kFirstPartyDomain);
+ g_assert_cmpint(g_strv_length(test->getDomains()), ==, 1);
+
+ // Delete third party cookies.
+ test->deleteCookiesForDomain(kThirdPartyDomain);
+ g_assert_cmpint(g_strv_length(test->getDomains()), ==, 0);
+
+ test->loadURI(kServer->getURIForPath("/index.html").data());
+ test->waitUntilLoadFinished();
+ g_assert_cmpint(g_strv_length(test->getDomains()), ==, 2);
+
+ // Delete all cookies.
+ test->deleteAllCookies();
+ g_assert_cmpint(g_strv_length(test->getDomains()), ==, 0);
+}
+
+static void testCookieManagerCookiesChanged(CookieManagerTest* test, gconstpointer)
+{
+ g_assert(!test->m_cookiesChanged);
+ test->setAcceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
+ test->loadURI(kServer->getURIForPath("/index.html").data());
+ test->waitUntilLoadFinished();
+ g_assert(test->m_cookiesChanged);
+
+ test->deleteCookiesForDomain(kFirstPartyDomain);
+ test->waitUntilCookiesChanged();
+ g_assert(test->m_cookiesChanged);
+
+ test->deleteAllCookies();
+ test->waitUntilCookiesChanged();
+ g_assert(test->m_cookiesChanged);
+}
+
+static void testCookieManagerPersistentStorage(CookieManagerTest* test, gconstpointer)
+{
+ test->setAcceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
+
+ // Text storage using a new file.
+ test->setPersistentStorage(WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT);
+ char** domains = test->getDomains();
+ g_assert(domains);
+ g_assert_cmpint(g_strv_length(domains), ==, 0);
+
+ test->loadURI(kServer->getURIForPath("/index.html").data());
+ test->waitUntilLoadFinished();
+ g_assert(test->m_cookiesChanged);
+ domains = test->getDomains();
+ g_assert(domains);
+ g_assert_cmpint(g_strv_length(domains), ==, 2);
+
+
+ // SQLite storage using a new file.
+ test->setPersistentStorage(WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
+ domains = test->getDomains();
+ g_assert(domains);
+ g_assert_cmpint(g_strv_length(domains), ==, 0);
+
+ test->loadURI(kServer->getURIForPath("/index.html").data());
+ test->waitUntilLoadFinished();
+ g_assert(test->m_cookiesChanged);
+ domains = test->getDomains();
+ g_assert(domains);
+ g_assert_cmpint(g_strv_length(domains), ==, 2);
+
+ // Text storage using an existing file.
+ test->setPersistentStorage(WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT);
+ domains = test->getDomains();
+ g_assert(domains);
+ g_assert_cmpint(g_strv_length(domains), ==, 2);
+ test->deleteAllCookies();
+ g_assert_cmpint(g_strv_length(test->getDomains()), ==, 0);
+
+ // SQLite storage with an existing file.
+ test->setPersistentStorage(WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
+ domains = test->getDomains();
+ g_assert(domains);
+ g_assert_cmpint(g_strv_length(domains), ==, 2);
+ test->deleteAllCookies();
+ g_assert_cmpint(g_strv_length(test->getDomains()), ==, 0);
+}
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ if (g_str_equal(path, "/index.html")) {
+ char* indexHtml = g_strdup_printf(kIndexHtmlFormat, soup_server_get_port(server));
+ soup_message_headers_replace(message->response_headers, "Set-Cookie", "foo=bar; Max-Age=60");
+ soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, indexHtml, strlen(indexHtml));
+ } else if (g_str_equal(path, "/image.png"))
+ soup_message_headers_replace(message->response_headers, "Set-Cookie", "baz=qux; Max-Age=60");
+ else
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+ soup_message_body_complete(message->response_body);
+}
+
+void beforeAll()
+{
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0);
+ g_assert(kTempDirectory);
+
+ CookieManagerTest::add("WebKitCookieManager", "accept-policy", testCookieManagerAcceptPolicy);
+ CookieManagerTest::add("WebKitCookieManager", "delete-cookies", testCookieManagerDeleteCookies);
+ CookieManagerTest::add("WebKitCookieManager", "cookies-changed", testCookieManagerCookiesChanged);
+ CookieManagerTest::add("WebKitCookieManager", "persistent-storage", testCookieManagerPersistentStorage);
+}
+
+void afterAll()
+{
+ delete kServer;
+ g_rmdir(kTempDirectory);
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestCookieManagercpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestDOMDOMWindowcpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMDOMWindow.cpp (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMDOMWindow.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMDOMWindow.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,152 @@
</span><ins>+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * 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,1 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 "WebProcessTestRunner.h"
+#include "WebViewTest.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+#define HTML_DOCUMENT "<html><head><title></title></head><style type='text/css'>#test { font-size: 16px; }</style><body><p id='test'>test</p></body></html>"
+
+typedef struct {
+ gboolean loaded;
+ gboolean clicked;
+ WebProcessTestRunner* testRunner;
+ WebViewTest* test;
+} DomDomWindowTestStatus;
+
+static DomDomWindowTestStatus status;
+
+static void signalsNotifyCallback(const gchar *key, const gchar *value, gconstpointer)
+{
+ if (g_str_equal(key, "ready")) {
+ // The document was already loaded in the webprocess, and its "load"
+ // signal couldn't be captured on time (was issued before the test
+ // started). We load it again to force a new "load" signal in the
+ // webprocess, which will be captured this time
+ status.test->loadHtml(HTML_DOCUMENT, 0);
+ }
+
+ if (g_str_equal(key, "loaded")) {
+ status.loaded = TRUE;
+ status.test->showInWindowAndWaitUntilMapped();
+
+ // Click in a known location where the text is
+ status.test->clickMouseButton(20, 18, 1, 0);
+ }
+
+ if (g_str_equal(key, "clicked"))
+ status.clicked = TRUE;
+
+ if (g_str_equal(key, "finish")) {
+ status.test = 0;
+ status.testRunner->finishTest(status.loaded && status.clicked);
+ }
+}
+
+static void dispatchEventNotifyCallback(const gchar *key, const gchar *value, gconstpointer)
+{
+ if (g_str_equal(key, "ready")) {
+ // The document was already loaded in the webprocess, and its "load"
+ // signal couldn't be captured on time (was issued before the test
+ // started). We load it again to force a new "load" signal in the
+ // webprocess, which will be captured this time
+ status.test->loadHtml(HTML_DOCUMENT, 0);
+ }
+
+ if (g_str_equal(key, "loaded"))
+ status.loaded = TRUE;
+
+ if (g_str_equal(key, "clicked"))
+ status.clicked = TRUE;
+
+ if (g_str_equal(key, "finish")) {
+ status.test = 0;
+ status.testRunner->finishTest(status.loaded && status.clicked);
+ }
+}
+
+static void testWebKitDOMDOMWindowSignals(WebViewTest* test, gconstpointer)
+{
+ status.loaded = FALSE;
+ status.clicked = FALSE;
+ status.test = test;
+
+ status.testRunner->setNotifyCallback(G_CALLBACK(signalsNotifyCallback), 0);
+
+ // The HTML document will we loaded later, when the test is "ready" because
+ // we want to test the "load" signal
+
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(status.test->m_webView)));
+ status.testRunner->runTestAndWait("WebKitDOMDOMWindow", "signals", g_variant_builder_end(&builder));
+ g_assert(status.testRunner->getTestResult());
+}
+
+static void testWebKitDOMDOMWindowDispatchEvent(WebViewTest* test, gconstpointer)
+{
+ status.loaded = FALSE;
+ status.clicked = FALSE;
+ status.test = test;
+
+ status.testRunner->setNotifyCallback(G_CALLBACK(dispatchEventNotifyCallback), 0);
+
+ // The HTML document will we loaded later, when the test is "ready" because
+ // we want to test the "load" signal
+
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(status.test->m_webView)));
+ status.testRunner->runTestAndWait("WebKitDOMDOMWindow", "dispatch-event", g_variant_builder_end(&builder));
+ g_assert(status.testRunner->getTestResult());
+}
+
+static void testWebKitDOMDOMWindowGetComputedStyle(WebViewTest* test, gconstpointer)
+{
+ status.loaded = FALSE;
+ status.clicked = FALSE;
+ status.test = test;
+
+ static const char* testHTML = HTML_DOCUMENT;
+ status.test->loadHtml(testHTML, 0);
+ status.test->waitUntilLoadFinished();
+
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(status.test->m_webView)));
+ g_assert(status.testRunner->runTest("WebKitDOMDOMWindow", "get-computed-style", g_variant_builder_end(&builder)));
+}
+
+void beforeAll()
+{
+ status.testRunner = new WebProcessTestRunner();
+ webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+
+ WebViewTest::add("WebKitDOMDOMWindow", "signals", testWebKitDOMDOMWindowSignals);
+ WebViewTest::add("WebKitDOMDOMWindow", "dispatch-event", testWebKitDOMDOMWindowDispatchEvent);
+ WebViewTest::add("WebKitDOMDOMWindow", "get-computed-style", testWebKitDOMDOMWindowGetComputedStyle);
+}
+
+void afterAll()
+{
+ delete status.testRunner;
+}
</ins><span class="cx">Property changes on: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMDOMWindow.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestDOMNodecppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestDOMNodecpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestDOMNode.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,87 @@
</span><ins>+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * 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,1 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 "WebProcessTestRunner.h"
+#include "WebViewTest.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+static WebProcessTestRunner* testRunner;
+
+static void testWebKitDOMNodeHierarchyNavigation(WebViewTest* test, gconstpointer)
+{
+ static const char* testHTML = "<html><head><title>This is the title</title></head><body><p>1</p><p>2</p><p>3</p></body></html>";
+ test->loadHtml(testHTML, 0);
+ test->waitUntilLoadFinished();
+
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
+ g_assert(testRunner->runTest("WebKitDOMNode", "hierarchy-navigation", g_variant_builder_end(&builder)));
+}
+
+static void testWebKitDOMNodeInsertion(WebViewTest* test, gconstpointer)
+{
+ static const char* testHTML = "<html><body></body></html>";
+ test->loadHtml(testHTML, 0);
+ test->waitUntilLoadFinished();
+
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
+ g_assert(testRunner->runTest("WebKitDOMNode", "insertion", g_variant_builder_end(&builder)));
+}
+
+static void testWebKitDOMNodeTagNames(WebViewTest* test, gconstpointer)
+{
+ static const char* testHTML = "<html><head></head><body>"
+ "<video id='video' preload='none'>"
+ " <source src='movie.ogg' type='video/ogg'>"
+ " Your browser does not support the video tag."
+ "</video>"
+ "<video id='video2' preload='none'>"
+ " <source src='movie.ogg' type='video/ogg'>"
+ " Your browser does not support the video tag."
+ "</video>"
+ "<input type='hidden' id='test' name='finish' value='false'></body></html>";
+ test->loadHtml(testHTML, 0);
+ test->waitUntilLoadFinished();
+
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
+ g_assert(testRunner->runTest("WebKitDOMNode", "tag-names", g_variant_builder_end(&builder)));
+}
+
+void beforeAll()
+{
+ testRunner = new WebProcessTestRunner();
+ webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+
+ WebViewTest::add("WebKitDOMNode", "hierarchy-navigation", testWebKitDOMNodeHierarchyNavigation);
+ WebViewTest::add("WebKitDOMNode", "insertion", testWebKitDOMNodeInsertion);
+ WebViewTest::add("WebKitDOMNode", "tag-names", testWebKitDOMNodeTagNames);
+}
+
+void afterAll()
+{
+ delete testRunner;
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestDOMNodecpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestDownloadscppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestDownloadscpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,522 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 "WebKitTestServer.h"
+#include "WebViewTest.h"
+#include <glib/gstdio.h>
+#include <gtk/gtk.h>
+#include <libsoup/soup.h>
+#include <string.h>
+#include <webkit2/webkit2.h>
+#include <wtf/Vector.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+static char* kTempDirectory;
+
+class DownloadTest: public Test {
+public:
+ MAKE_GLIB_TEST_FIXTURE(DownloadTest);
+
+ enum DownloadEvent {
+ Started,
+ ReceivedResponse,
+ CreatedDestination,
+ ReceivedData,
+ Failed,
+ Finished
+ };
+
+ static void receivedResponseCallback(WebKitDownload* download, GParamSpec*, DownloadTest* test)
+ {
+ g_assert(webkit_download_get_response(download));
+ test->receivedResponse(download);
+ }
+
+ static gboolean createdDestinationCallback(WebKitDownload* download, const gchar* destination, DownloadTest* test)
+ {
+ g_assert(webkit_download_get_destination(download));
+ g_assert_cmpstr(webkit_download_get_destination(download), ==, destination);
+ test->createdDestination(download, destination);
+ return TRUE;
+ }
+
+ static gboolean receivedDataCallback(WebKitDownload* download, guint64 dataLength, DownloadTest* test)
+ {
+ test->receivedData(download, dataLength);
+ return TRUE;
+ }
+
+ static gboolean finishedCallback(WebKitDownload* download, DownloadTest* test)
+ {
+ test->finished(download);
+ return TRUE;
+ }
+
+ static gboolean failedCallback(WebKitDownload* download, GError* error, DownloadTest* test)
+ {
+ g_assert(error);
+ test->failed(download, error);
+ return TRUE;
+ }
+
+ static gboolean decideDestinationCallback(WebKitDownload* download, const gchar* suggestedFilename, DownloadTest* test)
+ {
+ g_assert(suggestedFilename);
+ test->decideDestination(download, suggestedFilename);
+ return TRUE;
+ }
+
+ static void downloadStartedCallback(WebKitWebContext* context, WebKitDownload* download, DownloadTest* test)
+ {
+ g_assert(webkit_download_get_request(download));
+ test->started(download);
+ g_signal_connect(download, "notify::response", G_CALLBACK(receivedResponseCallback), test);
+ g_signal_connect(download, "created-destination", G_CALLBACK(createdDestinationCallback), test);
+ g_signal_connect(download, "received-data", G_CALLBACK(receivedDataCallback), test);
+ g_signal_connect(download, "finished", G_CALLBACK(finishedCallback), test);
+ g_signal_connect(download, "failed", G_CALLBACK(failedCallback), test);
+ g_signal_connect(download, "decide-destination", G_CALLBACK(decideDestinationCallback), test);
+ }
+
+ DownloadTest()
+ : m_webContext(webkit_web_context_get_default())
+ , m_mainLoop(g_main_loop_new(0, TRUE))
+ , m_downloadSize(0)
+ {
+ g_signal_connect(m_webContext, "download-started", G_CALLBACK(downloadStartedCallback), this);
+ }
+
+ ~DownloadTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webContext, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ g_main_loop_unref(m_mainLoop);
+ }
+
+ virtual void started(WebKitDownload* download)
+ {
+ m_downloadEvents.append(Started);
+ }
+
+ virtual void receivedResponse(WebKitDownload* download)
+ {
+ m_downloadEvents.append(ReceivedResponse);
+ }
+
+ virtual void createdDestination(WebKitDownload* download, const char* destination)
+ {
+ m_downloadEvents.append(CreatedDestination);
+ }
+
+ virtual void receivedData(WebKitDownload* download, guint64 dataLength)
+ {
+ m_downloadSize += dataLength;
+ if (!m_downloadEvents.contains(ReceivedData))
+ m_downloadEvents.append(ReceivedData);
+ }
+
+ virtual void finished(WebKitDownload* download)
+ {
+ g_assert_cmpuint(m_downloadSize, ==, webkit_download_get_received_data_length(download));
+ m_downloadEvents.append(Finished);
+ g_main_loop_quit(m_mainLoop);
+ }
+
+ virtual void failed(WebKitDownload* download, GError* error)
+ {
+ m_downloadEvents.append(Failed);
+ }
+
+ virtual void decideDestination(WebKitDownload* download, const gchar* suggestedFilename)
+ {
+ GOwnPtr<char> destination(g_build_filename(kTempDirectory, suggestedFilename, NULL));
+ GOwnPtr<char> destinationURI(g_filename_to_uri(destination.get(), 0, 0));
+ webkit_download_set_destination(download, destinationURI.get());
+ }
+
+ WebKitDownload* downloadURIAndWaitUntilFinishes(const CString& requestURI)
+ {
+ WebKitDownload* download = webkit_web_context_download_uri(m_webContext, requestURI.data());
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download));
+
+ WebKitURIRequest* request = webkit_download_get_request(download);
+ g_assert(request);
+ ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, requestURI);
+
+ g_main_loop_run(m_mainLoop);
+
+ return download;
+ }
+
+ void checkDestinationAndDeleteFile(WebKitDownload* download, const char* expectedName)
+ {
+ if (!webkit_download_get_destination(download))
+ return;
+ GRefPtr<GFile> destFile = adoptGRef(g_file_new_for_uri(webkit_download_get_destination(download)));
+ GOwnPtr<char> destBasename(g_file_get_basename(destFile.get()));
+ g_assert_cmpstr(destBasename.get(), ==, expectedName);
+
+ g_file_delete(destFile.get(), 0, 0);
+ }
+
+ WebKitWebContext* m_webContext;
+ GMainLoop* m_mainLoop;
+ Vector<DownloadEvent> m_downloadEvents;
+ guint64 m_downloadSize;
+};
+
+static void testDownloadLocalFile(DownloadTest* test, gconstpointer)
+{
+ GOwnPtr<char> sourcePath(g_build_filename(Test::getWebKit1TestResoucesDir().data(), "test.pdf", NULL));
+ GRefPtr<GFile> source = adoptGRef(g_file_new_for_path(sourcePath.get()));
+ GRefPtr<GFileInfo> sourceInfo = adoptGRef(g_file_query_info(source.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE, static_cast<GFileQueryInfoFlags>(0), 0, 0));
+ GOwnPtr<char> sourceURI(g_file_get_uri(source.get()));
+ GRefPtr<WebKitDownload> download = adoptGRef(test->downloadURIAndWaitUntilFinishes(sourceURI.get()));
+ g_assert(!webkit_download_get_web_view(download.get()));
+
+ Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents;
+ g_assert_cmpint(events.size(), ==, 5);
+ g_assert_cmpint(events[0], ==, DownloadTest::Started);
+ g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse);
+ g_assert_cmpint(events[2], ==, DownloadTest::CreatedDestination);
+ g_assert_cmpint(events[3], ==, DownloadTest::ReceivedData);
+ g_assert_cmpint(events[4], ==, DownloadTest::Finished);
+
+ WebKitURIRequest* request = webkit_download_get_request(download.get());
+ g_assert(request);
+ g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, sourceURI.get());
+
+ g_assert_cmpint(test->m_downloadSize, ==, g_file_info_get_size(sourceInfo.get()));
+ g_assert(webkit_download_get_destination(download.get()));
+ g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), ==, 1);
+ test->checkDestinationAndDeleteFile(download.get(), "test.pdf");
+}
+
+class DownloadErrorTest: public DownloadTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(DownloadErrorTest);
+
+ DownloadErrorTest()
+ : m_expectedError(WEBKIT_DOWNLOAD_ERROR_NETWORK)
+ {
+ }
+
+ void receivedResponse(WebKitDownload* download)
+ {
+ DownloadTest::receivedResponse(download);
+ if (m_expectedError == WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER)
+ webkit_download_cancel(download);
+ }
+
+ void createdDestination(WebKitDownload* download, const char* destination)
+ {
+ g_assert_not_reached();
+ }
+
+ void failed(WebKitDownload* download, GError* error)
+ {
+ g_assert(g_error_matches(error, WEBKIT_DOWNLOAD_ERROR, m_expectedError));
+ DownloadTest::failed(download, error);
+ }
+
+ void decideDestination(WebKitDownload* download, const gchar* suggestedFilename)
+ {
+ if (m_expectedError != WEBKIT_DOWNLOAD_ERROR_DESTINATION) {
+ DownloadTest::decideDestination(download, suggestedFilename);
+ return;
+ }
+ webkit_download_set_destination(download, "file:///foo/bar");
+ }
+
+ WebKitDownloadError m_expectedError;
+};
+
+static void testDownloadLocalFileError(DownloadErrorTest* test, gconstpointer)
+{
+ test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_NETWORK;
+ GRefPtr<WebKitDownload> download = adoptGRef(test->downloadURIAndWaitUntilFinishes("file:///foo/bar"));
+ g_assert(!webkit_download_get_web_view(download.get()));
+
+ Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents;
+ g_assert_cmpint(events.size(), ==, 3);
+ g_assert_cmpint(events[0], ==, DownloadTest::Started);
+ g_assert_cmpint(events[1], ==, DownloadTest::Failed);
+ g_assert_cmpint(events[2], ==, DownloadTest::Finished);
+ events.clear();
+ g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1);
+
+ test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_DESTINATION;
+ GOwnPtr<char> path(g_build_filename(Test::getWebKit1TestResoucesDir().data(), "test.pdf", NULL));
+ GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(path.get()));
+ GOwnPtr<char> uri(g_file_get_uri(file.get()));
+ download = adoptGRef(test->downloadURIAndWaitUntilFinishes(uri.get()));
+ g_assert(!webkit_download_get_web_view(download.get()));
+
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, DownloadTest::Started);
+ g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse);
+ g_assert_cmpint(events[2], ==, DownloadTest::Failed);
+ g_assert_cmpint(events[3], ==, DownloadTest::Finished);
+ events.clear();
+ g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1);
+ test->checkDestinationAndDeleteFile(download.get(), "bar");
+
+ test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER;
+ download = adoptGRef(test->downloadURIAndWaitUntilFinishes(uri.get()));
+ g_assert(!webkit_download_get_web_view(download.get()));
+
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, DownloadTest::Started);
+ g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse);
+ g_assert_cmpint(events[2], ==, DownloadTest::Failed);
+ g_assert_cmpint(events[3], ==, DownloadTest::Finished);
+ events.clear();
+ g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1);
+ test->checkDestinationAndDeleteFile(download.get(), "test.pdf");
+}
+
+static WebKitTestServer* kServer;
+static const char* kServerSuggestedFilename = "webkit-downloaded-file";
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ GOwnPtr<char> filePath(g_build_filename(Test::getWebKit1TestResoucesDir().data(), path, NULL));
+ char* contents;
+ gsize contentsLength;
+ if (!g_file_get_contents(filePath.get(), &contents, &contentsLength, 0)) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+ soup_message_body_complete(message->response_body);
+ return;
+ }
+
+ soup_message_set_status(message, SOUP_STATUS_OK);
+
+ GOwnPtr<char> contentDisposition(g_strdup_printf("filename=%s", kServerSuggestedFilename));
+ soup_message_headers_append(message->response_headers, "Content-Disposition", contentDisposition.get());
+ soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, contentsLength);
+
+ soup_message_body_complete(message->response_body);
+}
+
+static void testDownloadRemoteFile(DownloadTest* test, gconstpointer)
+{
+ GRefPtr<WebKitDownload> download = adoptGRef(test->downloadURIAndWaitUntilFinishes(kServer->getURIForPath("/test.pdf")));
+ g_assert(!webkit_download_get_web_view(download.get()));
+
+ Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents;
+ g_assert_cmpint(events.size(), ==, 5);
+ g_assert_cmpint(events[0], ==, DownloadTest::Started);
+ g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse);
+ g_assert_cmpint(events[2], ==, DownloadTest::CreatedDestination);
+ g_assert_cmpint(events[3], ==, DownloadTest::ReceivedData);
+ g_assert_cmpint(events[4], ==, DownloadTest::Finished);
+ events.clear();
+
+ WebKitURIRequest* request = webkit_download_get_request(download.get());
+ g_assert(request);
+ ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, kServer->getURIForPath("/test.pdf"));
+
+ g_assert(webkit_download_get_destination(download.get()));
+ g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), ==, 1);
+ test->checkDestinationAndDeleteFile(download.get(), kServerSuggestedFilename);
+}
+
+static void testDownloadRemoteFileError(DownloadErrorTest* test, gconstpointer)
+{
+ test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_NETWORK;
+ GRefPtr<WebKitDownload> download = adoptGRef(test->downloadURIAndWaitUntilFinishes(kServer->getURIForPath("/foo")));
+ g_assert(!webkit_download_get_web_view(download.get()));
+
+ Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents;
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, DownloadTest::Started);
+ g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse);
+ g_assert_cmpint(events[2], ==, DownloadTest::Failed);
+ g_assert_cmpint(events[3], ==, DownloadTest::Finished);
+ events.clear();
+ WebKitURIResponse* response = webkit_download_get_response(download.get());
+ g_assert_cmpuint(webkit_uri_response_get_status_code(response), ==, 404);
+ g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1);
+
+ test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_DESTINATION;
+ download = adoptGRef(test->downloadURIAndWaitUntilFinishes(kServer->getURIForPath("/test.pdf")));
+ g_assert(!webkit_download_get_web_view(download.get()));
+
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, DownloadTest::Started);
+ g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse);
+ g_assert_cmpint(events[2], ==, DownloadTest::Failed);
+ g_assert_cmpint(events[3], ==, DownloadTest::Finished);
+ events.clear();
+ g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1);
+ test->checkDestinationAndDeleteFile(download.get(), "bar");
+
+ test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER;
+ download = adoptGRef(test->downloadURIAndWaitUntilFinishes(kServer->getURIForPath("/test.pdf")));
+ g_assert(!webkit_download_get_web_view(download.get()));
+
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, DownloadTest::Started);
+ g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse);
+ g_assert_cmpint(events[2], ==, DownloadTest::Failed);
+ g_assert_cmpint(events[3], ==, DownloadTest::Finished);
+ events.clear();
+ g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1);
+ test->checkDestinationAndDeleteFile(download.get(), kServerSuggestedFilename);
+}
+
+class WebViewDownloadTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(WebViewDownloadTest);
+
+ static void downloadStartedCallback(WebKitWebContext* context, WebKitDownload* download, WebViewDownloadTest* test)
+ {
+ test->m_download = download;
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download));
+ test->quitMainLoop();
+ }
+
+ WebViewDownloadTest()
+ {
+ g_signal_connect(webkit_web_view_get_context(m_webView), "download-started", G_CALLBACK(downloadStartedCallback), this);
+ }
+
+ ~WebViewDownloadTest()
+ {
+ g_signal_handlers_disconnect_matched(webkit_web_view_get_context(m_webView), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void waitUntilDownloadStarted()
+ {
+ m_download = 0;
+ g_main_loop_run(m_mainLoop);
+ g_assert(m_download.get());
+ }
+
+ static gboolean downloadDecideDestinationCallback(WebKitDownload* download, const gchar* suggestedFilename, WebViewDownloadTest* test)
+ {
+ GOwnPtr<char> destination(g_build_filename(kTempDirectory, suggestedFilename, NULL));
+ GOwnPtr<char> destinationURI(g_filename_to_uri(destination.get(), 0, 0));
+ webkit_download_set_destination(download, destinationURI.get());
+ return TRUE;
+ }
+
+ static void downloadFinishedCallback(WebKitDownload* download, WebViewDownloadTest* test)
+ {
+ test->quitMainLoop();
+ }
+
+ void waitUntilDownloadFinished()
+ {
+ g_signal_connect(m_download.get(), "decide-destination", G_CALLBACK(downloadDecideDestinationCallback), this);
+ g_signal_connect(m_download.get(), "finished", G_CALLBACK(downloadFinishedCallback), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ GRefPtr<WebKitDownload> m_download;
+};
+
+static void testWebViewDownloadURI(WebViewDownloadTest* test, gconstpointer)
+{
+ GRefPtr<WebKitDownload> download = adoptGRef(webkit_web_view_download_uri(test->m_webView, kServer->getURIForPath("/test.pdf").data()));
+ test->waitUntilDownloadStarted();
+ g_assert(test->m_webView == webkit_download_get_web_view(download.get()));
+ test->waitUntilDownloadFinished();
+
+ GRefPtr<GFile> downloadFile = adoptGRef(g_file_new_for_uri(webkit_download_get_destination(download.get())));
+ GRefPtr<GFileInfo> downloadFileInfo = adoptGRef(g_file_query_info(downloadFile.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE, static_cast<GFileQueryInfoFlags>(0), 0, 0));
+ g_assert_cmpint(g_file_info_get_size(downloadFileInfo.get()), >, 0);
+ g_file_delete(downloadFile.get(), 0, 0);
+}
+
+class PolicyResponseDownloadTest: public WebViewDownloadTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(PolicyResponseDownloadTest);
+
+ static gboolean decidePolicyCallback(WebKitWebView* webView, WebKitPolicyDecision* decision, WebKitPolicyDecisionType type, PolicyResponseDownloadTest* test)
+ {
+ if (type != WEBKIT_POLICY_DECISION_TYPE_RESPONSE)
+ return FALSE;
+
+ webkit_policy_decision_download(decision);
+ return TRUE;
+ }
+
+ PolicyResponseDownloadTest()
+ {
+ g_signal_connect(m_webView, "decide-policy", G_CALLBACK(decidePolicyCallback), this);
+ }
+
+ ~PolicyResponseDownloadTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void cancelDownloadAndWaitUntilFinished()
+ {
+ webkit_download_cancel(m_download.get());
+ waitUntilDownloadFinished();
+ m_download = 0;
+ }
+};
+
+static void testPolicyResponseDownload(PolicyResponseDownloadTest* test, gconstpointer)
+{
+ // Test that a download started by the the policy checker contains the web view.
+ CString requestURI = kServer->getURIForPath("/test.pdf").data();
+ test->loadURI(requestURI.data());
+ test->waitUntilDownloadStarted();
+
+ WebKitURIRequest* request = webkit_download_get_request(test->m_download.get());
+ g_assert(request);
+ ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, requestURI);
+
+ g_assert(test->m_webView == webkit_download_get_web_view(test->m_download.get()));
+ test->cancelDownloadAndWaitUntilFinished();
+}
+
+void beforeAll()
+{
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0);
+ g_assert(kTempDirectory);
+
+ DownloadTest::add("Downloads", "local-file", testDownloadLocalFile);
+ DownloadErrorTest::add("Downloads", "local-file-error", testDownloadLocalFileError);
+ DownloadTest::add("Downloads", "remote-file", testDownloadRemoteFile);
+ DownloadErrorTest::add("Downloads", "remote-file-error", testDownloadRemoteFileError);
+ WebViewDownloadTest::add("WebKitWebView", "download-uri", testWebViewDownloadURI);
+ PolicyResponseDownloadTest::add("Downloads", "policy-decision-download", testPolicyResponseDownload);
+}
+
+void afterAll()
+{
+ delete kServer;
+ g_rmdir(kTempDirectory);
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestDownloadscpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestFramecppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestFramecpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestFrame.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * 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,1 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 "WebProcessTestRunner.h"
+#include "WebViewTest.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+static WebProcessTestRunner* testRunner;
+
+static void webkitFrameTestRun(WebViewTest* test, const char* testName)
+{
+ static const char* testHTML = "<html><body></body></html>";
+ test->loadHtml(testHTML, 0);
+ test->waitUntilLoadFinished();
+
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
+ g_assert(testRunner->runTest("WebKitFrame", testName, g_variant_builder_end(&builder)));
+}
+
+static void testWebKitFrameMainFrame(WebViewTest* test, gconstpointer)
+{
+ webkitFrameTestRun(test, "main-frame");
+}
+
+static void testWebKitFrameURI(WebViewTest* test, gconstpointer)
+{
+ webkitFrameTestRun(test, "uri");
+}
+
+static void testWebKitFrameJavaScriptContext(WebViewTest* test, gconstpointer)
+{
+ webkitFrameTestRun(test, "javascript-context");
+}
+
+void beforeAll()
+{
+ testRunner = new WebProcessTestRunner();
+ webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+
+ WebViewTest::add("WebKitFrame", "main-frame", testWebKitFrameMainFrame);
+ WebViewTest::add("WebKitFrame", "uri", testWebKitFrameURI);
+ WebViewTest::add("WebKitFrame", "javascript-context", testWebKitFrameJavaScriptContext);
+}
+
+void afterAll()
+{
+ delete testRunner;
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestFramecpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestInspectorcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestInspectorcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspector.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspector.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspector.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,356 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 "WebViewTest.h"
+#include <wtf/Vector.h>
+#include <wtf/gobject/GRefPtr.h>
+
+class InspectorTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(InspectorTest);
+
+ enum InspectorEvents {
+ OpenWindow,
+ BringToFront,
+ Closed,
+ Attach,
+ Detach
+ };
+
+ static gboolean openWindowCallback(WebKitWebInspector*, InspectorTest* test)
+ {
+ return test->openWindow();
+ }
+
+ static gboolean bringToFrontCallback(WebKitWebInspector*, InspectorTest* test)
+ {
+ return test->bringToFront();
+ }
+
+ static void closedCallback(WebKitWebInspector*, InspectorTest* test)
+ {
+ return test->closed();
+ }
+
+ static gboolean attachCallback(WebKitWebInspector*, InspectorTest* test)
+ {
+ return test->attach();
+ }
+
+ static gboolean detachCallback(WebKitWebInspector*, InspectorTest* test)
+ {
+ return test->detach();
+ }
+
+ static const unsigned gMinimumAttachedInspectorWidth = 750;
+ static const unsigned gMinimumAttachedInspectorHeight = 250;
+
+ InspectorTest()
+ : WebViewTest()
+ , m_inspector(webkit_web_view_get_inspector(m_webView))
+ {
+ webkit_settings_set_enable_developer_extras(webkit_web_view_get_settings(m_webView), TRUE);
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_inspector));
+ g_signal_connect(m_inspector, "open-window", G_CALLBACK(openWindowCallback), this);
+ g_signal_connect(m_inspector, "bring-to-front", G_CALLBACK(bringToFrontCallback), this);
+ g_signal_connect(m_inspector, "closed", G_CALLBACK(closedCallback), this);
+ g_signal_connect(m_inspector, "attach", G_CALLBACK(attachCallback), this);
+ g_signal_connect(m_inspector, "detach", G_CALLBACK(detachCallback), this);
+ }
+
+ ~InspectorTest()
+ {
+ g_signal_handlers_disconnect_matched(m_inspector, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ virtual bool openWindow()
+ {
+ m_events.append(OpenWindow);
+ g_main_loop_quit(m_mainLoop);
+ return TRUE;
+ }
+
+ virtual bool bringToFront()
+ {
+ m_events.append(BringToFront);
+ g_main_loop_quit(m_mainLoop);
+ return FALSE;
+ }
+
+ virtual void closed()
+ {
+ m_events.append(Closed);
+ }
+
+ virtual bool attach()
+ {
+ m_events.append(Attach);
+ return TRUE;
+ }
+
+ virtual bool detach()
+ {
+ m_events.append(Detach);
+ return TRUE;
+ }
+
+
+ static gboolean showIdle(InspectorTest* test)
+ {
+ webkit_web_inspector_show(test->m_inspector);
+ return FALSE;
+ }
+
+ void show()
+ {
+ g_idle_add(reinterpret_cast<GSourceFunc>(showIdle), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ void resizeViewAndAttach()
+ {
+ // Resize the view to make room for the inspector.
+ resizeView(gMinimumAttachedInspectorWidth, (gMinimumAttachedInspectorHeight + 1) * 4 / 3);
+ webkit_web_inspector_attach(m_inspector);
+ }
+
+ static gboolean detachIdle(InspectorTest* test)
+ {
+ webkit_web_inspector_detach(test->m_inspector);
+ return FALSE;
+ }
+
+ void detachAndWaitUntilWindowOpened()
+ {
+ g_idle_add(reinterpret_cast<GSourceFunc>(detachIdle), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ void close()
+ {
+ webkit_web_inspector_close(m_inspector);
+ }
+
+ WebKitWebInspector* m_inspector;
+ Vector<InspectorEvents> m_events;
+};
+
+static void testInspectorDefault(InspectorTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+ test->resizeView(200, 200);
+ test->loadHtml("<html><body><p>WebKitGTK+ Inspector test</p></body></html>", 0);
+ test->waitUntilLoadFinished();
+
+ test->show();
+ // We don't add the view to a container, so consume the weak ref with GRefPtr.
+ GRefPtr<WebKitWebViewBase> inspectorView = webkit_web_inspector_get_web_view(test->m_inspector);
+ g_assert(inspectorView.get());
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inspectorView.get()));
+ g_assert(!webkit_web_inspector_is_attached(test->m_inspector));
+ g_assert_cmpuint(webkit_web_inspector_get_attached_height(test->m_inspector), ==, 0);
+ Vector<InspectorTest::InspectorEvents>& events = test->m_events;
+ g_assert_cmpint(events.size(), ==, 1);
+ g_assert_cmpint(events[0], ==, InspectorTest::OpenWindow);
+ test->m_events.clear();
+
+ test->show();
+ events = test->m_events;
+ g_assert_cmpint(events.size(), ==, 1);
+ g_assert_cmpint(events[0], ==, InspectorTest::BringToFront);
+ test->m_events.clear();
+
+ test->resizeViewAndAttach();
+ g_assert(webkit_web_inspector_is_attached(test->m_inspector));
+ g_assert_cmpuint(webkit_web_inspector_get_attached_height(test->m_inspector), >=, InspectorTest::gMinimumAttachedInspectorHeight);
+ events = test->m_events;
+ g_assert_cmpint(events.size(), ==, 1);
+ g_assert_cmpint(events[0], ==, InspectorTest::Attach);
+ test->m_events.clear();
+
+ test->detachAndWaitUntilWindowOpened();
+ g_assert(!webkit_web_inspector_is_attached(test->m_inspector));
+ events = test->m_events;
+ g_assert_cmpint(events.size(), ==, 2);
+ g_assert_cmpint(events[0], ==, InspectorTest::Detach);
+ g_assert_cmpint(events[1], ==, InspectorTest::OpenWindow);
+ test->m_events.clear();
+
+ test->close();
+ events = test->m_events;
+ g_assert_cmpint(events.size(), ==, 1);
+ g_assert_cmpint(events[0], ==, InspectorTest::Closed);
+ test->m_events.clear();
+}
+
+class CustomInspectorTest: public InspectorTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(CustomInspectorTest);
+
+ CustomInspectorTest()
+ : InspectorTest()
+ , m_inspectorWindow(0)
+ {
+ }
+
+ ~CustomInspectorTest()
+ {
+ if (m_inspectorWindow)
+ gtk_widget_destroy(m_inspectorWindow);
+ }
+
+ bool openWindow()
+ {
+ g_assert(!m_inspectorWindow);
+ m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ WebKitWebViewBase* inspectorView = webkit_web_inspector_get_web_view(m_inspector);
+ g_assert(inspectorView);
+ gtk_container_add(GTK_CONTAINER(m_inspectorWindow), GTK_WIDGET(inspectorView));
+ gtk_widget_show_all(m_inspectorWindow);
+
+ return InspectorTest::openWindow();
+ }
+
+ void closed()
+ {
+ if (m_inspectorWindow) {
+ gtk_widget_destroy(m_inspectorWindow);
+ m_inspectorWindow = 0;
+ }
+
+ return InspectorTest::closed();
+ }
+
+ bool attach()
+ {
+ GRefPtr<WebKitWebViewBase> inspectorView = webkit_web_inspector_get_web_view(m_inspector);
+ if (m_inspectorWindow) {
+ gtk_container_remove(GTK_CONTAINER(m_inspectorWindow), GTK_WIDGET(inspectorView.get()));
+ gtk_widget_destroy(m_inspectorWindow);
+ m_inspectorWindow = 0;
+ }
+
+ GtkWidget* pane;
+ if (gtk_bin_get_child(GTK_BIN(m_parentWindow)) == GTK_WIDGET(m_webView)) {
+ GRefPtr<WebKitWebView> inspectedView = m_webView;
+ gtk_container_remove(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
+ pane = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
+ gtk_paned_add1(GTK_PANED(pane), GTK_WIDGET(m_webView));
+ gtk_container_add(GTK_CONTAINER(m_parentWindow), pane);
+ gtk_widget_show_all(pane);
+ } else
+ pane = gtk_bin_get_child(GTK_BIN(m_parentWindow));
+ gtk_paned_set_position(GTK_PANED(pane), webkit_web_inspector_get_attached_height(m_inspector));
+ gtk_paned_add2(GTK_PANED(pane), GTK_WIDGET(inspectorView.get()));
+
+ return InspectorTest::attach();
+ }
+
+ bool detach()
+ {
+ GRefPtr<WebKitWebViewBase> inspectorView = webkit_web_inspector_get_web_view(m_inspector);
+ GtkWidget* pane = gtk_bin_get_child(GTK_BIN(m_parentWindow));
+ g_assert(GTK_IS_PANED(pane));
+ gtk_container_remove(GTK_CONTAINER(pane), GTK_WIDGET(inspectorView.get()));
+ return InspectorTest::detach();
+ }
+
+ void destroyWindow()
+ {
+ g_assert(m_inspectorWindow);
+ gtk_widget_destroy(m_inspectorWindow);
+ m_inspectorWindow = 0;
+ }
+
+ GtkWidget* m_inspectorWindow;
+};
+
+static void testInspectorManualAttachDetach(CustomInspectorTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+ test->resizeView(200, 200);
+ test->loadHtml("<html><body><p>WebKitGTK+ Inspector test</p></body></html>", 0);
+ test->waitUntilLoadFinished();
+
+ test->show();
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webkit_web_inspector_get_web_view(test->m_inspector)));
+ g_assert(!webkit_web_inspector_is_attached(test->m_inspector));
+ Vector<InspectorTest::InspectorEvents>& events = test->m_events;
+ g_assert_cmpint(events.size(), ==, 1);
+ g_assert_cmpint(events[0], ==, InspectorTest::OpenWindow);
+ test->m_events.clear();
+
+ test->resizeViewAndAttach();
+ g_assert(webkit_web_inspector_is_attached(test->m_inspector));
+ g_assert_cmpuint(webkit_web_inspector_get_attached_height(test->m_inspector), >=, InspectorTest::gMinimumAttachedInspectorHeight);
+ events = test->m_events;
+ g_assert_cmpint(events.size(), ==, 1);
+ g_assert_cmpint(events[0], ==, InspectorTest::Attach);
+ test->m_events.clear();
+
+ test->detachAndWaitUntilWindowOpened();
+ g_assert(!webkit_web_inspector_is_attached(test->m_inspector));
+ events = test->m_events;
+ g_assert_cmpint(events.size(), ==, 2);
+ g_assert_cmpint(events[0], ==, InspectorTest::Detach);
+ g_assert_cmpint(events[1], ==, InspectorTest::OpenWindow);
+ test->m_events.clear();
+
+ test->resizeViewAndAttach();
+ g_assert(webkit_web_inspector_is_attached(test->m_inspector));
+ test->m_events.clear();
+ test->close();
+ events = test->m_events;
+ g_assert_cmpint(events.size(), ==, 2);
+ g_assert_cmpint(events[0], ==, InspectorTest::Detach);
+ g_assert_cmpint(events[1], ==, InspectorTest::Closed);
+ test->m_events.clear();
+}
+
+static void testInspectorCustomContainerDestroyed(CustomInspectorTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+ test->resizeView(200, 200);
+ test->loadHtml("<html><body><p>WebKitGTK+ Inspector test</p></body></html>", 0);
+ test->waitUntilLoadFinished();
+
+ test->show();
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webkit_web_inspector_get_web_view(test->m_inspector)));
+ g_assert(!webkit_web_inspector_is_attached(test->m_inspector));
+
+ test->m_events.clear();
+ test->destroyWindow();
+ Vector<InspectorTest::InspectorEvents>& events = test->m_events;
+ g_assert_cmpint(events.size(), ==, 1);
+ g_assert_cmpint(events[0], ==, InspectorTest::Closed);
+ test->m_events.clear();
+}
+
+void beforeAll()
+{
+ InspectorTest::add("WebKitWebInspector", "default", testInspectorDefault);
+ CustomInspectorTest::add("WebKitWebInspector", "manual-attach-detach", testInspectorManualAttachDetach);
+ CustomInspectorTest::add("WebKitWebInspector", "custom-container-destroyed", testInspectorCustomContainerDestroyed);
+}
+
+void afterAll()
+{
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestInspectorcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspector.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestInspectorServercppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestInspectorServercpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspectorServer.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestInspectorServer.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspectorServer.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspectorServer.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,294 @@
</span><ins>+/*
+ * Copyright (C) 2012 Samsung Electronics Ltd. All Rights Reserved.
+ *
+ * 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "WebViewTest.h"
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/WTFString.h>
+
+// Name of the test server application creating the webView object.
+static const char* gTestServerAppName = "InspectorTestServer";
+
+// Max seconds to wait for the test server before inspecting it.
+static const int gMaxWaitForChild = 5;
+
+// The PID for the test server running, so we can kill it if needed.
+static GPid gChildProcessPid = 0;
+
+// Whether the child has replied and it's ready.
+static bool gChildIsReady = false;
+
+static void stopTestServer()
+{
+ // Do nothing if there's no server running.
+ if (!gChildProcessPid)
+ return;
+
+ g_spawn_close_pid(gChildProcessPid);
+ kill(gChildProcessPid, SIGTERM);
+ gChildProcessPid = 0;
+}
+
+static void sigAbortHandler(int sigNum)
+{
+ // Just stop the test server if SIGABRT was received.
+ stopTestServer();
+}
+
+static gpointer testServerMonitorThreadFunc(gpointer)
+{
+ // Wait for the specified timeout to happen.
+ g_usleep(gMaxWaitForChild * G_USEC_PER_SEC);
+
+ // Kill the child process if not ready yet.
+ if (!gChildIsReady)
+ stopTestServer();
+
+ g_thread_exit(0);
+ return 0;
+}
+
+static void startTestServerMonitor()
+{
+ gChildIsReady = false;
+ g_thread_new("TestServerMonitor", testServerMonitorThreadFunc, 0);
+}
+
+static void startTestServer()
+{
+ // Prepare argv[] for spawning the server process.
+ GOwnPtr<char> testServerPath(g_build_filename(WEBKIT_EXEC_PATH, "TestWebKitAPI", "WebKit2Gtk", gTestServerAppName, NULL));
+
+ // We install a handler to ensure that we kill the child process
+ // if the parent dies because of whatever the reason is.
+ signal(SIGABRT, sigAbortHandler);
+
+ char* testServerArgv[2];
+ testServerArgv[0] = testServerPath.get();
+ testServerArgv[1] = 0;
+
+ // Spawn the server, getting its stdout file descriptor to set a
+ // communication channel, so we know when it's ready.
+ int childStdout = 0;
+ g_assert(g_spawn_async_with_pipes(0, testServerArgv, 0, static_cast<GSpawnFlags>(0), 0, 0,
+ &gChildProcessPid, 0, &childStdout, 0, 0));
+
+ // Start monitoring the test server (in a separate thread) to
+ // ensure we don't block on the child process more than a timeout.
+ startTestServerMonitor();
+
+ char msg[2];
+ GIOChannel* ioChannel = g_io_channel_unix_new(childStdout);
+ if (g_io_channel_read_chars(ioChannel, msg, 2, 0, 0) == G_IO_STATUS_NORMAL) {
+ // Check whether the server sent a message saying it's ready
+ // and store the result globally, so the monitor can see it.
+ gChildIsReady = msg[0] == 'O' && msg[1] == 'K';
+ }
+ g_io_channel_unref(ioChannel);
+ close(childStdout);
+
+ // The timeout was reached and the server is not ready yet, so
+ // stop it inmediately, and let the unit tests fail.
+ if (!gChildIsReady)
+ stopTestServer();
+}
+
+class InspectorServerTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(InspectorServerTest);
+
+ InspectorServerTest()
+ : WebViewTest()
+ {
+ }
+
+ bool getPageList()
+ {
+ loadHtml("<script type=\"text/javascript\">\n"
+ "var pages;\n"
+ "var xhr = new XMLHttpRequest;\n"
+ "xhr.open(\"GET\", \"/pagelist.json\");\n"
+ "xhr.onload = function(e) {\n"
+ "if (xhr.status == 200) {\n"
+ "pages = JSON.parse(xhr.responseText);\n"
+ "document.title = \"OK\";\n"
+ "} else \n"
+ "document.title = \"FAIL\";\n"
+ "}\n"
+ "xhr.send();\n"
+ "</script>\n",
+ "http://127.0.0.1:2999/");
+
+ waitUntilTitleChanged();
+
+ if (!strcmp(webkit_web_view_get_title(m_webView), "OK"))
+ return true;
+
+ return false;
+ }
+
+ ~InspectorServerTest()
+ {
+ }
+};
+
+// Test to get inspector server page list from the test server.
+// Should contain only one entry pointing to http://127.0.0.1:2999/webinspector/Main.html?page=1
+static void testInspectorServerPageList(InspectorServerTest* test, gconstpointer)
+{
+ GOwnPtr<GError> error;
+
+ test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+ g_assert(test->getPageList());
+
+ WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("pages.length;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ g_assert_cmpint(WebViewTest::javascriptResultToNumber(javascriptResult), ==, 1);
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("pages[0].id;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ int pageId = WebViewTest::javascriptResultToNumber(javascriptResult);
+
+ GOwnPtr<char> valueString;
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("pages[0].url;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "http://127.0.0.1:2999/");
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("pages[0].inspectorUrl;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
+ String validInspectorURL = String("/Main.html?page=") + String::number(pageId);
+ ASSERT_CMP_CSTRING(valueString.get(), ==, validInspectorURL.utf8());
+}
+
+// Test sending a raw remote debugging message through our web socket server.
+// For this specific message see: http://code.google.com/chrome/devtools/docs/protocol/tot/runtime.html#command-evaluate
+static void testRemoteDebuggingMessage(InspectorServerTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+
+ test->loadHtml("<script type=\"text/javascript\">\n"
+ "var socket = new WebSocket('ws://127.0.0.1:2999/devtools/page/1');\n"
+ "socket.onmessage = function(message) {\n"
+ "var response = JSON.parse(message.data);\n"
+ "if (response.id === 1)\n"
+ "document.title = response.result.result.value;\n"
+ "else\n"
+ "document.title = \"FAIL\";\n"
+ "}\n"
+ "socket.onopen = function() {\n"
+ "socket.send('{\"id\": 1, \"method\": \"Runtime.evaluate\", \"params\": {\"expression\": \"2 + 2\" } }');\n"
+ "}\n"
+ "</script>",
+ "http://127.0.0.1:2999/");
+ test->waitUntilTitleChanged();
+
+ g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, "4");
+}
+
+static void openRemoteDebuggingSession(InspectorServerTest* test, gconstpointer)
+{
+ // To test the whole pipeline this exploits a behavior of the inspector front-end which won't provide the page address as title unless the
+ // debugging session was established correctly through web socket.
+ // In our case page URL should be http://127.0.0.1:2999/
+ // So this test case will fail if:
+ // - The page list didn't return a valid inspector URL
+ // - Or the front-end couldn't be loaded through the inspector HTTP server
+ // - Or the web socket connection couldn't be established between the front-end and the page through the inspector server
+ // Let's see if this test isn't raising too many false positives, in which case we should use a better predicate if available.
+
+ test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+
+ g_assert(test->getPageList());
+
+ GOwnPtr<GError> error;
+ WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("pages[0].inspectorUrl;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+
+ String resolvedURL = String("http://127.0.0.1:2999/") + String::fromUTF8(WebViewTest::javascriptResultToCString(javascriptResult));
+ test->loadURI(resolvedURL.utf8().data());
+ test->waitUntilLoadFinished();
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.document.getElementsByTagName('li')[0].title", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+
+ GOwnPtr<char> title(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(title.get(), ==, "http://127.0.0.1:2999/");
+}
+
+static void sendIncompleteRequest(InspectorServerTest* test, gconstpointer)
+{
+ GOwnPtr<GError> error;
+
+ // Connect to the inspector server.
+ GRefPtr<GSocketClient> client = adoptGRef(g_socket_client_new());
+ GRefPtr<GSocketConnection> connection = adoptGRef(g_socket_client_connect_to_host(client.get(), "127.0.0.1", 2999, 0, &error.outPtr()));
+ g_assert_no_error(error.get());
+
+ // Send incomplete request (missing blank line after headers) and check if inspector server
+ // replies. The server should not reply to an incomplete request and the test should timeout
+ // on read.
+ GOutputStream* ostream = g_io_stream_get_output_stream(G_IO_STREAM(connection.get()));
+ // Request missing blank line after headers.
+ const gchar* incompleteRequest = "GET /devtools/page/1 HTTP/1.1\r\nHost: Localhost\r\n";
+ g_output_stream_write(ostream, incompleteRequest, strlen(incompleteRequest), 0, &error.outPtr());
+ g_assert_no_error(error.get());
+
+ GInputStream* istream = g_io_stream_get_input_stream(G_IO_STREAM(connection.get()));
+ char response[16];
+ memset(response, 0, sizeof(response));
+ GRefPtr<GCancellable> cancel = adoptGRef(g_cancellable_new());
+ g_input_stream_read_async(istream, response, sizeof(response) - 1, G_PRIORITY_DEFAULT, cancel.get(), 0, 0);
+ // Give a chance for the server to reply.
+ test->wait(1);
+ g_cancellable_cancel(cancel.get());
+ // If we got any answer it means the server replied to an incomplete request, lets fail.
+ g_assert(response[0] == '\0');
+}
+
+void beforeAll()
+{
+ // Overwrite WEBKIT_INSPECTOR_SERVER variable with default IP address but different port to avoid conflict with the test inspector server page.
+ g_setenv("WEBKIT_INSPECTOR_SERVER", "127.0.0.1:2998", TRUE);
+
+ startTestServer();
+ InspectorServerTest::add("WebKitWebInspectorServer", "test-page-list", testInspectorServerPageList);
+ InspectorServerTest::add("WebKitWebInspectorServer", "test-remote-debugging-message", testRemoteDebuggingMessage);
+ InspectorServerTest::add("WebKitWebInspectorServer", "test-open-debugging-session", openRemoteDebuggingSession);
+ InspectorServerTest::add("WebKitWebInspectorServer", "test-incomplete-request", sendIncompleteRequest);
+
+}
+
+void afterAll()
+{
+ stopTestServer();
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestInspectorServercpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestInspectorServer.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestLoaderClientcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestLoaderClientcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,465 @@
</span><ins>+/*
+ * Copyright (C) 2009, 2010 Gustavo Noronha Silva
+ * Copyright (C) 2009, 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
+ *
+ * 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 "LoadTrackingTest.h"
+#include "WebKitTestBus.h"
+#include "WebKitTestServer.h"
+#include "WebViewTest.h"
+#include <gtk/gtk.h>
+#include <libsoup/soup.h>
+#include <wtf/text/CString.h>
+
+static WebKitTestBus* bus;
+static WebKitTestServer* kServer;
+
+const char* kDNTHeaderNotPresent = "DNT header not present";
+
+static void testLoadingStatus(LoadTrackingTest* test, gconstpointer data)
+{
+ test->setRedirectURI(kServer->getURIForPath("/normal").data());
+ test->loadURI(kServer->getURIForPath("/redirect").data());
+ test->waitUntilLoadFinished();
+
+ Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents;
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(events[1], ==, LoadTrackingTest::ProvisionalLoadReceivedServerRedirect);
+ g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(events[3], ==, LoadTrackingTest::LoadFinished);
+}
+
+static void testLoadingError(LoadTrackingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/error").data());
+ test->waitUntilLoadFinished();
+
+ Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents;
+ g_assert_cmpint(events.size(), ==, 3);
+ g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(events[1], ==, LoadTrackingTest::ProvisionalLoadFailed);
+ g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadFinished);
+}
+
+static void assertNormalLoadHappened(Vector<LoadTrackingTest::LoadEvents>& events)
+{
+ g_assert_cmpint(events.size(), ==, 3);
+ g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(events[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadFinished);
+}
+
+static void testLoadHtml(LoadTrackingTest* test, gconstpointer)
+{
+ test->loadHtml("<html><body>Hello WebKit-GTK+</body></html>", 0);
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+}
+
+static void testLoadAlternateHTML(LoadTrackingTest* test, gconstpointer)
+{
+ test->loadAlternateHTML("<html><body>Alternate page</body></html>", "http://error-page.foo/", 0);
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+}
+
+static void testLoadPlainText(LoadTrackingTest* test, gconstpointer)
+{
+ test->loadPlainText("Hello WebKit-GTK+");
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+}
+
+static void testLoadRequest(LoadTrackingTest* test, gconstpointer)
+{
+ GRefPtr<WebKitURIRequest> request(webkit_uri_request_new(kServer->getURIForPath("/normal").data()));
+ test->loadRequest(request.get());
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+}
+
+class LoadStopTrackingTest : public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(LoadStopTrackingTest);
+
+ virtual void loadCommitted()
+ {
+ LoadTrackingTest::loadCommitted();
+ webkit_web_view_stop_loading(m_webView);
+ }
+ virtual void loadFailed(const gchar* failingURI, GError* error)
+ {
+ g_assert(g_error_matches(error, WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED));
+ LoadTrackingTest::loadFailed(failingURI, error);
+ }
+};
+
+static void testLoadCancelled(LoadStopTrackingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/cancelled").data());
+ test->waitUntilLoadFinished();
+
+ Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents;
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(events[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadFailed);
+ g_assert_cmpint(events[3], ==, LoadTrackingTest::LoadFinished);
+}
+
+static void testWebViewTitle(LoadTrackingTest* test, gconstpointer)
+{
+ g_assert(!webkit_web_view_get_title(test->m_webView));
+ test->loadHtml("<html><head><title>Welcome to WebKit-GTK+!</title></head></html>", 0);
+ test->waitUntilLoadFinished();
+ g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, "Welcome to WebKit-GTK+!");
+}
+
+static void testWebViewReload(LoadTrackingTest* test, gconstpointer)
+{
+ // Check that nothing happens when there's nothing to reload.
+ test->reload();
+ test->wait(0.25); // Wait for a quarter of a second.
+
+ test->loadURI(kServer->getURIForPath("/normal").data());
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+
+ test->reload();
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+}
+
+static void testLoadProgress(LoadTrackingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/normal").data());
+ test->waitUntilLoadFinished();
+ g_assert_cmpfloat(test->m_estimatedProgress, ==, 1);
+}
+
+static void testWebViewHistoryLoad(LoadTrackingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/normal").data());
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+
+ test->loadURI(kServer->getURIForPath("/normal2").data());
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+
+ // Check that load process is the same for pages loaded from history cache.
+ test->goBack();
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+
+ test->goForward();
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+}
+
+class ViewURITrackingTest: public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ViewURITrackingTest);
+
+ static void uriChanged(GObject*, GParamSpec*, ViewURITrackingTest* test)
+ {
+ g_assert_cmpstr(test->m_activeURI.data(), !=, webkit_web_view_get_uri(test->m_webView));
+ test->m_activeURI = webkit_web_view_get_uri(test->m_webView);
+ }
+
+ ViewURITrackingTest()
+ : m_activeURI(webkit_web_view_get_uri(m_webView))
+ {
+ g_assert(m_activeURI.isNull());
+ g_signal_connect(m_webView, "notify::uri", G_CALLBACK(uriChanged), this);
+ }
+
+ void provisionalLoadStarted()
+ {
+ checkActiveURI("/redirect");
+ }
+
+ void provisionalLoadReceivedServerRedirect()
+ {
+ checkActiveURI("/normal");
+ }
+
+ void loadCommitted()
+ {
+ checkActiveURI("/normal");
+ }
+
+ void loadFinished()
+ {
+ checkActiveURI("/normal");
+ LoadTrackingTest::loadFinished();
+ }
+
+ CString m_activeURI;
+
+private:
+ void checkActiveURI(const char* uri)
+ {
+ ASSERT_CMP_CSTRING(m_activeURI, ==, kServer->getURIForPath(uri));
+ }
+};
+
+static void testWebViewActiveURI(ViewURITrackingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/redirect").data());
+ test->waitUntilLoadFinished();
+}
+
+class ViewIsLoadingTest: public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ViewIsLoadingTest);
+
+ static void isLoadingChanged(GObject*, GParamSpec*, ViewIsLoadingTest* test)
+ {
+ if (webkit_web_view_is_loading(test->m_webView))
+ test->beginLoad();
+ else
+ test->endLoad();
+ }
+
+ ViewIsLoadingTest()
+ {
+ g_signal_connect(m_webView, "notify::is-loading", G_CALLBACK(isLoadingChanged), this);
+ }
+
+ void beginLoad()
+ {
+ // New load, load-started hasn't been emitted yet.
+ g_assert(m_loadEvents.isEmpty());
+ g_assert_cmpstr(webkit_web_view_get_uri(m_webView), ==, m_activeURI.data());
+ }
+
+ void endLoad()
+ {
+ // Load finish, load-finished and load-failed haven't been emitted yet.
+ g_assert(!m_loadEvents.isEmpty());
+ g_assert(!m_loadEvents.contains(LoadTrackingTest::LoadFinished));
+ g_assert(!m_loadEvents.contains(LoadTrackingTest::LoadFailed));
+ }
+};
+
+static void testWebViewIsLoading(ViewIsLoadingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/normal").data());
+ test->waitUntilLoadFinished();
+
+ test->reload();
+ test->waitUntilLoadFinished();
+
+ test->loadURI(kServer->getURIForPath("/error").data());
+ test->waitUntilLoadFinished();
+
+ test->loadURI(kServer->getURIForPath("/normal").data());
+ test->waitUntilLoadFinished();
+ test->loadURI(kServer->getURIForPath("/normal2").data());
+ test->waitUntilLoadFinished();
+
+ test->goBack();
+ test->waitUntilLoadFinished();
+
+ test->goForward();
+ test->waitUntilLoadFinished();
+}
+
+class WebPageURITest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(WebPageURITest);
+
+ static void webPageURIChangedCallback(GDBusConnection*, const char*, const char*, const char*, const char*, GVariant* result, WebPageURITest* test)
+ {
+ const char* uri;
+ g_variant_get(result, "(&s)", &uri);
+ test->m_webPageURIs.append(uri);
+ }
+
+ static void webViewURIChanged(GObject*, GParamSpec*, WebPageURITest* test)
+ {
+ test->m_webViewURIs.append(webkit_web_view_get_uri(test->m_webView));
+ }
+
+ WebPageURITest()
+ {
+ GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
+ "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", m_mainLoop));
+ m_uriChangedSignalID = g_dbus_connection_signal_subscribe(
+ g_dbus_proxy_get_connection(proxy.get()),
+ 0,
+ "org.webkit.gtk.WebExtensionTest",
+ "URIChanged",
+ "/org/webkit/gtk/WebExtensionTest",
+ 0,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ reinterpret_cast<GDBusSignalCallback>(webPageURIChangedCallback),
+ this,
+ 0);
+ g_assert(m_uriChangedSignalID);
+
+ g_signal_connect(m_webView, "notify::uri", G_CALLBACK(webViewURIChanged), this);
+ }
+
+ ~WebPageURITest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ g_dbus_connection_signal_unsubscribe(bus->connection(), m_uriChangedSignalID);
+ }
+
+ unsigned m_uriChangedSignalID;
+ Vector<CString> m_webPageURIs;
+ Vector<CString> m_webViewURIs;
+};
+
+static void testWebPageURI(WebPageURITest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/redirect").data());
+ test->waitUntilLoadFinished();
+
+ g_assert_cmpint(test->m_webPageURIs.size(), ==, test->m_webViewURIs.size());
+ for (size_t i = 0; i < test->m_webPageURIs.size(); ++i)
+ ASSERT_CMP_CSTRING(test->m_webPageURIs[i], ==, test->m_webViewURIs[i]);
+
+ g_assert_cmpint(test->m_webPageURIs.size(), ==, 2);
+ ASSERT_CMP_CSTRING(test->m_webPageURIs[0], ==, kServer->getURIForPath("/redirect"));
+ ASSERT_CMP_CSTRING(test->m_webPageURIs[1], ==, kServer->getURIForPath("/normal"));
+
+}
+
+static void testURIRequestHTTPHeaders(WebViewTest* test, gconstpointer)
+{
+ GRefPtr<WebKitURIRequest> uriRequest = adoptGRef(webkit_uri_request_new("file:///foo/bar"));
+ g_assert(uriRequest.get());
+ g_assert_cmpstr(webkit_uri_request_get_uri(uriRequest.get()), ==, "file:///foo/bar");
+ g_assert(!webkit_uri_request_get_http_headers(uriRequest.get()));
+
+ // Load a request with no Do Not Track header.
+ webkit_uri_request_set_uri(uriRequest.get(), kServer->getURIForPath("/do-not-track-header").data());
+ test->loadRequest(uriRequest.get());
+ test->waitUntilLoadFinished();
+
+ size_t mainResourceDataSize = 0;
+ const char* mainResourceData = test->mainResourceData(mainResourceDataSize);
+ g_assert_cmpint(mainResourceDataSize, ==, strlen(kDNTHeaderNotPresent));
+ g_assert(!strncmp(mainResourceData, kDNTHeaderNotPresent, mainResourceDataSize));
+
+ // Add the Do Not Track header and load the request again.
+ SoupMessageHeaders* headers = webkit_uri_request_get_http_headers(uriRequest.get());
+ g_assert(headers);
+ soup_message_headers_append(headers, "DNT", "1");
+ test->loadRequest(uriRequest.get());
+ test->waitUntilLoadFinished();
+
+ mainResourceData = test->mainResourceData(mainResourceDataSize);
+ g_assert_cmpint(mainResourceDataSize, ==, 1);
+ g_assert(!strncmp(mainResourceData, "1", mainResourceDataSize));
+
+ // Load a URI for which the web extension will add the Do Not Track header.
+ test->loadURI(kServer->getURIForPath("/add-do-not-track-header").data());
+ test->waitUntilLoadFinished();
+
+ mainResourceData = test->mainResourceData(mainResourceDataSize);
+ g_assert_cmpint(mainResourceDataSize, ==, 1);
+ g_assert(!strncmp(mainResourceData, "1", mainResourceDataSize));
+}
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ static const char* responseString = "<html><body>Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!</body></html>";
+
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ soup_message_set_status(message, SOUP_STATUS_OK);
+
+ if (g_str_has_prefix(path, "/normal"))
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString));
+ else if (g_str_equal(path, "/error"))
+ soup_message_set_status(message, SOUP_STATUS_CANT_CONNECT);
+ else if (g_str_equal(path, "/redirect")) {
+ soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
+ soup_message_headers_append(message->response_headers, "Location", "/normal");
+ } else if (g_str_equal(path, "/cancelled")) {
+ soup_message_headers_set_encoding(message->response_headers, SOUP_ENCODING_CHUNKED);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString));
+ soup_server_unpause_message(server, message);
+ return;
+ } else if (g_str_equal(path, "/do-not-track-header") || g_str_equal(path, "/add-do-not-track-header")) {
+ const char* doNotTrack = soup_message_headers_get_one(message->request_headers, "DNT");
+ if (doNotTrack)
+ soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, doNotTrack, strlen(doNotTrack));
+ else
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kDNTHeaderNotPresent, strlen(kDNTHeaderNotPresent));
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ } else
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+
+ soup_message_body_complete(message->response_body);
+}
+
+void beforeAll()
+{
+ webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+ bus = new WebKitTestBus();
+ if (!bus->run())
+ return;
+
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ LoadTrackingTest::add("WebKitWebView", "loading-status", testLoadingStatus);
+ LoadTrackingTest::add("WebKitWebView", "loading-error", testLoadingError);
+ LoadTrackingTest::add("WebKitWebView", "load-html", testLoadHtml);
+ LoadTrackingTest::add("WebKitWebView", "load-alternate-html", testLoadAlternateHTML);
+ LoadTrackingTest::add("WebKitWebView", "load-plain-text", testLoadPlainText);
+ LoadTrackingTest::add("WebKitWebView", "load-request", testLoadRequest);
+ LoadStopTrackingTest::add("WebKitWebView", "stop-loading", testLoadCancelled);
+ LoadTrackingTest::add("WebKitWebView", "title", testWebViewTitle);
+ LoadTrackingTest::add("WebKitWebView", "progress", testLoadProgress);
+ LoadTrackingTest::add("WebKitWebView", "reload", testWebViewReload);
+ LoadTrackingTest::add("WebKitWebView", "history-load", testWebViewHistoryLoad);
+
+ // This test checks that web view notify::uri signal is correctly emitted
+ // and the uri is already updated when loader client signals are emitted.
+ ViewURITrackingTest::add("WebKitWebView", "active-uri", testWebViewActiveURI);
+
+ ViewIsLoadingTest::add("WebKitWebView", "is-loading", testWebViewIsLoading);
+ WebPageURITest::add("WebKitWebPage", "get-uri", testWebPageURI);
+ WebViewTest::add("WebKitURIRequest", "http-headers", testURIRequestHTTPHeaders);
+}
+
+void afterAll()
+{
+ delete bus;
+ delete kServer;
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestLoaderClientcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestPrintingcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestPrintingcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,210 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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,1 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 "WebViewTest.h"
+#include <glib/gstdio.h>
+#include <wtf/gobject/GRefPtr.h>
+
+#ifdef HAVE_GTK_UNIX_PRINTING
+#include <gtk/gtkunixprint.h>
+#endif
+
+static char* kTempDirectory;
+
+static void testPrintOperationPrintSettings(WebViewTest* test, gconstpointer)
+{
+ GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(webkit_print_operation_new(test->m_webView));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printOperation.get()));
+
+ g_assert(!webkit_print_operation_get_print_settings(printOperation.get()));
+ g_assert(!webkit_print_operation_get_page_setup(printOperation.get()));
+
+ GRefPtr<GtkPrintSettings> printSettings = adoptGRef(gtk_print_settings_new());
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printSettings.get()));
+
+ GRefPtr<GtkPageSetup> pageSetup = adoptGRef(gtk_page_setup_new());
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(pageSetup.get()));
+
+ webkit_print_operation_set_print_settings(printOperation.get(), printSettings.get());
+ webkit_print_operation_set_page_setup(printOperation.get(), pageSetup.get());
+
+ g_assert(webkit_print_operation_get_print_settings(printOperation.get()) == printSettings.get());
+ g_assert(webkit_print_operation_get_page_setup(printOperation.get()) == pageSetup.get());
+}
+
+static gboolean webViewPrintCallback(WebKitWebView* webView, WebKitPrintOperation* printOperation, WebViewTest* test)
+{
+ g_assert(webView == test->m_webView);
+
+ g_assert(WEBKIT_IS_PRINT_OPERATION(printOperation));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printOperation));
+
+ g_assert(!webkit_print_operation_get_print_settings(printOperation));
+ g_assert(!webkit_print_operation_get_page_setup(printOperation));
+
+ g_main_loop_quit(test->m_mainLoop);
+
+ return TRUE;
+}
+
+static void testWebViewPrint(WebViewTest* test, gconstpointer)
+{
+ g_signal_connect(test->m_webView, "print", G_CALLBACK(webViewPrintCallback), test);
+ test->loadHtml("<html><body onLoad=\"print();\">WebKitGTK+ printing test</body></html>", 0);
+ g_main_loop_run(test->m_mainLoop);
+}
+
+#ifdef HAVE_GTK_UNIX_PRINTING
+class PrintTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(PrintTest);
+
+ static void printFinishedCallback(WebKitPrintOperation*, PrintTest* test)
+ {
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ static void printFailedCallback(WebKitPrintOperation*, GError* error, PrintTest* test)
+ {
+ g_assert(test->m_expectedError);
+ g_assert(error);
+ g_assert(g_error_matches(error, WEBKIT_PRINT_ERROR, test->m_expectedError));
+ }
+
+ PrintTest()
+ : m_expectedError(0)
+ {
+ m_printOperation = adoptGRef(webkit_print_operation_new(m_webView));
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_printOperation.get()));
+ g_signal_connect(m_printOperation.get(), "finished", G_CALLBACK(printFinishedCallback), this);
+ g_signal_connect(m_printOperation.get(), "failed", G_CALLBACK(printFailedCallback), this);
+ }
+
+ static gboolean testPrintOperationPrintPrinter(GtkPrinter* printer, gpointer userData)
+ {
+ if (strcmp(gtk_printer_get_name(printer), "Print to File"))
+ return FALSE;
+
+ GtkPrinter** foundPrinter = static_cast<GtkPrinter**>(userData);
+ *foundPrinter = static_cast<GtkPrinter*>(g_object_ref(printer));
+ return TRUE;
+ }
+
+ GtkPrinter* findPrintToFilePrinter()
+ {
+ GtkPrinter* printer = 0;
+ gtk_enumerate_printers(testPrintOperationPrintPrinter, &printer, 0, TRUE);
+ return printer;
+ }
+
+ void waitUntilPrintFinished()
+ {
+ g_main_loop_run(m_mainLoop);
+ }
+
+ GRefPtr<WebKitPrintOperation> m_printOperation;
+ unsigned m_expectedError;
+};
+
+static void testPrintOperationPrint(PrintTest* test, gconstpointer)
+{
+ test->loadHtml("<html><body>WebKitGTK+ printing test</body></html>", 0);
+ test->waitUntilLoadFinished();
+
+ GRefPtr<GtkPrinter> printer = adoptGRef(test->findPrintToFilePrinter());
+ if (!printer) {
+ g_message("%s", "Cannot test WebKitPrintOperation/print: no suitable printer found");
+ return;
+ }
+
+ GOwnPtr<char> outputFilename(g_build_filename(kTempDirectory, "webkit-print.pdf", NULL));
+ GRefPtr<GFile> outputFile = adoptGRef(g_file_new_for_path(outputFilename.get()));
+ GOwnPtr<char> outputURI(g_file_get_uri(outputFile.get()));
+
+ GRefPtr<GtkPrintSettings> printSettings = adoptGRef(gtk_print_settings_new());
+ gtk_print_settings_set_printer(printSettings.get(), gtk_printer_get_name(printer.get()));
+ gtk_print_settings_set(printSettings.get(), GTK_PRINT_SETTINGS_OUTPUT_URI, outputURI.get());
+
+ webkit_print_operation_set_print_settings(test->m_printOperation.get(), printSettings.get());
+ webkit_print_operation_print(test->m_printOperation.get());
+ test->waitUntilPrintFinished();
+
+ GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_info(outputFile.get(),
+ G_FILE_ATTRIBUTE_STANDARD_SIZE "," G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ static_cast<GFileQueryInfoFlags>(0), 0, 0));
+ g_assert(fileInfo.get());
+ g_assert_cmpint(g_file_info_get_size(fileInfo.get()), >, 0);
+ g_assert_cmpstr(g_file_info_get_content_type(fileInfo.get()), ==, "application/pdf");
+
+ g_file_delete(outputFile.get(), 0, 0);
+}
+
+static void testPrintOperationErrors(PrintTest* test, gconstpointer)
+{
+ test->loadHtml("<html><body>WebKitGTK+ printing errors test</body></html>", 0);
+ test->waitUntilLoadFinished();
+
+ GRefPtr<GtkPrinter> printer = adoptGRef(test->findPrintToFilePrinter());
+ if (!printer) {
+ g_message("%s", "Cannot test WebKitPrintOperation/print: no suitable printer found");
+ return;
+ }
+
+ // General Error: invalid filename.
+ test->m_expectedError = WEBKIT_PRINT_ERROR_GENERAL;
+ GRefPtr<GtkPrintSettings> printSettings = adoptGRef(gtk_print_settings_new());
+ gtk_print_settings_set_printer(printSettings.get(), gtk_printer_get_name(printer.get()));
+ gtk_print_settings_set(printSettings.get(), GTK_PRINT_SETTINGS_OUTPUT_URI, "file:///foo/bar");
+ webkit_print_operation_set_print_settings(test->m_printOperation.get(), printSettings.get());
+ webkit_print_operation_print(test->m_printOperation.get());
+ test->waitUntilPrintFinished();
+
+ // Printer not found error.
+ test->m_expectedError = WEBKIT_PRINT_ERROR_PRINTER_NOT_FOUND;
+ gtk_print_settings_set_printer(printSettings.get(), "The fake WebKit printer");
+ webkit_print_operation_print(test->m_printOperation.get());
+ test->waitUntilPrintFinished();
+
+ // No pages to print: print even pages for a single page document.
+ test->m_expectedError = WEBKIT_PRINT_ERROR_INVALID_PAGE_RANGE;
+ gtk_print_settings_set_printer(printSettings.get(), gtk_printer_get_name(printer.get()));
+ gtk_print_settings_set_page_set(printSettings.get(), GTK_PAGE_SET_EVEN);
+ webkit_print_operation_print(test->m_printOperation.get());
+ test->waitUntilPrintFinished();
+}
+#endif // HAVE_GTK_UNIX_PRINTING
+
+void beforeAll()
+{
+ kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0);
+ g_assert(kTempDirectory);
+
+ WebViewTest::add("WebKitPrintOperation", "printing-settings", testPrintOperationPrintSettings);
+ WebViewTest::add("WebKitWebView", "print", testWebViewPrint);
+#ifdef HAVE_GTK_UNIX_PRINTING
+ PrintTest::add("WebKitPrintOperation", "print", testPrintOperationPrint);
+ PrintTest::add("WebKitPrintOperation", "print-errors", testPrintOperationErrors);
+#endif
+}
+
+void afterAll()
+{
+ g_rmdir(kTempDirectory);
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestPrintingcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestResourcescppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestResourcescpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,789 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 "WebKitTestServer.h"
+#include "WebViewTest.h"
+#include <wtf/Vector.h>
+#include <wtf/gobject/GRefPtr.h>
+
+static WebKitTestServer* kServer;
+
+static const char* kIndexHtml =
+ "<html><head>"
+ " <link rel='stylesheet' href='/style.css' type='text/css'>"
+ " <script language='javascript' src='/javascript.js'></script>"
+ "</head><body>WebKitGTK+ resources test</body></html>";
+
+static const char* kStyleCSS =
+ "body {"
+ " margin: 0px;"
+ " padding: 0px;"
+ " font-family: sans-serif;"
+ " background: url(/blank.ico) 0 0 no-repeat;"
+ " color: black;"
+ "}";
+
+static const char* kJavascript = "function foo () { var a = 1; }";
+
+class ResourcesTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ResourcesTest);
+
+ static void resourceSentRequestCallback(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse, ResourcesTest* test)
+ {
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+ if (redirectResponse)
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(redirectResponse));
+ test->resourceSentRequest(resource, request, redirectResponse);
+ }
+
+ static void resourceReceivedResponseCallback(WebKitWebResource* resource, GParamSpec*, ResourcesTest* test)
+ {
+ g_assert(webkit_web_resource_get_response(resource));
+ test->resourceReceivedResponse(resource);
+ }
+
+ static void resourceReceivedDataCallback(WebKitWebResource* resource, guint64 bytesReceived, ResourcesTest* test)
+ {
+ test->resourceReceivedData(resource, bytesReceived);
+ }
+
+ static void resourceFinishedCallback(WebKitWebResource* resource, ResourcesTest* test)
+ {
+ test->resourceFinished(resource);
+ }
+
+ static void resourceFailedCallback(WebKitWebResource* resource, GError* error, ResourcesTest* test)
+ {
+ g_assert(error);
+ test->resourceFailed(resource, error);
+ }
+
+ static void resourceLoadStartedCallback(WebKitWebView* webView, WebKitWebResource* resource, WebKitURIRequest* request, ResourcesTest* test)
+ {
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(resource));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+
+ // Ignore favicons.
+ if (g_str_has_suffix(webkit_uri_request_get_uri(request), "favicon.ico"))
+ return;
+
+ test->resourceLoadStarted(resource, request);
+ g_signal_connect(resource, "sent-request", G_CALLBACK(resourceSentRequestCallback), test);
+ g_signal_connect(resource, "notify::response", G_CALLBACK(resourceReceivedResponseCallback), test);
+ g_signal_connect(resource, "received-data", G_CALLBACK(resourceReceivedDataCallback), test);
+ g_signal_connect(resource, "finished", G_CALLBACK(resourceFinishedCallback), test);
+ g_signal_connect(resource, "failed", G_CALLBACK(resourceFailedCallback), test);
+ }
+
+ void clearSubresources()
+ {
+ g_list_free_full(m_subresources, reinterpret_cast<GDestroyNotify>(g_object_unref));
+ m_subresources = 0;
+ }
+
+ ResourcesTest()
+ : WebViewTest()
+ , m_resourcesLoaded(0)
+ , m_resourcesToLoad(0)
+ , m_resourceDataSize(0)
+ , m_subresources(0)
+ {
+ g_signal_connect(m_webView, "resource-load-started", G_CALLBACK(resourceLoadStartedCallback), this);
+ }
+
+ ~ResourcesTest()
+ {
+ clearSubresources();
+ }
+
+ virtual void resourceLoadStarted(WebKitWebResource* resource, WebKitURIRequest* request)
+ {
+ }
+
+ virtual void resourceSentRequest(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse)
+ {
+ }
+
+ virtual void resourceReceivedResponse(WebKitWebResource* resource)
+ {
+ }
+
+ virtual void resourceReceivedData(WebKitWebResource* resource, guint64 bytesReceived)
+ {
+ }
+
+ virtual void resourceFinished(WebKitWebResource* resource)
+ {
+ g_signal_handlers_disconnect_matched(resource, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ if (webkit_web_view_get_main_resource(m_webView) != resource)
+ m_subresources = g_list_prepend(m_subresources, g_object_ref(resource));
+ if (++m_resourcesLoaded == m_resourcesToLoad)
+ g_main_loop_quit(m_mainLoop);
+ }
+
+ virtual void resourceFailed(WebKitWebResource* resource, GError* error)
+ {
+ g_assert_not_reached();
+ }
+
+ void waitUntilResourcesLoaded(size_t resourcesCount)
+ {
+ m_resourcesLoaded = 0;
+ m_resourcesToLoad = resourcesCount;
+ clearSubresources();
+ g_main_loop_run(m_mainLoop);
+ }
+
+ GList* subresources()
+ {
+ return m_subresources;
+ }
+
+ static void resourceGetDataCallback(GObject* object, GAsyncResult* result, gpointer userData)
+ {
+ size_t dataSize;
+ GOwnPtr<GError> error;
+ unsigned char* data = webkit_web_resource_get_data_finish(WEBKIT_WEB_RESOURCE(object), result, &dataSize, &error.outPtr());
+ g_assert(!error.get());
+ g_assert(data);
+ g_assert_cmpint(dataSize, >, 0);
+
+ ResourcesTest* test = static_cast<ResourcesTest*>(userData);
+ test->m_resourceData.set(reinterpret_cast<char*>(data));
+ test->m_resourceDataSize = dataSize;
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ void checkResourceData(WebKitWebResource* resource)
+ {
+ m_resourceDataSize = 0;
+ webkit_web_resource_get_data(resource, 0, resourceGetDataCallback, this);
+ g_main_loop_run(m_mainLoop);
+
+ const char* uri = webkit_web_resource_get_uri(resource);
+ if (uri == kServer->getURIForPath("/")) {
+ g_assert_cmpint(m_resourceDataSize, ==, strlen(kIndexHtml));
+ g_assert(!strncmp(m_resourceData.get(), kIndexHtml, m_resourceDataSize));
+ } else if (uri == kServer->getURIForPath("/style.css")) {
+ g_assert_cmpint(m_resourceDataSize, ==, strlen(kStyleCSS));
+ g_assert(!strncmp(m_resourceData.get(), kStyleCSS, m_resourceDataSize));
+ } else if (uri == kServer->getURIForPath("/javascript.js")) {
+ g_assert_cmpint(m_resourceDataSize, ==, strlen(kJavascript));
+ g_assert(!strncmp(m_resourceData.get(), kJavascript, m_resourceDataSize));
+ } else
+ g_assert_not_reached();
+ m_resourceData.clear();
+ }
+
+ size_t m_resourcesLoaded;
+ size_t m_resourcesToLoad;
+ GOwnPtr<char> m_resourceData;
+ size_t m_resourceDataSize;
+ GList* m_subresources;
+};
+
+static void testWebViewResources(ResourcesTest* test, gconstpointer)
+{
+ // Nothing loaded yet, there shoulnd't be resources.
+ g_assert(!webkit_web_view_get_main_resource(test->m_webView));
+ g_assert(!test->subresources());
+
+ // Load simple page without subresources.
+ test->loadHtml("<html><body>Testing WebKitGTK+</body></html>", 0);
+ test->waitUntilLoadFinished();
+ WebKitWebResource* resource = webkit_web_view_get_main_resource(test->m_webView);
+ g_assert(resource);
+ g_assert_cmpstr(webkit_web_view_get_uri(test->m_webView), ==, webkit_web_resource_get_uri(resource));
+ g_assert(!test->subresources());
+
+ // Load simple page with subresources.
+ test->loadURI(kServer->getURIForPath("/").data());
+ test->waitUntilResourcesLoaded(4);
+
+ resource = webkit_web_view_get_main_resource(test->m_webView);
+ g_assert(resource);
+ g_assert_cmpstr(webkit_web_view_get_uri(test->m_webView), ==, webkit_web_resource_get_uri(resource));
+ GList* subresources = test->subresources();
+ g_assert(subresources);
+ g_assert_cmpint(g_list_length(subresources), ==, 3);
+
+#if 0
+ // Load the same URI again.
+ // FIXME: we need a workaround for bug https://bugs.webkit.org/show_bug.cgi?id=78510.
+ test->loadURI(kServer->getURIForPath("/").data());
+ test->waitUntilResourcesLoaded(4);
+#endif
+
+ // Reload.
+ webkit_web_view_reload_bypass_cache(test->m_webView);
+ test->waitUntilResourcesLoaded(4);
+}
+
+class SingleResourceLoadTest: public ResourcesTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(SingleResourceLoadTest);
+
+ enum LoadEvents {
+ Started,
+ SentRequest,
+ Redirected,
+ ReceivedResponse,
+ ReceivedData,
+ Finished,
+ Failed
+ };
+
+ SingleResourceLoadTest()
+ : ResourcesTest()
+ , m_resourceDataReceived(0)
+ {
+ m_resourcesToLoad = 2;
+ }
+
+ void resourceLoadStarted(WebKitWebResource* resource, WebKitURIRequest* request)
+ {
+ if (resource == webkit_web_view_get_main_resource(m_webView))
+ return;
+
+ m_resourceDataReceived = 0;
+ m_resource = resource;
+ m_loadEvents.append(Started);
+ }
+
+ void resourceSentRequest(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse)
+ {
+ if (resource != m_resource)
+ return;
+
+ if (redirectResponse)
+ m_loadEvents.append(Redirected);
+ else
+ m_loadEvents.append(SentRequest);
+ }
+
+ void resourceReceivedResponse(WebKitWebResource* resource)
+ {
+ if (resource != m_resource)
+ return;
+
+ m_loadEvents.append(ReceivedResponse);
+ }
+
+ void resourceReceivedData(WebKitWebResource* resource, guint64 bytesReceived)
+ {
+ if (resource != m_resource)
+ return;
+
+ m_resourceDataReceived += bytesReceived;
+ if (!m_loadEvents.contains(ReceivedData))
+ m_loadEvents.append(ReceivedData);
+ }
+
+ void resourceFinished(WebKitWebResource* resource)
+ {
+ if (resource != m_resource) {
+ ResourcesTest::resourceFinished(resource);
+ return;
+ }
+
+ if (!m_loadEvents.contains(Failed)) {
+ WebKitURIResponse* response = webkit_web_resource_get_response(m_resource.get());
+ g_assert(response);
+ g_assert_cmpint(webkit_uri_response_get_content_length(response), ==, m_resourceDataReceived);
+ }
+ m_loadEvents.append(Finished);
+ ResourcesTest::resourceFinished(resource);
+ }
+
+ void resourceFailed(WebKitWebResource* resource, GError* error)
+ {
+ if (resource == m_resource)
+ m_loadEvents.append(Failed);
+ }
+
+ void waitUntilResourceLoadFinished()
+ {
+ m_resource = 0;
+ m_resourcesLoaded = 0;
+ g_main_loop_run(m_mainLoop);
+ }
+
+ WebKitURIResponse* waitUntilResourceLoadFinishedAndReturnURIResponse()
+ {
+ waitUntilResourceLoadFinished();
+ g_assert(m_resource);
+ return webkit_web_resource_get_response(m_resource.get());
+ }
+
+ GRefPtr<WebKitWebResource> m_resource;
+ Vector<LoadEvents> m_loadEvents;
+ guint64 m_resourceDataReceived;
+};
+
+static void testWebResourceLoading(SingleResourceLoadTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/javascript.html").data());
+ test->waitUntilResourceLoadFinished();
+ g_assert(test->m_resource);
+ Vector<SingleResourceLoadTest::LoadEvents>& events = test->m_loadEvents;
+ g_assert_cmpint(events.size(), ==, 5);
+ g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started);
+ g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest);
+ g_assert_cmpint(events[2], ==, SingleResourceLoadTest::ReceivedResponse);
+ g_assert_cmpint(events[3], ==, SingleResourceLoadTest::ReceivedData);
+ g_assert_cmpint(events[4], ==, SingleResourceLoadTest::Finished);
+ events.clear();
+
+ test->loadURI(kServer->getURIForPath("/redirected-css.html").data());
+ test->waitUntilResourceLoadFinished();
+ g_assert(test->m_resource);
+ g_assert_cmpint(events.size(), ==, 6);
+ g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started);
+ g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest);
+ g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Redirected);
+ g_assert_cmpint(events[3], ==, SingleResourceLoadTest::ReceivedResponse);
+ g_assert_cmpint(events[4], ==, SingleResourceLoadTest::ReceivedData);
+ g_assert_cmpint(events[5], ==, SingleResourceLoadTest::Finished);
+ events.clear();
+
+ test->loadURI(kServer->getURIForPath("/invalid-css.html").data());
+ test->waitUntilResourceLoadFinished();
+ g_assert(test->m_resource);
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started);
+ g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest);
+ g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Failed);
+ g_assert_cmpint(events[3], ==, SingleResourceLoadTest::Finished);
+ events.clear();
+}
+
+static void testWebResourceResponse(SingleResourceLoadTest* test, gconstpointer)
+{
+ // No cached resource: First load.
+ test->loadURI(kServer->getURIForPath("/javascript.html").data());
+ WebKitURIResponse* response = test->waitUntilResourceLoadFinishedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK);
+
+ // No cached resource: Second load.
+ test->loadURI(kServer->getURIForPath("/javascript.html").data());
+ response = test->waitUntilResourceLoadFinishedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK);
+
+ // No cached resource: Reload.
+ webkit_web_view_reload(test->m_webView);
+ response = test->waitUntilResourceLoadFinishedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK);
+
+ // Cached resource: First load.
+ test->loadURI(kServer->getURIForPath("/image.html").data());
+ response = test->waitUntilResourceLoadFinishedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK);
+
+ // Cached resource: Second load.
+ test->loadURI(kServer->getURIForPath("/image.html").data());
+ response = test->waitUntilResourceLoadFinishedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK);
+
+ // Cached resource: Reload.
+ webkit_web_view_reload(test->m_webView);
+ response = test->waitUntilResourceLoadFinishedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_NOT_MODIFIED);
+}
+
+static void testWebResourceMimeType(SingleResourceLoadTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/javascript.html").data());
+ WebKitURIResponse* response = test->waitUntilResourceLoadFinishedAndReturnURIResponse();
+ g_assert_cmpstr(webkit_uri_response_get_mime_type(response), ==, "text/javascript");
+
+ test->loadURI(kServer->getURIForPath("/image.html").data());
+ response = test->waitUntilResourceLoadFinishedAndReturnURIResponse();
+ g_assert_cmpstr(webkit_uri_response_get_mime_type(response), ==, "image/vnd.microsoft.icon");
+
+ test->loadURI(kServer->getURIForPath("/redirected-css.html").data());
+ response = test->waitUntilResourceLoadFinishedAndReturnURIResponse();
+ g_assert_cmpstr(webkit_uri_response_get_mime_type(response), ==, "text/css");
+}
+
+static void testWebResourceSuggestedFilename(SingleResourceLoadTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/javascript.html").data());
+ WebKitURIResponse* response = test->waitUntilResourceLoadFinishedAndReturnURIResponse();
+ g_assert_cmpstr(webkit_uri_response_get_suggested_filename(response), ==, "JavaScript.js");
+
+ test->loadURI(kServer->getURIForPath("/image.html").data());
+ response = test->waitUntilResourceLoadFinishedAndReturnURIResponse();
+ g_assert(!webkit_uri_response_get_suggested_filename(response));
+}
+
+class ResourceURITrackingTest: public SingleResourceLoadTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ResourceURITrackingTest);
+
+ ResourceURITrackingTest()
+ : SingleResourceLoadTest()
+ {
+ }
+
+ static void uriChanged(WebKitWebResource* resource, GParamSpec*, ResourceURITrackingTest* test)
+ {
+ g_assert(resource == test->m_resource.get());
+ g_assert_cmpstr(test->m_activeURI.data(), !=, webkit_web_resource_get_uri(test->m_resource.get()));
+ test->m_activeURI = webkit_web_resource_get_uri(test->m_resource.get());
+ }
+
+ void resourceLoadStarted(WebKitWebResource* resource, WebKitURIRequest* request)
+ {
+ if (resource == webkit_web_view_get_main_resource(m_webView))
+ return;
+
+ m_resource = resource;
+ m_activeURI = webkit_web_resource_get_uri(resource);
+ checkActiveURI("/redirected.css");
+ g_assert_cmpstr(m_activeURI.data(), ==, webkit_uri_request_get_uri(request));
+ g_signal_connect(resource, "notify::uri", G_CALLBACK(uriChanged), this);
+ }
+
+ void resourceSentRequest(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse)
+ {
+ if (resource != m_resource)
+ return;
+
+ if (redirectResponse)
+ checkActiveURI("/simple-style.css");
+ else
+ checkActiveURI("/redirected.css");
+ g_assert_cmpstr(m_activeURI.data(), ==, webkit_uri_request_get_uri(request));
+ }
+
+ void resourceReceivedResponse(WebKitWebResource* resource)
+ {
+ if (resource != m_resource)
+ return;
+
+ checkActiveURI("/simple-style.css");
+ }
+
+ void resourceReceivedData(WebKitWebResource* resource, guint64 bytesReceived)
+ {
+ }
+
+ void resourceFinished(WebKitWebResource* resource)
+ {
+ if (resource == m_resource)
+ checkActiveURI("/simple-style.css");
+ ResourcesTest::resourceFinished(resource);
+ }
+
+ void resourceFailed(WebKitWebResource*, GError*)
+ {
+ g_assert_not_reached();
+ }
+
+ CString m_activeURI;
+
+private:
+ void checkActiveURI(const char* uri)
+ {
+ ASSERT_CMP_CSTRING(m_activeURI, ==, kServer->getURIForPath(uri));
+ }
+};
+
+static void testWebResourceActiveURI(ResourceURITrackingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/redirected-css.html").data());
+ test->waitUntilResourceLoadFinished();
+}
+
+static void testWebResourceGetData(ResourcesTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/").data());
+ // FIXME: this should be 4 instead of 3, but we don't get the css image resource
+ // due to bug https://bugs.webkit.org/show_bug.cgi?id=78510.
+ test->waitUntilResourcesLoaded(3);
+
+ WebKitWebResource* resource = webkit_web_view_get_main_resource(test->m_webView);
+ g_assert(resource);
+ test->checkResourceData(resource);
+
+ GList* subresources = test->subresources();
+ for (GList* item = subresources; item; item = g_list_next(item))
+ test->checkResourceData(WEBKIT_WEB_RESOURCE(item->data));
+}
+
+static void testWebViewResourcesHistoryCache(SingleResourceLoadTest* test, gconstpointer)
+{
+ CString javascriptURI = kServer->getURIForPath("/javascript.html");
+ test->loadURI(javascriptURI.data());
+ test->waitUntilResourceLoadFinished();
+ WebKitWebResource* resource = webkit_web_view_get_main_resource(test->m_webView);
+ g_assert(resource);
+ g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, javascriptURI.data());
+
+ CString simpleStyleCSSURI = kServer->getURIForPath("/simple-style-css.html");
+ test->loadURI(simpleStyleCSSURI.data());
+ test->waitUntilResourceLoadFinished();
+ resource = webkit_web_view_get_main_resource(test->m_webView);
+ g_assert(resource);
+ g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, simpleStyleCSSURI.data());
+
+ test->goBack();
+ test->waitUntilResourceLoadFinished();
+ resource = webkit_web_view_get_main_resource(test->m_webView);
+ g_assert(resource);
+ g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, javascriptURI.data());
+
+ test->goForward();
+ test->waitUntilResourceLoadFinished();
+ resource = webkit_web_view_get_main_resource(test->m_webView);
+ g_assert(resource);
+ g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, simpleStyleCSSURI.data());
+}
+
+class SendRequestTest: public SingleResourceLoadTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(SendRequestTest);
+
+ void resourceSentRequest(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse)
+ {
+ if (resource != m_resource)
+ return;
+
+ if (redirectResponse)
+ g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, m_expectedNewResourceURIAfterRedirection.data());
+ else
+ g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, m_expectedNewResourceURI.data());
+ g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, webkit_web_resource_get_uri(resource));
+
+ SingleResourceLoadTest::resourceSentRequest(resource, request, redirectResponse);
+ }
+
+ void resourceFailed(WebKitWebResource* resource, GError* error)
+ {
+ if (resource != m_resource)
+ return;
+
+ g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, m_expectedCancelledResourceURI.data());
+ g_assert_error(error, WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED);
+
+ SingleResourceLoadTest::resourceFailed(resource, error);
+ }
+
+ void setExpectedNewResourceURI(const CString& uri)
+ {
+ m_expectedNewResourceURI = uri;
+ }
+
+ void setExpectedCancelledResourceURI(const CString& uri)
+ {
+ m_expectedCancelledResourceURI = uri;
+ }
+
+ void setExpectedNewResourceURIAfterRedirection(const CString& uri)
+ {
+ m_expectedNewResourceURIAfterRedirection = uri;
+ }
+
+ CString m_expectedNewResourceURI;
+ CString m_expectedCancelledResourceURI;
+ CString m_expectedNewResourceURIAfterRedirection;
+};
+
+static void testWebResourceSendRequest(SendRequestTest* test, gconstpointer)
+{
+ test->setExpectedNewResourceURI(kServer->getURIForPath("/javascript.js"));
+ test->loadURI(kServer->getURIForPath("relative-javascript.html").data());
+ test->waitUntilResourceLoadFinished();
+ g_assert(test->m_resource);
+
+ Vector<SingleResourceLoadTest::LoadEvents>& events = test->m_loadEvents;
+ g_assert_cmpint(events.size(), ==, 5);
+ g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started);
+ g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest);
+ g_assert_cmpint(events[2], ==, SingleResourceLoadTest::ReceivedResponse);
+ g_assert_cmpint(events[3], ==, SingleResourceLoadTest::ReceivedData);
+ g_assert_cmpint(events[4], ==, SingleResourceLoadTest::Finished);
+ events.clear();
+
+ // Cancel request.
+ test->setExpectedCancelledResourceURI(kServer->getURIForPath("/cancel-this.js"));
+ test->loadURI(kServer->getURIForPath("/resource-to-cancel.html").data());
+ test->waitUntilResourceLoadFinished();
+ g_assert(test->m_resource);
+
+ g_assert_cmpint(events.size(), ==, 3);
+ g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started);
+ g_assert_cmpint(events[1], ==, SingleResourceLoadTest::Failed);
+ g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Finished);
+ events.clear();
+
+ // URI changed after a redirect.
+ test->setExpectedNewResourceURI(kServer->getURIForPath("/redirected.js"));
+ test->setExpectedNewResourceURIAfterRedirection(kServer->getURIForPath("/javascript.js"));
+ test->loadURI(kServer->getURIForPath("redirected-javascript.html").data());
+ test->waitUntilResourceLoadFinished();
+ g_assert(test->m_resource);
+
+ g_assert_cmpint(events.size(), ==, 6);
+ g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started);
+ g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest);
+ g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Redirected);
+ g_assert_cmpint(events[3], ==, SingleResourceLoadTest::ReceivedResponse);
+ g_assert_cmpint(events[4], ==, SingleResourceLoadTest::ReceivedData);
+ g_assert_cmpint(events[5], ==, SingleResourceLoadTest::Finished);
+ events.clear();
+
+ // Cancel after a redirect.
+ test->setExpectedNewResourceURI(kServer->getURIForPath("/redirected-to-cancel.js"));
+ test->setExpectedCancelledResourceURI(kServer->getURIForPath("/redirected-to-cancel.js"));
+ test->loadURI(kServer->getURIForPath("/redirected-to-cancel.html").data());
+ test->waitUntilResourceLoadFinished();
+ g_assert(test->m_resource);
+
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started);
+ g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest);
+ g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Failed);
+ g_assert_cmpint(events[3], ==, SingleResourceLoadTest::Finished);
+ events.clear();
+}
+
+static void addCacheHTTPHeadersToResponse(SoupMessage* message)
+{
+ // The actual date doesn't really matter.
+ SoupDate* soupDate = soup_date_new_from_now(0);
+ GOwnPtr<char> date(soup_date_to_string(soupDate, SOUP_DATE_HTTP));
+ soup_message_headers_append(message->response_headers, "Last-Modified", date.get());
+ soup_date_free(soupDate);
+ soup_message_headers_append(message->response_headers, "Cache-control", "public, max-age=31536000");
+ soupDate = soup_date_new_from_now(3600);
+ date.set(soup_date_to_string(soupDate, SOUP_DATE_HTTP));
+ soup_message_headers_append(message->response_headers, "Expires", date.get());
+ soup_date_free(soupDate);
+}
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ soup_message_set_status(message, SOUP_STATUS_OK);
+
+ if (soup_message_headers_get_one(message->request_headers, "If-Modified-Since")) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_MODIFIED);
+ soup_message_body_complete(message->response_body);
+ return;
+ }
+
+ if (g_str_equal(path, "/")) {
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kIndexHtml, strlen(kIndexHtml));
+ } else if (g_str_equal(path, "/javascript.html")) {
+ static const char* javascriptHtml = "<html><head><script language='javascript' src='/javascript.js'></script></head><body></body></html>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, javascriptHtml, strlen(javascriptHtml));
+ } else if (g_str_equal(path, "/image.html")) {
+ static const char* imageHTML = "<html><body><img src='/blank.ico'></img></body></html>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, imageHTML, strlen(imageHTML));
+ } else if (g_str_equal(path, "/redirected-css.html")) {
+ static const char* redirectedCSSHtml = "<html><head><link rel='stylesheet' href='/redirected.css' type='text/css'></head><body></html>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, redirectedCSSHtml, strlen(redirectedCSSHtml));
+ } else if (g_str_equal(path, "/invalid-css.html")) {
+ static const char* invalidCSSHtml = "<html><head><link rel='stylesheet' href='/invalid.css' type='text/css'></head><body></html>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, invalidCSSHtml, strlen(invalidCSSHtml));
+ } else if (g_str_equal(path, "/simple-style-css.html")) {
+ static const char* simpleStyleCSSHtml = "<html><head><link rel='stylesheet' href='/simple-style.css' type='text/css'></head><body></html>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, simpleStyleCSSHtml, strlen(simpleStyleCSSHtml));
+ } else if (g_str_equal(path, "/style.css")) {
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kStyleCSS, strlen(kStyleCSS));
+ addCacheHTTPHeadersToResponse(message);
+ soup_message_headers_append(message->response_headers, "Content-Type", "text/css");
+ } else if (g_str_equal(path, "/javascript.js")) {
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kJavascript, strlen(kJavascript));
+ soup_message_headers_append(message->response_headers, "Content-Type", "text/javascript");
+ soup_message_headers_append(message->response_headers, "Content-Disposition", "filename=JavaScript.js");
+ } else if (g_str_equal(path, "/relative-javascript.html")) {
+ static const char* javascriptRelativeHTML = "<html><head><script language='javascript' src='remove-this/javascript.js'></script></head><body></body></html>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, javascriptRelativeHTML, strlen(javascriptRelativeHTML));
+ } else if (g_str_equal(path, "/resource-to-cancel.html")) {
+ static const char* resourceToCancelHTML = "<html><head><script language='javascript' src='cancel-this.js'></script></head><body></body></html>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, resourceToCancelHTML, strlen(resourceToCancelHTML));
+ } else if (g_str_equal(path, "/redirected-javascript.html")) {
+ static const char* javascriptRelativeHTML = "<html><head><script language='javascript' src='/redirected.js'></script></head><body></body></html>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, javascriptRelativeHTML, strlen(javascriptRelativeHTML));
+ } else if (g_str_equal(path, "/redirected-to-cancel.html")) {
+ static const char* javascriptRelativeHTML = "<html><head><script language='javascript' src='/redirected-to-cancel.js'></script></head><body></body></html>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, javascriptRelativeHTML, strlen(javascriptRelativeHTML));
+ } else if (g_str_equal(path, "/blank.ico")) {
+ GOwnPtr<char> filePath(g_build_filename(Test::getWebKit1TestResoucesDir().data(), path, NULL));
+ char* contents;
+ gsize contentsLength;
+ g_file_get_contents(filePath.get(), &contents, &contentsLength, 0);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, contentsLength);
+ addCacheHTTPHeadersToResponse(message);
+ soup_message_headers_append(message->response_headers, "Content-Type", "image/vnd.microsoft.icon");
+ } else if (g_str_equal(path, "/simple-style.css")) {
+ static const char* simpleCSS =
+ "body {"
+ " margin: 0px;"
+ " padding: 0px;"
+ "}";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, simpleCSS, strlen(simpleCSS));
+ soup_message_headers_append(message->response_headers, "Content-Type", "text/css");
+ } else if (g_str_equal(path, "/redirected.css")) {
+ soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
+ soup_message_headers_append(message->response_headers, "Location", "/simple-style.css");
+ } else if (g_str_equal(path, "/redirected.js")) {
+ soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
+ soup_message_headers_append(message->response_headers, "Location", "/remove-this/javascript.js");
+ } else if (g_str_equal(path, "/redirected-to-cancel.js")) {
+ soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
+ soup_message_headers_append(message->response_headers, "Location", "/cancel-this.js");
+ } else if (g_str_equal(path, "/invalid.css"))
+ soup_message_set_status(message, SOUP_STATUS_CANT_CONNECT);
+ else
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+ soup_message_body_complete(message->response_body);
+}
+
+void beforeAll()
+{
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+
+ ResourcesTest::add("WebKitWebView", "resources", testWebViewResources);
+ SingleResourceLoadTest::add("WebKitWebResource", "loading", testWebResourceLoading);
+ SingleResourceLoadTest::add("WebKitWebResource", "response", testWebResourceResponse);
+ SingleResourceLoadTest::add("WebKitWebResource", "mime-type", testWebResourceMimeType);
+ SingleResourceLoadTest::add("WebKitWebResource", "suggested-filename", testWebResourceSuggestedFilename);
+ ResourceURITrackingTest::add("WebKitWebResource", "active-uri", testWebResourceActiveURI);
+ ResourcesTest::add("WebKitWebResource", "get-data", testWebResourceGetData);
+ SingleResourceLoadTest::add("WebKitWebView", "history-cache", testWebViewResourcesHistoryCache);
+ SendRequestTest::add("WebKitWebPage", "send-request", testWebResourceSendRequest);
+}
+
+void afterAll()
+{
+ delete kServer;
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestResourcescpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestSSLcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestSSLcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,290 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 "LoadTrackingTest.h"
+#include "WebKitTestServer.h"
+#include <gtk/gtk.h>
+
+static WebKitTestServer* kHttpsServer;
+static WebKitTestServer* kHttpServer;
+
+static const char* indexHTML = "<html><body>Testing WebKit2GTK+ SSL</body></htmll>";
+static const char* insecureContentHTML = "<html><script src=\"%s\"></script><body><p>Text + image <img src=\"%s\" align=\"right\"/></p></body></html>";
+static const char TLSExpectedSuccessTitle[] = "WebKit2Gtk+ TLS permission test";
+static const char TLSSuccessHTMLString[] = "<html><head><title>WebKit2Gtk+ TLS permission test</title></head><body></body></html>";
+
+class SSLTest: public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(SSLTest);
+
+ SSLTest()
+ : m_tlsErrors(static_cast<GTlsCertificateFlags>(0))
+ {
+ }
+
+ virtual void provisionalLoadFailed(const gchar* failingURI, GError* error)
+ {
+ g_assert_error(error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED);
+ LoadTrackingTest::provisionalLoadFailed(failingURI, error);
+ }
+
+ virtual void loadCommitted()
+ {
+ GTlsCertificate* certificate = 0;
+ webkit_web_view_get_tls_info(m_webView, &certificate, &m_tlsErrors);
+ m_certificate = certificate;
+ LoadTrackingTest::loadCommitted();
+ }
+
+ void waitUntilLoadFinished()
+ {
+ m_certificate = 0;
+ m_tlsErrors = static_cast<GTlsCertificateFlags>(0);
+ LoadTrackingTest::waitUntilLoadFinished();
+ }
+
+ GRefPtr<GTlsCertificate> m_certificate;
+ GTlsCertificateFlags m_tlsErrors;
+};
+
+static void testSSL(SSLTest* test, gconstpointer)
+{
+ test->loadURI(kHttpsServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+ g_assert(test->m_certificate);
+ // We always expect errors because we are using a self-signed certificate,
+ // but only G_TLS_CERTIFICATE_UNKNOWN_CA flags should be present.
+ g_assert(test->m_tlsErrors);
+ g_assert_cmpuint(test->m_tlsErrors, ==, G_TLS_CERTIFICATE_UNKNOWN_CA);
+
+ // Non HTTPS loads shouldn't have a certificate nor errors.
+ test->loadHtml(indexHTML, 0);
+ test->waitUntilLoadFinished();
+ g_assert(!test->m_certificate);
+ g_assert(!test->m_tlsErrors);
+}
+
+class InsecureContentTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(InsecureContentTest);
+
+ InsecureContentTest()
+ : m_insecureContentRun(false)
+ , m_insecureContentDisplayed(false)
+ {
+ g_signal_connect(m_webView, "insecure-content-detected", G_CALLBACK(insecureContentDetectedCallback), this);
+ }
+
+ static void insecureContentDetectedCallback(WebKitWebView* webView, WebKitInsecureContentEvent event, InsecureContentTest* test)
+ {
+ g_assert(webView == test->m_webView);
+
+ if (event == WEBKIT_INSECURE_CONTENT_RUN)
+ test->m_insecureContentRun = true;
+
+ if (event == WEBKIT_INSECURE_CONTENT_DISPLAYED)
+ test->m_insecureContentDisplayed = true;
+ }
+
+ bool m_insecureContentRun;
+ bool m_insecureContentDisplayed;
+};
+
+static void testInsecureContent(InsecureContentTest* test, gconstpointer)
+{
+ test->loadURI(kHttpsServer->getURIForPath("/insecure-content/").data());
+ test->waitUntilLoadFinished();
+
+ g_assert(test->m_insecureContentRun);
+ g_assert(test->m_insecureContentDisplayed);
+}
+
+static void testTLSErrorsPolicy(SSLTest* test, gconstpointer)
+{
+ WebKitWebContext* context = webkit_web_view_get_context(test->m_webView);
+ // TLS errors are ignored by default.
+ g_assert(webkit_web_context_get_tls_errors_policy(context) == WEBKIT_TLS_ERRORS_POLICY_IGNORE);
+ test->loadURI(kHttpsServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+ g_assert(!test->m_loadFailed);
+
+ webkit_web_context_set_tls_errors_policy(context, WEBKIT_TLS_ERRORS_POLICY_FAIL);
+ test->loadURI(kHttpsServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+ g_assert(test->m_loadFailed);
+ g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+ g_assert(!test->m_loadEvents.contains(LoadTrackingTest::LoadCommitted));
+}
+
+class TLSErrorsTest: public SSLTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(TLSErrorsTest);
+
+ TLSErrorsTest()
+ {
+ g_signal_connect(m_webView, "load-failed-with-tls-errors", G_CALLBACK(runLoadFailedWithTLSErrorsCallback), this);
+ }
+
+ ~TLSErrorsTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ if (m_certificateInfo)
+ webkit_certificate_info_free(m_certificateInfo);
+ }
+
+ static gboolean runLoadFailedWithTLSErrorsCallback(WebKitWebView*, WebKitCertificateInfo* info, const char* host, TLSErrorsTest* test)
+ {
+ test->runLoadFailedWithTLSErrors(info, host);
+ return TRUE;
+ }
+
+ void runLoadFailedWithTLSErrors(WebKitCertificateInfo* info, const char* host)
+ {
+ if (m_certificateInfo)
+ webkit_certificate_info_free(m_certificateInfo);
+ m_certificateInfo = webkit_certificate_info_copy(info);
+ m_host.set(g_strdup(host));
+ g_main_loop_quit(m_mainLoop);
+ }
+
+ void waitUntilLoadFailedWithTLSErrors()
+ {
+ g_main_loop_run(m_mainLoop);
+ }
+
+ WebKitCertificateInfo* certificateInfo()
+ {
+ return m_certificateInfo;
+ }
+
+ const char* host()
+ {
+ return m_host.get();
+ }
+
+private:
+ WebKitCertificateInfo* m_certificateInfo;
+ GOwnPtr<char> m_host;
+};
+
+static void testLoadFailedWithTLSErrors(TLSErrorsTest* test, gconstpointer)
+{
+ WebKitWebContext* context = webkit_web_view_get_context(test->m_webView);
+ webkit_web_context_set_tls_errors_policy(context, WEBKIT_TLS_ERRORS_POLICY_FAIL);
+
+ // The load-failed-with-tls-errors signal should be emitted when there is a TLS failure.
+ test->loadURI(kHttpsServer->getURIForPath("/test-tls/").data());
+ test->waitUntilLoadFailedWithTLSErrors();
+ // Test the WebKitCertificateInfo API.
+ g_assert(G_IS_TLS_CERTIFICATE(webkit_certificate_info_get_tls_certificate(test->certificateInfo())));
+ g_assert_cmpuint(webkit_certificate_info_get_tls_errors(test->certificateInfo()), ==, G_TLS_CERTIFICATE_UNKNOWN_CA);
+ g_assert_cmpstr(test->host(), ==, soup_uri_get_host(kHttpsServer->baseURI()));
+ g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadFinished);
+
+ // Test allowing an exception for this certificate on this host.
+ webkit_web_context_allow_tls_certificate_for_host(context, test->certificateInfo(), test->host());
+ // The page should now load without errors.
+ test->loadURI(kHttpsServer->getURIForPath("/test-tls/").data());
+ test->waitUntilLoadFinished();
+
+ g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+ g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, TLSExpectedSuccessTitle);
+}
+
+
+static void httpsServerCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ if (g_str_equal(path, "/")) {
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, indexHTML, strlen(indexHTML));
+ soup_message_body_complete(message->response_body);
+ } else if (g_str_equal(path, "/insecure-content/")) {
+ GOwnPtr<char> responseHTML(g_strdup_printf(insecureContentHTML, kHttpServer->getURIForPath("/test-script").data(), kHttpServer->getURIForPath("/test-image").data()));
+ soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, responseHTML.get(), strlen(responseHTML.get()));
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_complete(message->response_body);
+ } else if (g_str_equal(path, "/test-tls/")) {
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, TLSSuccessHTMLString, strlen(TLSSuccessHTMLString));
+ soup_message_body_complete(message->response_body);
+ } else
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+}
+
+static void httpServerCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ if (g_str_equal(path, "/test-script")) {
+ GOwnPtr<char> pathToFile(g_build_filename(Test::getResourcesDir().data(), "link-title.js", NULL));
+ char* contents;
+ gsize length;
+ g_file_get_contents(pathToFile.get(), &contents, &length, 0);
+
+ soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, length);
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_complete(message->response_body);
+ } else if (g_str_equal(path, "/test-image")) {
+ GOwnPtr<char> pathToFile(g_build_filename(Test::getWebKit1TestResoucesDir().data(), "blank.ico", NULL));
+ char* contents;
+ gsize length;
+ g_file_get_contents(pathToFile.get(), &contents, &length, 0);
+
+ soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, length);
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_complete(message->response_body);
+ } else
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+}
+
+void beforeAll()
+{
+ kHttpsServer = new WebKitTestServer(WebKitTestServer::ServerHTTPS);
+ kHttpsServer->run(httpsServerCallback);
+
+ kHttpServer = new WebKitTestServer(WebKitTestServer::ServerHTTP);
+ kHttpServer->run(httpServerCallback);
+
+ SSLTest::add("WebKitWebView", "ssl", testSSL);
+ InsecureContentTest::add("WebKitWebView", "insecure-content", testInsecureContent);
+ // In this case the order of the tests does matter because tls-errors-policy tests the default policy,
+ // and expects that no exception will have been added for this certificate and host pair as is
+ // done in the tls-permission-request test.
+ SSLTest::add("WebKitWebView", "tls-errors-policy", testTLSErrorsPolicy);
+ TLSErrorsTest::add("WebKitWebView", "load-failed-with-tls-errors", testLoadFailedWithTLSErrors);
+}
+
+void afterAll()
+{
+ delete kHttpsServer;
+ delete kHttpServer;
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestSSLcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestUIClientcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestUIClientcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestUIClient.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,679 @@
</span><ins>+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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,1 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 "WebViewTest.h"
+#include <wtf/HashSet.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/StringHash.h>
+
+static const char* kAlertDialogMessage = "WebKitGTK+ alert dialog message";
+static const char* kConfirmDialogMessage = "WebKitGTK+ confirm dialog message";
+static const char* kPromptDialogMessage = "WebKitGTK+ prompt dialog message";
+static const char* kPromptDialogReturnedText = "WebKitGTK+ prompt dialog returned text";
+
+class UIClientTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(UIClientTest);
+
+ enum WebViewEvents {
+ Create,
+ ReadyToShow,
+ RunAsModal,
+ Close
+ };
+
+ class WindowProperties {
+ public:
+ WindowProperties()
+ : m_isNull(true)
+ , m_toolbarVisible(true)
+ , m_statusbarVisible(true)
+ , m_scrollbarsVisible(true)
+ , m_menubarVisible(true)
+ , m_locationbarVisible(true)
+ , m_resizable(true)
+ , m_fullscreen(false)
+ {
+ memset(&m_geometry, 0, sizeof(GdkRectangle));
+ }
+
+ WindowProperties(WebKitWindowProperties* windowProperties)
+ : m_isNull(false)
+ , m_toolbarVisible(webkit_window_properties_get_toolbar_visible(windowProperties))
+ , m_statusbarVisible(webkit_window_properties_get_statusbar_visible(windowProperties))
+ , m_scrollbarsVisible(webkit_window_properties_get_scrollbars_visible(windowProperties))
+ , m_menubarVisible(webkit_window_properties_get_menubar_visible(windowProperties))
+ , m_locationbarVisible(webkit_window_properties_get_locationbar_visible(windowProperties))
+ , m_resizable(webkit_window_properties_get_resizable(windowProperties))
+ , m_fullscreen(webkit_window_properties_get_fullscreen(windowProperties))
+ {
+ webkit_window_properties_get_geometry(windowProperties, &m_geometry);
+ }
+
+ WindowProperties(GdkRectangle* geometry, bool toolbarVisible, bool statusbarVisible, bool scrollbarsVisible, bool menubarVisible, bool locationbarVisible, bool resizable, bool fullscreen)
+ : m_isNull(false)
+ , m_geometry(*geometry)
+ , m_toolbarVisible(toolbarVisible)
+ , m_statusbarVisible(statusbarVisible)
+ , m_scrollbarsVisible(scrollbarsVisible)
+ , m_menubarVisible(menubarVisible)
+ , m_locationbarVisible(locationbarVisible)
+ , m_resizable(resizable)
+ , m_fullscreen(fullscreen)
+ {
+ }
+
+ bool isNull() const { return m_isNull; }
+
+ void assertEqual(const WindowProperties& other) const
+ {
+ g_assert_cmpint(m_geometry.x, ==, other.m_geometry.x);
+ g_assert_cmpint(m_geometry.y, ==, other.m_geometry.y);
+ g_assert_cmpint(m_geometry.width, ==, other.m_geometry.width);
+ g_assert_cmpint(m_geometry.height, ==, other.m_geometry.height);
+ g_assert_cmpint(static_cast<int>(m_toolbarVisible), ==, static_cast<int>(other.m_toolbarVisible));
+ g_assert_cmpint(static_cast<int>(m_statusbarVisible), ==, static_cast<int>(other.m_statusbarVisible));
+ g_assert_cmpint(static_cast<int>(m_scrollbarsVisible), ==, static_cast<int>(other.m_scrollbarsVisible));
+ g_assert_cmpint(static_cast<int>(m_menubarVisible), ==, static_cast<int>(other.m_menubarVisible));
+ g_assert_cmpint(static_cast<int>(m_locationbarVisible), ==, static_cast<int>(other.m_locationbarVisible));
+ g_assert_cmpint(static_cast<int>(m_resizable), ==, static_cast<int>(other.m_resizable));
+ g_assert_cmpint(static_cast<int>(m_fullscreen), ==, static_cast<int>(other.m_fullscreen));
+ }
+
+ private:
+ bool m_isNull;
+
+ GdkRectangle m_geometry;
+
+ bool m_toolbarVisible;
+ bool m_statusbarVisible;
+ bool m_scrollbarsVisible;
+ bool m_menubarVisible;
+ bool m_locationbarVisible;
+
+ bool m_resizable;
+ bool m_fullscreen;
+ };
+
+ static void windowPropertiesNotifyCallback(GObject*, GParamSpec* paramSpec, UIClientTest* test)
+ {
+ test->m_windowPropertiesChanged.add(g_param_spec_get_name(paramSpec));
+ }
+
+ static GtkWidget* viewCreateCallback(WebKitWebView* webView, UIClientTest* test)
+ {
+ return test->viewCreate(webView);
+ }
+
+ static void viewReadyToShowCallback(WebKitWebView* webView, UIClientTest* test)
+ {
+ test->viewReadyToShow(webView);
+ }
+
+ static void viewCloseCallback(WebKitWebView* webView, UIClientTest* test)
+ {
+ test->viewClose(webView);
+ }
+
+ void scriptAlert(WebKitScriptDialog* dialog)
+ {
+ switch (m_scriptDialogType) {
+ case WEBKIT_SCRIPT_DIALOG_ALERT:
+ g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kAlertDialogMessage);
+ break;
+ case WEBKIT_SCRIPT_DIALOG_CONFIRM:
+ g_assert(m_scriptDialogConfirmed);
+ g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, "confirmed");
+
+ break;
+ case WEBKIT_SCRIPT_DIALOG_PROMPT:
+ g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kPromptDialogReturnedText);
+ break;
+ }
+
+ g_main_loop_quit(m_mainLoop);
+ }
+
+ void scriptConfirm(WebKitScriptDialog* dialog)
+ {
+ g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kConfirmDialogMessage);
+ m_scriptDialogConfirmed = !m_scriptDialogConfirmed;
+ webkit_script_dialog_confirm_set_confirmed(dialog, m_scriptDialogConfirmed);
+ }
+
+ void scriptPrompt(WebKitScriptDialog* dialog)
+ {
+ g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kPromptDialogMessage);
+ g_assert_cmpstr(webkit_script_dialog_prompt_get_default_text(dialog), ==, "default");
+ webkit_script_dialog_prompt_set_text(dialog, kPromptDialogReturnedText);
+ }
+
+ static gboolean scriptDialog(WebKitWebView*, WebKitScriptDialog* dialog, UIClientTest* test)
+ {
+ switch (webkit_script_dialog_get_dialog_type(dialog)) {
+ case WEBKIT_SCRIPT_DIALOG_ALERT:
+ test->scriptAlert(dialog);
+ break;
+ case WEBKIT_SCRIPT_DIALOG_CONFIRM:
+ test->scriptConfirm(dialog);
+ break;
+ case WEBKIT_SCRIPT_DIALOG_PROMPT:
+ test->scriptPrompt(dialog);
+ break;
+ }
+
+ return TRUE;
+ }
+
+ static void mouseTargetChanged(WebKitWebView*, WebKitHitTestResult* hitTestResult, guint modifiers, UIClientTest* test)
+ {
+ g_assert(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(hitTestResult));
+
+ test->m_mouseTargetHitTestResult = hitTestResult;
+ test->m_mouseTargetModifiers = modifiers;
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ static gboolean permissionRequested(WebKitWebView*, WebKitPermissionRequest* request, UIClientTest* test)
+ {
+ g_assert(WEBKIT_IS_PERMISSION_REQUEST(request));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+
+ if (test->m_allowPermissionRequests)
+ webkit_permission_request_allow(request);
+ else
+ webkit_permission_request_deny(request);
+
+ return TRUE;
+ }
+
+ UIClientTest()
+ : m_scriptDialogType(WEBKIT_SCRIPT_DIALOG_ALERT)
+ , m_scriptDialogConfirmed(true)
+ , m_allowPermissionRequests(false)
+ , m_mouseTargetModifiers(0)
+ {
+ webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(m_webView), TRUE);
+ g_signal_connect(m_webView, "create", G_CALLBACK(viewCreateCallback), this);
+ g_signal_connect(m_webView, "script-dialog", G_CALLBACK(scriptDialog), this);
+ g_signal_connect(m_webView, "mouse-target-changed", G_CALLBACK(mouseTargetChanged), this);
+ g_signal_connect(m_webView, "permission-request", G_CALLBACK(permissionRequested), this);
+ }
+
+ ~UIClientTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void waitUntilMainLoopFinishes()
+ {
+ g_main_loop_run(m_mainLoop);
+ }
+
+ void setExpectedWindowProperties(const WindowProperties& windowProperties)
+ {
+ m_windowProperties = windowProperties;
+ }
+
+ WebKitHitTestResult* moveMouseAndWaitUntilMouseTargetChanged(int x, int y, unsigned mouseModifiers = 0)
+ {
+ mouseMoveTo(x, y, mouseModifiers);
+ g_main_loop_run(m_mainLoop);
+ return m_mouseTargetHitTestResult.get();
+ }
+
+ virtual GtkWidget* viewCreate(WebKitWebView* webView)
+ {
+ g_assert(webView == m_webView);
+
+ GtkWidget* newWebView = webkit_web_view_new_with_context(webkit_web_view_get_context(webView));
+ g_object_ref_sink(newWebView);
+
+ m_webViewEvents.append(Create);
+
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(newWebView));
+ g_assert(windowProperties);
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(windowProperties));
+ m_windowPropertiesChanged.clear();
+
+ g_signal_connect(windowProperties, "notify", G_CALLBACK(windowPropertiesNotifyCallback), this);
+ g_signal_connect(newWebView, "ready-to-show", G_CALLBACK(viewReadyToShowCallback), this);
+ g_signal_connect(newWebView, "close", G_CALLBACK(viewCloseCallback), this);
+
+ return newWebView;
+ }
+
+ virtual void viewReadyToShow(WebKitWebView* webView)
+ {
+ g_assert(webView != m_webView);
+
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(webView);
+ g_assert(windowProperties);
+ if (!m_windowProperties.isNull())
+ WindowProperties(windowProperties).assertEqual(m_windowProperties);
+
+ m_webViewEvents.append(ReadyToShow);
+ }
+
+ virtual void viewClose(WebKitWebView* webView)
+ {
+ g_assert(webView != m_webView);
+
+ m_webViewEvents.append(Close);
+ g_object_unref(webView);
+
+ g_main_loop_quit(m_mainLoop);
+ }
+
+ Vector<WebViewEvents> m_webViewEvents;
+ WebKitScriptDialogType m_scriptDialogType;
+ bool m_scriptDialogConfirmed;
+ bool m_allowPermissionRequests;
+ WindowProperties m_windowProperties;
+ HashSet<WTF::String> m_windowPropertiesChanged;
+ GRefPtr<WebKitHitTestResult> m_mouseTargetHitTestResult;
+ unsigned m_mouseTargetModifiers;
+};
+
+static void testWebViewCreateReadyClose(UIClientTest* test, gconstpointer)
+{
+ test->loadHtml("<html><body onLoad=\"window.open().close();\"></html>", 0);
+ test->waitUntilMainLoopFinishes();
+
+ Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
+ g_assert_cmpint(events.size(), ==, 3);
+ g_assert_cmpint(events[0], ==, UIClientTest::Create);
+ g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
+ g_assert_cmpint(events[2], ==, UIClientTest::Close);
+}
+
+static gboolean checkMimeTypeForFilter(GtkFileFilter* filter, const gchar* mimeType)
+{
+ GtkFileFilterInfo filterInfo;
+ filterInfo.contains = GTK_FILE_FILTER_MIME_TYPE;
+ filterInfo.mime_type = mimeType;
+ return gtk_file_filter_filter(filter, &filterInfo);
+}
+
+class ModalDialogsTest: public UIClientTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ModalDialogsTest);
+
+ static void dialogRunAsModalCallback(WebKitWebView* webView, ModalDialogsTest* test)
+ {
+ g_assert(webView != test->m_webView);
+ test->m_webViewEvents.append(RunAsModal);
+ }
+
+ GtkWidget* viewCreate(WebKitWebView* webView)
+ {
+ g_assert(webView == m_webView);
+
+ GtkWidget* newWebView = UIClientTest::viewCreate(webView);
+ g_signal_connect(newWebView, "run-as-modal", G_CALLBACK(dialogRunAsModalCallback), this);
+ return newWebView;
+ }
+
+ void viewReadyToShow(WebKitWebView* webView)
+ {
+ g_assert(webView != m_webView);
+ m_webViewEvents.append(ReadyToShow);
+ }
+};
+
+static void testWebViewAllowModalDialogs(ModalDialogsTest* test, gconstpointer)
+{
+ WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);
+ webkit_settings_set_allow_modal_dialogs(settings, TRUE);
+
+ test->loadHtml("<html><body onload=\"window.showModalDialog('data:text/html,<html><body/><script>window.close();</script></html>')\"></body></html>", 0);
+ test->waitUntilMainLoopFinishes();
+
+ Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, UIClientTest::Create);
+ g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
+ g_assert_cmpint(events[2], ==, UIClientTest::RunAsModal);
+ g_assert_cmpint(events[3], ==, UIClientTest::Close);
+}
+
+static void testWebViewDisallowModalDialogs(ModalDialogsTest* test, gconstpointer)
+{
+ WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);
+ webkit_settings_set_allow_modal_dialogs(settings, FALSE);
+
+ test->loadHtml("<html><body onload=\"window.showModalDialog('data:text/html,<html><body/><script>window.close();</script></html>')\"></body></html>", 0);
+ // We need to use a timeout here because the viewClose() function
+ // won't ever be called as the dialog won't be created.
+ test->wait(1);
+
+ Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
+ g_assert_cmpint(events.size(), ==, 0);
+}
+
+static void testWebViewJavaScriptDialogs(UIClientTest* test, gconstpointer)
+{
+ static const char* htmlOnLoadFormat = "<html><body onLoad=\"%s\"></body></html>";
+ static const char* jsAlertFormat = "alert('%s')";
+ static const char* jsConfirmFormat = "do { confirmed = confirm('%s'); } while (!confirmed); alert('confirmed');";
+ static const char* jsPromptFormat = "alert(prompt('%s', 'default'));";
+
+ test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_ALERT;
+ GOwnPtr<char> alertDialogMessage(g_strdup_printf(jsAlertFormat, kAlertDialogMessage));
+ GOwnPtr<char> alertHTML(g_strdup_printf(htmlOnLoadFormat, alertDialogMessage.get()));
+ test->loadHtml(alertHTML.get(), 0);
+ test->waitUntilMainLoopFinishes();
+
+ test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_CONFIRM;
+ GOwnPtr<char> confirmDialogMessage(g_strdup_printf(jsConfirmFormat, kConfirmDialogMessage));
+ GOwnPtr<char> confirmHTML(g_strdup_printf(htmlOnLoadFormat, confirmDialogMessage.get()));
+ test->loadHtml(confirmHTML.get(), 0);
+ test->waitUntilMainLoopFinishes();
+
+ test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_PROMPT;
+ GOwnPtr<char> promptDialogMessage(g_strdup_printf(jsPromptFormat, kPromptDialogMessage));
+ GOwnPtr<char> promptHTML(g_strdup_printf(htmlOnLoadFormat, promptDialogMessage.get()));
+ test->loadHtml(promptHTML.get(), 0);
+ test->waitUntilMainLoopFinishes();
+}
+
+static void testWebViewWindowProperties(UIClientTest* test, gconstpointer)
+{
+ static const char* windowProrpertiesString = "left=100,top=150,width=400,height=400,location=no,menubar=no,status=no,toolbar=no,scrollbars=no";
+ GdkRectangle geometry = { 100, 150, 400, 400 };
+ test->setExpectedWindowProperties(UIClientTest::WindowProperties(&geometry, false, false, false, false, false, true, false));
+
+ GOwnPtr<char> htmlString(g_strdup_printf("<html><body onLoad=\"window.open('', '', '%s').close();\"></body></html>", windowProrpertiesString));
+ test->loadHtml(htmlString.get(), 0);
+ test->waitUntilMainLoopFinishes();
+
+ static const char* propertiesChanged[] = {
+ "geometry", "locationbar-visible", "menubar-visible", "statusbar-visible", "toolbar-visible", "scrollbars-visible"
+ };
+ for (size_t i = 0; i < G_N_ELEMENTS(propertiesChanged); ++i)
+ g_assert(test->m_windowPropertiesChanged.contains(propertiesChanged[i]));
+
+ Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
+ g_assert_cmpint(events.size(), ==, 3);
+ g_assert_cmpint(events[0], ==, UIClientTest::Create);
+ g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
+ g_assert_cmpint(events[2], ==, UIClientTest::Close);
+}
+
+static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+
+ const char* linksHoveredHTML =
+ "<html><body>"
+ " <a style='position:absolute; left:1; top:1' href='http://www.webkitgtk.org' title='WebKitGTK+ Title'>WebKitGTK+ Website</a>"
+ " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>"
+ " <a style='position:absolute; left:1; top:20' href='http://www.webkitgtk.org/logo' title='WebKitGTK+ Logo'><img src='0xdeadbeef' width=5 height=5></img></a>"
+ " <input style='position:absolute; left:1; top:30' size='10'></input>"
+ " <div style='position:absolute; left:1; top:50; width:30; height:30; overflow:scroll'>&nbsp;</div>"
+ " <video style='position:absolute; left:1; top:100' width='300' height='300' controls='controls' preload='none'><source src='movie.ogg' type='video/ogg' /></video>"
+ "</body></html>";
+
+ test->loadHtml(linksHoveredHTML, "file:///");
+ test->waitUntilLoadFinished();
+
+ // Move over link.
+ WebKitHitTestResult* hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 1);
+ g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/");
+ g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Title");
+ g_assert_cmpstr(webkit_hit_test_result_get_link_label(hitTestResult), ==, "WebKitGTK+ Website");
+ g_assert(!test->m_mouseTargetModifiers);
+
+ // Move out of the link.
+ hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(0, 0);
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ g_assert(!test->m_mouseTargetModifiers);
+
+ // Move over image with GDK_CONTROL_MASK.
+ hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 10, GDK_CONTROL_MASK);
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
+ g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
+ g_assert(test->m_mouseTargetModifiers & GDK_CONTROL_MASK);
+
+ // Move over image link.
+ hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 20);
+ g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
+ g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/logo");
+ g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
+ g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Logo");
+ g_assert(!webkit_hit_test_result_get_link_label(hitTestResult));
+ g_assert(!test->m_mouseTargetModifiers);
+
+ // Move over media.
+ hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 100);
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
+ g_assert_cmpstr(webkit_hit_test_result_get_media_uri(hitTestResult), ==, "file:///movie.ogg");
+ g_assert(!test->m_mouseTargetModifiers);
+
+ // Mover over input.
+ hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 35);
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_editable(hitTestResult));
+ g_assert(!test->m_mouseTargetModifiers);
+
+ // Move over scrollbar.
+ hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 75);
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_scrollbar(hitTestResult));
+ g_assert(!test->m_mouseTargetModifiers);
+}
+
+static void testWebViewPermissionRequests(UIClientTest* test, gconstpointer)
+{
+ // Some versions of geoclue give a runtime warning because it tries
+ // to register the error quark twice. See https://bugs.webkit.org/show_bug.cgi?id=89858.
+ // Make warnings non-fatal for this test to make it pass.
+ test->removeLogFatalFlag(G_LOG_LEVEL_WARNING);
+ test->showInWindowAndWaitUntilMapped();
+ static const char* geolocationRequestHTML =
+ "<html>"
+ " <script>"
+ " function runTest()"
+ " {"
+ " navigator.geolocation.getCurrentPosition(function(p) { document.title = \"OK\" },"
+ " function(e) { document.title = e.code });"
+ " }"
+ " </script>"
+ " <body onload='runTest();'></body>"
+ "</html>";
+
+ // Test denying a permission request.
+ test->m_allowPermissionRequests = false;
+ test->loadHtml(geolocationRequestHTML, 0);
+ test->waitUntilTitleChanged();
+
+ // According to the Geolocation API specification, '1' is the
+ // error code returned for the PERMISSION_DENIED error.
+ // http://dev.w3.org/geo/api/spec-source.html#position_error_interface
+ const gchar* result = webkit_web_view_get_title(test->m_webView);
+ g_assert_cmpstr(result, ==, "1");
+
+ // Test allowing a permission request.
+ test->m_allowPermissionRequests = true;
+ test->loadHtml(geolocationRequestHTML, 0);
+ test->waitUntilTitleChanged();
+
+ // Check that we did not get the PERMISSION_DENIED error now.
+ result = webkit_web_view_get_title(test->m_webView);
+ g_assert_cmpstr(result, !=, "1");
+ test->addLogFatalFlag(G_LOG_LEVEL_WARNING);
+}
+
+class FileChooserTest: public UIClientTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(FileChooserTest);
+
+ FileChooserTest()
+ {
+ g_signal_connect(m_webView, "run-file-chooser", G_CALLBACK(runFileChooserCallback), this);
+ }
+
+ static gboolean runFileChooserCallback(WebKitWebView*, WebKitFileChooserRequest* request, FileChooserTest* test)
+ {
+ test->runFileChooser(request);
+ return TRUE;
+ }
+
+ void runFileChooser(WebKitFileChooserRequest* request)
+ {
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+ m_fileChooserRequest = request;
+ g_main_loop_quit(m_mainLoop);
+ }
+
+ WebKitFileChooserRequest* clickMouseButtonAndWaitForFileChooserRequest(int x, int y)
+ {
+ clickMouseButton(x, y);
+ g_main_loop_run(m_mainLoop);
+ return m_fileChooserRequest.get();
+ }
+
+private:
+ GRefPtr<WebKitFileChooserRequest> m_fileChooserRequest;
+};
+
+static void testWebViewFileChooserRequest(FileChooserTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+ static const char* fileChooserHTMLFormat = "<html><body><input style='position:absolute;left:0;top:0;margin:0;padding:0' type='file' %s/></body></html>";
+
+ // Multiple selections not allowed, no MIME filtering.
+ GOwnPtr<char> simpleFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, ""));
+ test->loadHtml(simpleFileUploadHTML.get(), 0);
+ test->waitUntilLoadFinished();
+ WebKitFileChooserRequest* fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
+ g_assert(!webkit_file_chooser_request_get_select_multiple(fileChooserRequest));
+
+ const gchar* const* mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest);
+ g_assert(!mimeTypes);
+ GtkFileFilter* filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest);
+ g_assert(!filter);
+ const gchar* const* selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
+ g_assert(!selectedFiles);
+ webkit_file_chooser_request_cancel(fileChooserRequest);
+
+ // Multiple selections allowed, no MIME filtering, some pre-selected files.
+ GOwnPtr<char> multipleSelectionFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "multiple"));
+ test->loadHtml(multipleSelectionFileUploadHTML.get(), 0);
+ test->waitUntilLoadFinished();
+ fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
+ g_assert(webkit_file_chooser_request_get_select_multiple(fileChooserRequest));
+
+ mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest);
+ g_assert(!mimeTypes);
+ filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest);
+ g_assert(!filter);
+ selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
+ g_assert(!selectedFiles);
+
+ // Select some files.
+ const gchar* filesToSelect[4] = { "/foo", "/foo/bar", "/foo/bar/baz", 0 };
+ webkit_file_chooser_request_select_files(fileChooserRequest, filesToSelect);
+
+ // Check the files that have been just selected.
+ selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
+ g_assert(selectedFiles);
+ g_assert_cmpstr(selectedFiles[0], ==, "/foo");
+ g_assert_cmpstr(selectedFiles[1], ==, "/foo/bar");
+ g_assert_cmpstr(selectedFiles[2], ==, "/foo/bar/baz");
+ g_assert(!selectedFiles[3]);
+
+ // Perform another request to check if the list of files selected
+ // in the previous step appears now as part of the new request.
+ fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
+ selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
+ g_assert(selectedFiles);
+ g_assert_cmpstr(selectedFiles[0], ==, "/foo");
+ g_assert_cmpstr(selectedFiles[1], ==, "/foo/bar");
+ g_assert_cmpstr(selectedFiles[2], ==, "/foo/bar/baz");
+ g_assert(!selectedFiles[3]);
+ webkit_file_chooser_request_cancel(fileChooserRequest);
+
+ // Multiple selections not allowed, only accept images, audio and video files..
+ GOwnPtr<char> mimeFilteredFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "accept='audio/*,video/*,image/*'"));
+ test->loadHtml(mimeFilteredFileUploadHTML.get(), 0);
+ test->waitUntilLoadFinished();
+ fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
+ g_assert(!webkit_file_chooser_request_get_select_multiple(fileChooserRequest));
+
+ mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest);
+ g_assert(mimeTypes);
+ g_assert_cmpstr(mimeTypes[0], ==, "audio/*");
+ g_assert_cmpstr(mimeTypes[1], ==, "video/*");
+ g_assert_cmpstr(mimeTypes[2], ==, "image/*");
+ g_assert(!mimeTypes[3]);
+
+ filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest);
+ g_assert(GTK_IS_FILE_FILTER(filter));
+ g_assert(checkMimeTypeForFilter(filter, "audio/*"));
+ g_assert(checkMimeTypeForFilter(filter, "video/*"));
+ g_assert(checkMimeTypeForFilter(filter, "image/*"));
+
+ selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
+ g_assert(!selectedFiles);
+ webkit_file_chooser_request_cancel(fileChooserRequest);
+}
+
+void beforeAll()
+{
+ UIClientTest::add("WebKitWebView", "create-ready-close", testWebViewCreateReadyClose);
+ ModalDialogsTest::add("WebKitWebView", "allow-modal-dialogs", testWebViewAllowModalDialogs);
+ ModalDialogsTest::add("WebKitWebView", "disallow-modal-dialogs", testWebViewDisallowModalDialogs);
+ UIClientTest::add("WebKitWebView", "javascript-dialogs", testWebViewJavaScriptDialogs);
+ UIClientTest::add("WebKitWebView", "window-properties", testWebViewWindowProperties);
+ UIClientTest::add("WebKitWebView", "mouse-target", testWebViewMouseTarget);
+ UIClientTest::add("WebKitWebView", "permission-requests", testWebViewPermissionRequests);
+ FileChooserTest::add("WebKitWebView", "file-chooser-request", testWebViewFileChooserRequest);
+}
+
+void afterAll()
+{
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestUIClientcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebExtensionscppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestWebExtensionscpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebExtensions.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,195 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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,1 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 "WebKitTestBus.h"
+#include "WebViewTest.h"
+#include <wtf/gobject/GRefPtr.h>
+
+static WebKitTestBus* bus;
+
+static void testWebExtensionGetTitle(WebViewTest* test, gconstpointer)
+{
+ test->loadHtml("<html><head><title>WebKitGTK+ Web Extensions Test</title></head><body></body></html>", 0);
+ test->waitUntilLoadFinished();
+
+ GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
+ "/org/webkit/gtk/WebExtensionTest" , "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
+ GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync(
+ proxy.get(),
+ "GetTitle",
+ g_variant_new("(t)", webkit_web_view_get_page_id(test->m_webView)),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, 0, 0));
+ g_assert(result);
+
+ const char* title;
+ g_variant_get(result.get(), "(&s)", &title);
+ g_assert_cmpstr(title, ==, "WebKitGTK+ Web Extensions Test");
+}
+
+static void documentLoadedCallback(GDBusConnection*, const char*, const char*, const char*, const char*, GVariant*, WebViewTest* test)
+{
+ g_main_loop_quit(test->m_mainLoop);
+}
+
+static void testDocumentLoadedSignal(WebViewTest* test, gconstpointer)
+{
+ GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
+ "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
+ GDBusConnection* connection = g_dbus_proxy_get_connection(proxy.get());
+ guint id = g_dbus_connection_signal_subscribe(connection,
+ 0,
+ "org.webkit.gtk.WebExtensionTest",
+ "DocumentLoaded",
+ "/org/webkit/gtk/WebExtensionTest",
+ 0,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ reinterpret_cast<GDBusSignalCallback>(documentLoadedCallback),
+ test,
+ 0);
+ g_assert(id);
+
+ test->loadHtml("<html><head><title>WebKitGTK+ Web Extensions Test</title></head><body></body></html>", 0);
+ g_main_loop_run(test->m_mainLoop);
+ g_dbus_connection_signal_unsubscribe(connection, id);
+}
+
+static gboolean webProcessCrashedCallback(WebKitWebView*, WebViewTest* test)
+{
+ test->quitMainLoop();
+
+ return FALSE;
+}
+
+static void testWebKitWebViewProcessCrashed(WebViewTest* test, gconstpointer)
+{
+ test->loadHtml("<html></html>", 0);
+ test->waitUntilLoadFinished();
+
+ g_signal_connect(test->m_webView, "web-process-crashed",
+ G_CALLBACK(webProcessCrashedCallback), test);
+
+ GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
+ "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
+
+ GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync(
+ proxy.get(),
+ "AbortProcess",
+ 0,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, 0, 0));
+ g_assert(!result);
+ g_main_loop_run(test->m_mainLoop);
+}
+
+static void testWebExtensionWindowObjectCleared(WebViewTest* test, gconstpointer)
+{
+ test->loadHtml("<html><header></header><body></body></html>", 0);
+ test->waitUntilLoadFinished();
+
+ GOwnPtr<GError> error;
+ WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.echo('Foo');", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ GOwnPtr<char> valueString(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "Foo");
+}
+
+static gboolean scriptDialogCallback(WebKitWebView*, WebKitScriptDialog* dialog, char** result)
+{
+ g_assert_cmpuint(webkit_script_dialog_get_dialog_type(dialog), ==, WEBKIT_SCRIPT_DIALOG_ALERT);
+ g_assert(!*result);
+ *result = g_strdup(webkit_script_dialog_get_message(dialog));
+ return TRUE;
+}
+
+static void runJavaScriptInIsolatedWorldFinishedCallback(GDBusProxy* proxy, GAsyncResult* result, WebViewTest* test)
+{
+ g_dbus_proxy_call_finish(proxy, result, 0);
+ g_main_loop_quit(test->m_mainLoop);
+}
+
+static void testWebExtensionIsolatedWorld(WebViewTest* test, gconstpointer)
+{
+ test->loadHtml("<html><header></header><body><div id='console'></div></body></html>", 0);
+ test->waitUntilLoadFinished();
+
+ GOwnPtr<char> result;
+ gulong scriptDialogID = g_signal_connect(test->m_webView, "script-dialog", G_CALLBACK(scriptDialogCallback), &result.outPtr());
+
+ static const char* mainWorldScript =
+ "top.foo = 'Foo';\n"
+ "document.getElementById('console').innerHTML = top.foo;\n"
+ "window.open = function () { alert('Main World'); }\n"
+ "document.open(1, 2, 3);";
+ test->runJavaScriptAndWaitUntilFinished(mainWorldScript, 0);
+ g_assert_cmpstr(result.get(), ==, "Main World");
+ result.clear();
+
+ WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.getElementById('console').innerHTML", 0);
+ g_assert(javascriptResult);
+ GOwnPtr<char> valueString(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "Foo");
+
+ static const char* isolatedWorldScript =
+ "document.getElementById('console').innerHTML = top.foo;\n"
+ "window.open = function () { alert('Isolated World'); }\n"
+ "document.open(1, 2, 3);";
+ GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
+ "/org/webkit/gtk/WebExtensionTest" , "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
+ g_dbus_proxy_call(proxy.get(),
+ "RunJavaScriptInIsolatedWorld",
+ g_variant_new("(t&s)", webkit_web_view_get_page_id(test->m_webView), isolatedWorldScript),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, 0,
+ reinterpret_cast<GAsyncReadyCallback>(runJavaScriptInIsolatedWorldFinishedCallback),
+ test);
+ g_main_loop_run(test->m_mainLoop);
+ g_assert_cmpstr(result.get(), ==, "Isolated World");
+ result.clear();
+
+ // Check that 'top.foo' defined in main world is not visible in isolated world.
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.getElementById('console').innerHTML", 0);
+ g_assert(javascriptResult);
+ valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "undefined");
+
+ g_signal_handler_disconnect(test->m_webView, scriptDialogID);
+}
+
+void beforeAll()
+{
+ webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+ bus = new WebKitTestBus();
+ if (!bus->run())
+ return;
+
+ WebViewTest::add("WebKitWebExtension", "dom-document-title", testWebExtensionGetTitle);
+ WebViewTest::add("WebKitWebExtension", "document-loaded-signal", testDocumentLoadedSignal);
+ WebViewTest::add("WebKitWebView", "web-process-crashed", testWebKitWebViewProcessCrashed);
+ WebViewTest::add("WebKitWebExtension", "window-object-cleared", testWebExtensionWindowObjectCleared);
+ WebViewTest::add("WebKitWebExtension", "isolated-world", testWebExtensionIsolatedWorld);
+}
+
+void afterAll()
+{
+ delete bus;
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebExtensionscpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitAccessibilitycppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestWebKitAccessibilitycpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitAccessibility.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitAccessibility.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitAccessibility.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitAccessibility.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,224 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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,1 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 "TestMain.h"
+#include "WebViewTest.h"
+
+// The libatspi headers don't use G_BEGIN_DECLS
+extern "C" {
+#include <atspi/atspi.h>
+}
+
+#include <errno.h>
+#include <fcntl.h>
+#include <glib.h>
+#include <signal.h>
+#include <unistd.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/gobject/GRefPtr.h>
+
+// Name of the test server application creating the webView object.
+static const char* kTestServerAppName = "AccessibilityTestServer";
+
+// Max seconds to wait for the test server before inspecting it.
+static const int kMaxWaitForChild = 5;
+
+// The PID for the test server running, so we can kill it if needed.
+static GPid kChildProcessPid = 0;
+
+// Whether the child has replied and it's ready.
+static bool kChildIsReady = false;
+
+static void stopTestServer()
+{
+ // Do nothing if there's no server running.
+ if (!kChildProcessPid)
+ return;
+
+ g_spawn_close_pid(kChildProcessPid);
+ kill(kChildProcessPid, SIGTERM);
+ kChildProcessPid = 0;
+}
+
+static void sigAbortHandler(int sigNum)
+{
+ // Just stop the test server if SIGABRT was received.
+ stopTestServer();
+}
+
+static gpointer testServerMonitorThreadFunc(gpointer)
+{
+ // Wait for the specified timeout to happen.
+ g_usleep(kMaxWaitForChild * G_USEC_PER_SEC);
+
+ // Kill the child process if not ready yet.
+ if (!kChildIsReady)
+ stopTestServer();
+
+ g_thread_exit(0);
+ return 0;
+}
+
+static void startTestServerMonitor()
+{
+ kChildIsReady = false;
+ g_thread_new("TestServerMonitor", testServerMonitorThreadFunc, 0);
+}
+
+static void startTestServer()
+{
+ // Prepare argv[] for spawning the server process.
+ GOwnPtr<char> testServerPath(g_build_filename(WEBKIT_EXEC_PATH, "TestWebKitAPI", "WebKit2Gtk", kTestServerAppName, NULL));
+
+ char* testServerArgv[2];
+ testServerArgv[0] = testServerPath.get();
+ testServerArgv[1] = 0;
+
+ // Spawn the server, getting its stdout file descriptor to set a
+ // communication channel, so we know when it's ready.
+ int childStdout = 0;
+ if (!g_spawn_async_with_pipes(0, testServerArgv, 0, static_cast<GSpawnFlags>(0), 0, 0, &kChildProcessPid, 0, &childStdout, 0, 0)) {
+ close(childStdout);
+ return;
+ }
+
+ // Start monitoring the test server (in a separate thread) to
+ // ensure we don't block on the child process more than a timeout.
+ startTestServerMonitor();
+
+ char msg[2];
+ GIOChannel* ioChannel = g_io_channel_unix_new(childStdout);
+ if (g_io_channel_read_chars(ioChannel, msg, 2, 0, 0) == G_IO_STATUS_NORMAL) {
+ // Check whether the server sent a message saying it's ready
+ // and store the result globally, so the monitor can see it.
+ kChildIsReady = msg[0] == 'O' && msg[1] == 'K';
+ }
+ g_io_channel_unref(ioChannel);
+ close(childStdout);
+
+ // The timeout was reached and the server is not ready yet, so
+ // stop it inmediately, and let the unit tests fail.
+ if (!kChildIsReady)
+ stopTestServer();
+}
+
+static void checkAtspiAccessible(AtspiAccessible* accessible, const char* targetName, AtspiRole targetRole)
+{
+ g_assert(ATSPI_IS_ACCESSIBLE(accessible));
+
+ GOwnPtr<char> name(atspi_accessible_get_name(accessible, 0));
+ g_assert_cmpstr(targetName, ==, name.get());
+ g_assert_cmpint(targetRole, ==, atspi_accessible_get_role(accessible, 0));
+}
+
+static GRefPtr<AtspiAccessible> findTestServerApplication()
+{
+ // Only one desktop is supported by ATSPI at the moment.
+ GRefPtr<AtspiAccessible> desktop = adoptGRef(atspi_get_desktop(0));
+
+ // Look for the server application in the list of apps.
+ GRefPtr<AtspiAccessible> current;
+ int childCount = atspi_accessible_get_child_count(desktop.get(), 0);
+ for (int i = 0; i < childCount; i++) {
+ current = adoptGRef(atspi_accessible_get_child_at_index(desktop.get(), i, 0));
+ if (!g_strcmp0(atspi_accessible_get_name(current.get(), 0), kTestServerAppName))
+ return current;
+ }
+
+ return 0;
+}
+
+static void testAtspiBasicHierarchy(WebViewTest* test, gconstpointer)
+{
+ // The test server's accessibility object (UI Process).
+ GRefPtr<AtspiAccessible> testServerApp = findTestServerApplication();
+ g_assert(ATSPI_IS_ACCESSIBLE(testServerApp.get()));
+ checkAtspiAccessible(testServerApp.get(), "AccessibilityTestServer", ATSPI_ROLE_APPLICATION);
+
+ // The main window's accessibility object (UI Process).
+ GRefPtr<AtspiAccessible> currentParent = testServerApp;
+ GRefPtr<AtspiAccessible> currentChild = adoptGRef(atspi_accessible_get_child_at_index(currentParent.get(), 0, 0));
+ g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
+ checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FRAME);
+
+ // The WebView's accessibility object (UI Process).
+ currentParent = currentChild;
+ currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
+ g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
+ checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FILLER);
+
+ // The WebPage's accessibility object (Web Process).
+ currentParent = currentChild;
+ currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
+ g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
+ checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FILLER);
+
+ // HTML root element's accessible element (Web Process).
+ currentParent = currentChild;
+ currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
+ g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
+
+ // HTML body's accessible element (Web Process).
+ currentParent = currentChild;
+ currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
+ g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
+ checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_DOCUMENT_WEB);
+
+ // HTML H1's accessible element (Web Process).
+ currentParent = currentChild;
+ currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
+ g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
+ checkAtspiAccessible(currentChild.get(), "This is a test", ATSPI_ROLE_HEADING);
+
+ // HTML first paragraph's accessible element (Web Process).
+ currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 1, 0);
+ g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
+ checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_PARAGRAPH);
+
+ // HTML second paragraph's accessible element (Web Process).
+ currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 2, 0);
+ g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
+ checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_PARAGRAPH);
+
+ // HTML link's accessible element (Web Process).
+ currentParent = currentChild;
+ currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
+ g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
+ checkAtspiAccessible(currentChild.get(), "a link", ATSPI_ROLE_LINK);
+}
+
+void beforeAll()
+{
+ // We install a handler to ensure that we kill the child process
+ // if the parent dies because of whatever the reason is.
+ signal(SIGABRT, sigAbortHandler);
+
+ // Start the accessibility test server and load the tests.
+ startTestServer();
+ WebViewTest::add("WebKitAccessibility", "atspi-basic-hierarchy", testAtspiBasicHierarchy);
+}
+
+void afterAll()
+{
+ // Ensure we stop the server.
+ stopTestServer();
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitAccessibilitycpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitAccessibility.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitFaviconDatabasecppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestWebKitFaviconDatabasecpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,274 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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,1 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 "WebKitTestServer.h"
+#include "WebViewTest.h"
+#include <glib/gstdio.h>
+#include <libsoup/soup.h>
+#include <wtf/gobject/GOwnPtr.h>
+
+static WebKitTestServer* kServer;
+static char* kTempDirectory;
+
+class FaviconDatabaseTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(FaviconDatabaseTest);
+
+ FaviconDatabaseTest()
+ : m_webContext(webkit_web_context_get_default())
+ , m_favicon(0)
+ , m_error(0)
+ , m_faviconNotificationReceived(false)
+ {
+ WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext);
+ g_signal_connect(database, "favicon-changed", G_CALLBACK(faviconChangedCallback), this);
+ }
+
+ ~FaviconDatabaseTest()
+ {
+ if (m_favicon)
+ cairo_surface_destroy(m_favicon);
+
+ WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext);
+ g_signal_handlers_disconnect_matched(database, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ static void faviconChangedCallback(WebKitFaviconDatabase* database, const char* pageURI, const char* faviconURI, FaviconDatabaseTest* test)
+ {
+ if (!g_strcmp0(webkit_web_view_get_uri(test->m_webView), pageURI))
+ test->m_faviconURI = faviconURI;
+ }
+
+ static void viewFaviconChangedCallback(WebKitWebView* webView, GParamSpec* pspec, gpointer data)
+ {
+ FaviconDatabaseTest* test = static_cast<FaviconDatabaseTest*>(data);
+ g_assert(test->m_webView == webView);
+ test->m_faviconNotificationReceived = true;
+ test->quitMainLoop();
+ }
+
+ static void getFaviconCallback(GObject* sourceObject, GAsyncResult* result, void* data)
+ {
+ FaviconDatabaseTest* test = static_cast<FaviconDatabaseTest*>(data);
+ WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext);
+ test->m_favicon = webkit_favicon_database_get_favicon_finish(database, result, &test->m_error.outPtr());
+ test->quitMainLoop();
+ }
+
+ void waitUntilFaviconChanged()
+ {
+ m_faviconNotificationReceived = false;
+ unsigned long handlerID = g_signal_connect(m_webView, "notify::favicon", G_CALLBACK(viewFaviconChangedCallback), this);
+ g_main_loop_run(m_mainLoop);
+ g_signal_handler_disconnect(m_webView, handlerID);
+ }
+
+ void getFaviconForPageURIAndWaitUntilReady(const char* pageURI)
+ {
+ m_error.clear();
+ if (m_favicon) {
+ cairo_surface_destroy(m_favicon);
+ m_favicon = 0;
+ }
+
+ WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext);
+ webkit_favicon_database_get_favicon(database, pageURI, 0, getFaviconCallback, this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ WebKitWebContext* m_webContext;
+ cairo_surface_t* m_favicon;
+ CString m_faviconURI;
+ GOwnPtr<GError> m_error;
+ bool m_faviconNotificationReceived;
+};
+
+static void
+serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable* query, SoupClientContext* context, void* data)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ if (g_str_equal(path, "/favicon.ico")) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+ soup_message_body_complete(message->response_body);
+ return;
+ }
+
+ char* contents;
+ gsize length;
+ if (g_str_equal(path, "/icon/favicon.ico")) {
+ GOwnPtr<char> pathToFavicon(g_build_filename(Test::getWebKit1TestResoucesDir().data(), "blank.ico", NULL));
+ g_file_get_contents(pathToFavicon.get(), &contents, &length, 0);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, length);
+ } else if (g_str_equal(path, "/nofavicon")) {
+ static const char* noFaviconHTML = "<html><head><body>test</body></html>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, noFaviconHTML, strlen(noFaviconHTML));
+ } else {
+ static const char* contentsHTML = "<html><head><link rel='icon' href='/icon/favicon.ico' type='image/x-ico; charset=binary'></head><body>test</body></html>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, contentsHTML, strlen(contentsHTML));
+ }
+
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_complete(message->response_body);
+}
+
+static void testNotInitialized(FaviconDatabaseTest* test)
+{
+ // Try to retrieve a valid favicon from a not initialized database.
+ test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/foo").data());
+ g_assert(!test->m_favicon);
+ g_assert(test->m_error);
+ g_assert_cmpint(test->m_error->code, ==, WEBKIT_FAVICON_DATABASE_ERROR_NOT_INITIALIZED);
+}
+
+static void testSetDirectory(FaviconDatabaseTest* test)
+{
+ webkit_web_context_set_favicon_database_directory(test->m_webContext, kTempDirectory);
+ g_assert_cmpstr(kTempDirectory, ==, webkit_web_context_get_favicon_database_directory(test->m_webContext));
+}
+
+static void testClearDatabase(FaviconDatabaseTest* test)
+{
+ WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext);
+ webkit_favicon_database_clear(database);
+
+ GOwnPtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, kServer->getURIForPath("/foo").data()));
+ g_assert(!iconURI);
+}
+
+static void testGetFavicon(FaviconDatabaseTest* test)
+{
+ // We need to load the page first to ensure the icon data will be
+ // in the database in case there's an associated favicon.
+ test->loadURI(kServer->getURIForPath("/foo").data());
+ test->waitUntilFaviconChanged();
+ CString faviconURI = kServer->getURIForPath("/icon/favicon.ico");
+
+ // Check the API retrieving a valid favicon.
+ test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/foo").data());
+ g_assert(test->m_favicon);
+ g_assert_cmpstr(test->m_faviconURI.data(), ==, faviconURI.data());
+ g_assert(!test->m_error);
+
+ // Check that width and height match those from blank.ico (16x16 favicon).
+ g_assert_cmpint(cairo_image_surface_get_width(test->m_favicon), ==, 16);
+ g_assert_cmpint(cairo_image_surface_get_height(test->m_favicon), ==, 16);
+
+ // Check that another page with the same favicon return the same icon.
+ cairo_surface_t* favicon = cairo_surface_reference(test->m_favicon);
+ test->loadURI(kServer->getURIForPath("/bar").data());
+ // It's a new page in the database, so favicon will change twice, first to reset it
+ // and then when the icon is loaded.
+ test->waitUntilFaviconChanged();
+ test->waitUntilFaviconChanged();
+ test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/bar").data());
+ g_assert(test->m_favicon);
+ g_assert_cmpstr(test->m_faviconURI.data(), ==, faviconURI.data());
+ g_assert(test->m_favicon == favicon);
+ g_assert(!test->m_error);
+ cairo_surface_destroy(favicon);
+
+ // Check the API retrieving an invalid favicon.
+ test->loadURI(kServer->getURIForPath("/nofavicon").data());
+ test->waitUntilFaviconChanged();
+
+ test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/nofavicon").data());
+ g_assert(!test->m_favicon);
+ g_assert(test->m_error);
+}
+
+static void testGetFaviconURI(FaviconDatabaseTest* test)
+{
+ WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext);
+
+ CString baseURI = kServer->getURIForPath("/foo");
+ GOwnPtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, baseURI.data()));
+ ASSERT_CMP_CSTRING(iconURI.get(), ==, kServer->getURIForPath("/icon/favicon.ico"));
+}
+
+static void testWebViewFavicon(FaviconDatabaseTest* test)
+{
+ test->m_faviconURI = CString();
+
+ cairo_surface_t* iconFromWebView = webkit_web_view_get_favicon(test->m_webView);
+ g_assert(!iconFromWebView);
+
+ test->loadURI(kServer->getURIForPath("/foo").data());
+ test->waitUntilFaviconChanged();
+ g_assert(test->m_faviconNotificationReceived);
+ // The icon is known and hasn't changed in the database, so notify::favicon is emitted
+ // but WebKitFaviconDatabase::icon-changed isn't.
+ g_assert(test->m_faviconURI.isNull());
+
+ iconFromWebView = webkit_web_view_get_favicon(test->m_webView);
+ g_assert(iconFromWebView);
+ g_assert_cmpuint(cairo_image_surface_get_width(iconFromWebView), ==, 16);
+ g_assert_cmpuint(cairo_image_surface_get_height(iconFromWebView), ==, 16);
+}
+
+static void testFaviconDatabase(FaviconDatabaseTest* test, gconstpointer)
+{
+ // These tests depend on this order to run properly so we declare them in a single one.
+ // See https://bugs.webkit.org/show_bug.cgi?id=111434.
+ testNotInitialized(test);
+ testSetDirectory(test);
+ testGetFavicon(test);
+ testGetFaviconURI(test);
+ testWebViewFavicon(test);
+ testClearDatabase(test);
+}
+
+void beforeAll()
+{
+ // Start a soup server for testing.
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0);
+ g_assert(kTempDirectory);
+
+ // Add tests to the suite.
+ FaviconDatabaseTest::add("WebKitFaviconDatabase", "favicon-database-test", testFaviconDatabase);
+}
+
+static void webkitFaviconDatabaseFinalizedCallback(gpointer, GObject*)
+{
+ if (!g_file_test(kTempDirectory, G_FILE_TEST_IS_DIR))
+ return;
+
+ GOwnPtr<char> filename(g_build_filename(kTempDirectory, "WebpageIcons.db", NULL));
+ g_unlink(filename.get());
+
+ g_rmdir(kTempDirectory);
+}
+
+void afterAll()
+{
+ delete kServer;
+
+ // Delete the temporary files after the IconDatabase has been
+ // closed, that is, once WebKitFaviconDatabase is being destroyed.
+ WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(webkit_web_context_get_default());
+ g_object_weak_ref(G_OBJECT(database), webkitFaviconDatabaseFinalizedCallback, 0);
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitFaviconDatabasecpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitFindControllercppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestWebKitFindControllercpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFindController.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFindController.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFindController.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFindController.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,335 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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,1 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 "LoadTrackingTest.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+#include <wtf/gobject/GRefPtr.h>
+
+static const char* testString = "<html><body>first testing second testing secondHalf</body></html>";
+
+class FindControllerTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(FindControllerTest);
+
+ FindControllerTest()
+ : m_findController(webkit_web_view_get_find_controller(m_webView))
+ , m_runFindUntilCompletion(false)
+ {
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_findController.get()));
+ }
+
+ ~FindControllerTest()
+ {
+ if (m_findController)
+ g_signal_handlers_disconnect_matched(m_findController.get(), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void find(const char* searchText, guint32 findOptions, guint maxMatchCount)
+ {
+ g_signal_connect(m_findController.get(), "found-text", G_CALLBACK(foundTextCallback), this);
+ g_signal_connect(m_findController.get(), "failed-to-find-text", G_CALLBACK(failedToFindTextCallback), this);
+ webkit_find_controller_search(m_findController.get(), searchText, findOptions, maxMatchCount);
+ }
+
+ void count(const char* searchText, guint32 findOptions, guint maxMatchCount)
+ {
+ g_signal_connect(m_findController.get(), "counted-matches", G_CALLBACK(countedMatchesCallback), this);
+ webkit_find_controller_count_matches(m_findController.get(), searchText, findOptions, maxMatchCount);
+ }
+
+ void waitUntilFindFinished()
+ {
+ m_runFindUntilCompletion = true;
+ g_main_loop_run(m_mainLoop);
+ }
+
+ GRefPtr<WebKitFindController> m_findController;
+ bool m_textFound;
+ unsigned m_matchCount;
+
+private:
+ bool m_runFindUntilCompletion;
+
+ static void foundTextCallback(WebKitFindController*, guint matchCount, FindControllerTest* test)
+ {
+ test->m_textFound = true;
+ test->m_matchCount = matchCount;
+ if (test->m_runFindUntilCompletion)
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ static void failedToFindTextCallback(WebKitFindController*, FindControllerTest* test)
+ {
+ test->m_textFound = false;
+ if (test->m_runFindUntilCompletion)
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ static void countedMatchesCallback(WebKitFindController*, guint matchCount, FindControllerTest* test)
+ {
+ test->m_matchCount = matchCount;
+ if (test->m_runFindUntilCompletion)
+ g_main_loop_quit(test->m_mainLoop);
+ }
+};
+
+static void testFindControllerTextFound(FindControllerTest* test, gconstpointer)
+{
+ test->loadHtml(testString, 0);
+ test->waitUntilLoadFinished();
+
+ test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 1);
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_textFound);
+}
+
+static void testFindControllerTextNotFound(FindControllerTest* test, gconstpointer)
+{
+ test->loadHtml(testString, 0);
+ test->waitUntilLoadFinished();
+
+ test->find("notFound", WEBKIT_FIND_OPTIONS_NONE, 1);
+ test->waitUntilFindFinished();
+
+ g_assert(!test->m_textFound);
+}
+
+static void testFindControllerMatchCount(FindControllerTest* test, gconstpointer)
+{
+ test->loadHtml(testString, 0);
+ test->waitUntilLoadFinished();
+
+ test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_matchCount == 2);
+ g_assert(test->m_textFound);
+}
+
+static void testFindControllerMaxMatchCount(FindControllerTest* test, gconstpointer)
+{
+ test->loadHtml(testString, 0);
+ test->waitUntilLoadFinished();
+
+ test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 1);
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_matchCount == G_MAXUINT);
+ g_assert(test->m_textFound);
+}
+
+static void testFindControllerNext(FindControllerTest* test, gconstpointer)
+{
+ test->loadHtml(testString, 0);
+ test->waitUntilLoadFinished();
+
+ test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_textFound);
+ g_assert(test->m_matchCount == 2);
+
+ webkit_find_controller_search_next(test->m_findController.get());
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_textFound);
+ g_assert(test->m_matchCount == 1);
+ g_assert(!(webkit_find_controller_get_options(test->m_findController.get()) & WEBKIT_FIND_OPTIONS_BACKWARDS));
+
+ webkit_find_controller_search_next(test->m_findController.get());
+ test->waitUntilFindFinished();
+
+ g_assert(!test->m_textFound);
+ g_assert(test->m_matchCount == 1);
+ g_assert(!(webkit_find_controller_get_options(test->m_findController.get()) & WEBKIT_FIND_OPTIONS_BACKWARDS));
+}
+
+static void testFindControllerPrevious(FindControllerTest* test, gconstpointer)
+{
+ test->loadHtml(testString, 0);
+ test->waitUntilLoadFinished();
+
+ test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_matchCount == 2);
+ g_assert(test->m_textFound);
+
+ webkit_find_controller_search_next(test->m_findController.get());
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_textFound);
+ g_assert(test->m_matchCount == 1);
+ g_assert(!(webkit_find_controller_get_options(test->m_findController.get()) & WEBKIT_FIND_OPTIONS_BACKWARDS));
+
+ webkit_find_controller_search_previous(test->m_findController.get());
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_textFound);
+ g_assert(test->m_matchCount == 1);
+ g_assert(webkit_find_controller_get_options(test->m_findController.get()) & WEBKIT_FIND_OPTIONS_BACKWARDS);
+}
+
+static void testFindControllerCountedMatches(FindControllerTest* test, gconstpointer)
+{
+ test->loadHtml(testString, 0);
+ test->waitUntilLoadFinished();
+
+ test->count("testing", WEBKIT_FIND_OPTIONS_NONE, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_matchCount == 2);
+
+ test->count("first", WEBKIT_FIND_OPTIONS_NONE, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_matchCount == 1);
+
+ test->count("notFound", WEBKIT_FIND_OPTIONS_NONE, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(!test->m_matchCount);
+}
+
+static void testFindControllerOptions(FindControllerTest* test, gconstpointer)
+{
+ test->loadHtml(testString, 0);
+ test->waitUntilLoadFinished();
+
+ test->find("Testing", WEBKIT_FIND_OPTIONS_NONE, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(!test->m_textFound);
+
+ test->find("Testing", WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_textFound);
+
+ test->find("esting", WEBKIT_FIND_OPTIONS_NONE, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_textFound);
+
+ test->find("esting", WEBKIT_FIND_OPTIONS_AT_WORD_STARTS, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(!test->m_textFound);
+
+ test->find("Half", WEBKIT_FIND_OPTIONS_AT_WORD_STARTS, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(!test->m_textFound);
+
+ test->find("Half", WEBKIT_FIND_OPTIONS_AT_WORD_STARTS | WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, 2);
+ test->waitUntilFindFinished();
+
+ g_assert(test->m_textFound);
+
+ test->find("testing", WEBKIT_FIND_OPTIONS_WRAP_AROUND, 3);
+ test->waitUntilFindFinished();
+ g_assert(test->m_textFound);
+
+ webkit_find_controller_search_next(test->m_findController.get());
+ test->waitUntilFindFinished();
+ g_assert(test->m_textFound);
+
+ webkit_find_controller_search_next(test->m_findController.get());
+ test->waitUntilFindFinished();
+ g_assert(test->m_textFound);
+}
+
+static void testFindControllerHide(FindControllerTest* test, gconstpointer)
+{
+ test->loadHtml(testString, 0);
+ test->waitUntilLoadFinished();
+
+ test->showInWindowAndWaitUntilMapped();
+
+ cairo_surface_t* originalSurface = cairo_surface_reference(
+ test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE));
+ g_assert(originalSurface);
+
+ test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 1);
+ test->waitUntilFindFinished();
+ g_assert(test->m_textFound);
+
+ cairo_surface_t* highlightSurface = cairo_surface_reference(
+ test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE));
+ g_assert(highlightSurface);
+ g_assert(!Test::cairoSurfacesEqual(originalSurface, highlightSurface));
+
+ WebKitFindController* findController = webkit_web_view_get_find_controller(test->m_webView);
+ webkit_find_controller_search_finish(findController);
+ webkit_web_view_execute_editing_command(test->m_webView, "Unselect");
+
+ cairo_surface_t* unhighlightSurface = cairo_surface_reference(
+ test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE));
+ g_assert(unhighlightSurface);
+ g_assert(Test::cairoSurfacesEqual(originalSurface, unhighlightSurface));
+
+ cairo_surface_destroy(originalSurface);
+ cairo_surface_destroy(highlightSurface);
+ cairo_surface_destroy(unhighlightSurface);
+}
+
+static void testFindControllerInstance(FindControllerTest* test, gconstpointer)
+{
+ WebKitFindController* findController1 = webkit_web_view_get_find_controller(test->m_webView);
+ WebKitFindController* findController2 = webkit_web_view_get_find_controller(test->m_webView);
+
+ g_assert(findController1 == findController2);
+}
+
+static void testFindControllerGetters(FindControllerTest* test, gconstpointer)
+{
+ const char* searchText = "testing";
+ guint maxMatchCount = 1;
+ guint32 findOptions = WEBKIT_FIND_OPTIONS_WRAP_AROUND | WEBKIT_FIND_OPTIONS_AT_WORD_STARTS;
+ WebKitFindController* findController = webkit_web_view_get_find_controller(test->m_webView);
+
+ webkit_find_controller_search(findController, searchText, findOptions, maxMatchCount);
+ g_assert(webkit_find_controller_get_web_view(findController) == test->m_webView);
+ g_assert(!g_strcmp0(webkit_find_controller_get_search_text(findController), searchText));
+ g_assert(webkit_find_controller_get_max_match_count(findController) == maxMatchCount);
+ g_assert(webkit_find_controller_get_options(findController) == findOptions);
+}
+
+void beforeAll()
+{
+ FindControllerTest::add("WebKitFindController", "getters", testFindControllerGetters);
+ FindControllerTest::add("WebKitFindController", "instance", testFindControllerInstance);
+ FindControllerTest::add("WebKitFindController", "text-found", testFindControllerTextFound);
+ FindControllerTest::add("WebKitFindController", "text-not-found", testFindControllerTextNotFound);
+ FindControllerTest::add("WebKitFindController", "match-count", testFindControllerMatchCount);
+ FindControllerTest::add("WebKitFindController", "max-match-count", testFindControllerMaxMatchCount);
+ FindControllerTest::add("WebKitFindController", "next", testFindControllerNext);
+ FindControllerTest::add("WebKitFindController", "previous", testFindControllerPrevious);
+ FindControllerTest::add("WebKitFindController", "counted-matches", testFindControllerCountedMatches);
+ FindControllerTest::add("WebKitFindController", "options", testFindControllerOptions);
+ FindControllerTest::add("WebKitFindController", "hide", testFindControllerHide);
+}
+
+void afterAll()
+{
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitFindControllercpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFindController.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitPolicyClientcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestWebKitPolicyClientcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,267 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 "LoadTrackingTest.h"
+#include "WebKitTestServer.h"
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+static WebKitTestServer* kServer;
+
+class PolicyClientTest: public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(PolicyClientTest);
+
+ enum PolicyDecisionResponse {
+ Use,
+ Ignore,
+ Download,
+ None
+ };
+
+ PolicyClientTest()
+ : LoadTrackingTest()
+ , m_policyDecisionResponse(None)
+ , m_policyDecisionTypeFilter(0)
+ , m_respondToPolicyDecisionAsynchronously(false)
+ , m_haltMainLoopAfterMakingDecision(false)
+ {
+ g_signal_connect(m_webView, "decide-policy", G_CALLBACK(decidePolicyCallback), this);
+ }
+
+ static gboolean quitMainLoopLater(GMainLoop* loop)
+ {
+ g_main_loop_quit(loop);
+ return FALSE;
+ }
+
+ static void respondToPolicyDecision(PolicyClientTest* test, WebKitPolicyDecision* decision)
+ {
+ switch (test->m_policyDecisionResponse) {
+ case Use:
+ webkit_policy_decision_use(decision);
+ break;
+ case Ignore:
+ webkit_policy_decision_ignore(decision);
+ break;
+ case Download:
+ webkit_policy_decision_download(decision);
+ break;
+ case None:
+ break;
+ }
+
+ if (test->m_haltMainLoopAfterMakingDecision)
+ g_idle_add(reinterpret_cast<GSourceFunc>(quitMainLoopLater), test->m_mainLoop);
+ }
+
+ static gboolean respondToPolicyDecisionLater(PolicyClientTest* test)
+ {
+ respondToPolicyDecision(test, test->m_previousPolicyDecision.get());
+ test->m_previousPolicyDecision = 0;
+ return FALSE;
+ }
+
+ static gboolean decidePolicyCallback(WebKitWebView* webView, WebKitPolicyDecision* decision, WebKitPolicyDecisionType type, PolicyClientTest* test)
+ {
+ if (test->m_policyDecisionTypeFilter != type)
+ return FALSE;
+
+ test->m_previousPolicyDecision = decision;
+ if (test->m_respondToPolicyDecisionAsynchronously) {
+ g_idle_add(reinterpret_cast<GSourceFunc>(respondToPolicyDecisionLater), test);
+ return TRUE;
+ }
+
+ respondToPolicyDecision(test, decision);
+
+ // We return FALSE here to ensure that the default policy decision
+ // handler doesn't override whatever we use here.
+ return FALSE;
+ }
+
+ PolicyDecisionResponse m_policyDecisionResponse;
+ int m_policyDecisionTypeFilter;
+ bool m_respondToPolicyDecisionAsynchronously;
+ bool m_haltMainLoopAfterMakingDecision;
+ GRefPtr<WebKitPolicyDecision> m_previousPolicyDecision;
+};
+
+static void testNavigationPolicy(PolicyClientTest* test, gconstpointer)
+{
+ test->m_policyDecisionTypeFilter = WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION;
+
+ test->m_policyDecisionResponse = PolicyClientTest::Use;
+ test->loadHtml("<html/>", "http://webkitgtk.org/");
+ test->waitUntilLoadFinished();
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+
+ // Ideally we'd like to have a more intensive test here, but it's still pretty tricky
+ // to trigger different types of navigations with the GTK+ WebKit2 API.
+ WebKitNavigationPolicyDecision* decision = WEBKIT_NAVIGATION_POLICY_DECISION(test->m_previousPolicyDecision.get());
+ g_assert_cmpint(webkit_navigation_policy_decision_get_navigation_type(decision), ==, WEBKIT_NAVIGATION_TYPE_OTHER);
+ g_assert_cmpint(webkit_navigation_policy_decision_get_mouse_button(decision), ==, 0);
+ g_assert_cmpint(webkit_navigation_policy_decision_get_modifiers(decision), ==, 0);
+ g_assert_cmpstr(webkit_navigation_policy_decision_get_frame_name(decision), ==, 0);
+ WebKitURIRequest* request = webkit_navigation_policy_decision_get_request(decision);
+ g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, "http://webkitgtk.org/");
+
+ test->m_policyDecisionResponse = PolicyClientTest::Use;
+ test->m_respondToPolicyDecisionAsynchronously = true;
+ test->loadHtml("<html/>", "http://webkitgtk.org/");
+ test->waitUntilLoadFinished();
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+
+ // If we are waiting until load completion, it will never complete if we ignore the
+ // navigation. So we tell the main loop to quit sometime later.
+ test->m_policyDecisionResponse = PolicyClientTest::Ignore;
+ test->m_respondToPolicyDecisionAsynchronously = false;
+ test->m_haltMainLoopAfterMakingDecision = true;
+ test->loadHtml("<html/>", "http://webkitgtk.org/");
+ test->waitUntilLoadFinished();
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 0);
+
+ test->m_policyDecisionResponse = PolicyClientTest::Ignore;
+ test->loadHtml("<html/>", "http://webkitgtk.org/");
+ test->waitUntilLoadFinished();
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 0);
+}
+
+static void testResponsePolicy(PolicyClientTest* test, gconstpointer)
+{
+ test->m_policyDecisionTypeFilter = WEBKIT_POLICY_DECISION_TYPE_RESPONSE;
+
+ test->m_policyDecisionResponse = PolicyClientTest::Use;
+ test->loadURI(kServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+ g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+
+ WebKitResponsePolicyDecision* decision = WEBKIT_RESPONSE_POLICY_DECISION(test->m_previousPolicyDecision.get());
+ WebKitURIRequest* request = webkit_response_policy_decision_get_request(decision);
+ g_assert(WEBKIT_IS_URI_REQUEST(request));
+ ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, kServer->getURIForPath("/"));
+ WebKitURIResponse* response = webkit_response_policy_decision_get_response(decision);
+ g_assert(WEBKIT_IS_URI_RESPONSE(response));
+ ASSERT_CMP_CSTRING(webkit_uri_response_get_uri(response), ==, kServer->getURIForPath("/"));
+ g_assert(webkit_web_view_can_show_mime_type(test->m_webView, webkit_uri_response_get_mime_type(response)) ==
+ webkit_response_policy_decision_is_mime_type_supported(decision));
+
+ test->m_respondToPolicyDecisionAsynchronously = true;
+ test->loadURI(kServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+ g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+
+ test->m_respondToPolicyDecisionAsynchronously = false;
+ test->m_policyDecisionResponse = PolicyClientTest::Ignore;
+ test->loadURI(kServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+
+ g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+ g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::ProvisionalLoadFailed);
+ g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+}
+
+struct CreateCallbackData {
+ bool triedToOpenWindow;
+ GMainLoop* mainLoop;
+};
+
+static WebKitWebView* createCallback(WebKitWebView* webView, CreateCallbackData* data)
+{
+ data->triedToOpenWindow = true;
+ g_main_loop_quit(data->mainLoop);
+ return 0;
+}
+
+static void testNewWindowPolicy(PolicyClientTest* test, gconstpointer)
+{
+ static const char* windowOpeningHTML =
+ "<html><body>"
+ " <a id=\"link\" href=\"http://www.google.com\" target=\"_blank\">Link</a>"
+ " <script>"
+ " var event = document.createEvent('MouseEvents');"
+ " event.initEvent('click', true, false);"
+ " document.getElementById('link').dispatchEvent(event);"
+ " </script>"
+ "</body></html>";
+ test->m_policyDecisionTypeFilter = WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION;
+ webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(test->m_webView), TRUE);
+
+ CreateCallbackData data;
+ data.triedToOpenWindow = false;
+ data.mainLoop = test->m_mainLoop;
+
+ g_signal_connect(test->m_webView, "create", G_CALLBACK(createCallback), &data);
+ test->m_policyDecisionResponse = PolicyClientTest::Use;
+ test->loadHtml(windowOpeningHTML, "http://webkitgtk.org/");
+ test->wait(1);
+ g_assert(data.triedToOpenWindow);
+
+ WebKitNavigationPolicyDecision* decision = WEBKIT_NAVIGATION_POLICY_DECISION(test->m_previousPolicyDecision.get());
+ g_assert_cmpstr(webkit_navigation_policy_decision_get_frame_name(decision), ==, "_blank");
+
+ // Using a short timeout is a bit ugly here, but it's hard to get around because if we block
+ // the new window signal we cannot halt the main loop in the create callback. If we
+ // halt the main loop in the policy decision, the create callback never executes.
+ data.triedToOpenWindow = false;
+ test->m_policyDecisionResponse = PolicyClientTest::Ignore;
+ test->loadHtml(windowOpeningHTML, "http://webkitgtk.org/");
+ test->wait(.2);
+ g_assert(!data.triedToOpenWindow);
+}
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ if (g_str_equal(path, "/")) {
+ static const char* responseString = "<html><body>Testing!</body></html>";
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString));
+ soup_message_body_complete(message->response_body);
+ } else
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+}
+
+void beforeAll()
+{
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ PolicyClientTest::add("WebKitPolicyClient", "navigation-policy", testNavigationPolicy);
+ PolicyClientTest::add("WebKitPolicyClient", "response-policy", testResponsePolicy);
+ PolicyClientTest::add("WebKitPolicyClient", "new-window-policy", testNewWindowPolicy);
+}
+
+void afterAll()
+{
+ delete kServer;
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitPolicyClientcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitSettingscppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestWebKitSettingscpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,371 @@
</span><ins>+/*
+ * Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * Neither the name of Motorola Mobility, Inc. nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "TestMain.h"
+#include "WebViewTest.h"
+#include "WebKitTestServer.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+#include <wtf/gobject/GRefPtr.h>
+
+static WebKitTestServer* gServer;
+
+static void testWebKitSettings(Test*, gconstpointer)
+{
+ WebKitSettings* settings = webkit_settings_new();
+
+ // JavaScript is enabled by default.
+ g_assert(webkit_settings_get_enable_javascript(settings));
+ webkit_settings_set_enable_javascript(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_javascript(settings));
+
+ // By default auto-load-image is true.
+ g_assert(webkit_settings_get_auto_load_images(settings));
+ webkit_settings_set_auto_load_images(settings, FALSE);
+ g_assert(!webkit_settings_get_auto_load_images(settings));
+
+ // load-icons-ignoring-image-load-setting is false by default.
+ g_assert(!webkit_settings_get_load_icons_ignoring_image_load_setting(settings));
+ webkit_settings_set_load_icons_ignoring_image_load_setting(settings, TRUE);
+ g_assert(webkit_settings_get_load_icons_ignoring_image_load_setting(settings));
+
+ // Offline application cache is true by default.
+ g_assert(webkit_settings_get_enable_offline_web_application_cache(settings));
+ webkit_settings_set_enable_offline_web_application_cache(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_offline_web_application_cache(settings));
+
+ // Local storage is enable by default.
+ g_assert(webkit_settings_get_enable_html5_local_storage(settings));
+ webkit_settings_set_enable_html5_local_storage(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_html5_local_storage(settings));
+
+ // HTML5 database is enabled by default.
+ g_assert(webkit_settings_get_enable_html5_database(settings));
+ webkit_settings_set_enable_html5_database(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_html5_database(settings));
+
+ // XSS Auditor is enabled by default.
+ g_assert(webkit_settings_get_enable_xss_auditor(settings));
+ webkit_settings_set_enable_xss_auditor(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_xss_auditor(settings));
+
+ // Frame flattening is disabled by default.
+ g_assert(!webkit_settings_get_enable_frame_flattening(settings));
+ webkit_settings_set_enable_frame_flattening(settings, TRUE);
+ g_assert(webkit_settings_get_enable_frame_flattening(settings));
+
+ // Plugins are enabled by default.
+ g_assert(webkit_settings_get_enable_plugins(settings));
+ webkit_settings_set_enable_plugins(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_plugins(settings));
+
+ // Java is enabled by default.
+ g_assert(webkit_settings_get_enable_java(settings));
+ webkit_settings_set_enable_java(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_java(settings));
+
+ // By default, JavaScript can open windows automatically is disabled.
+ g_assert(!webkit_settings_get_javascript_can_open_windows_automatically(settings));
+ webkit_settings_set_javascript_can_open_windows_automatically(settings, TRUE);
+ g_assert(webkit_settings_get_javascript_can_open_windows_automatically(settings));
+
+ // By default hyper link auditing is disabled.
+ g_assert(!webkit_settings_get_enable_hyperlink_auditing(settings));
+ webkit_settings_set_enable_hyperlink_auditing(settings, TRUE);
+ g_assert(webkit_settings_get_enable_hyperlink_auditing(settings));
+
+ // Default font family is "sans-serif".
+ g_assert_cmpstr(webkit_settings_get_default_font_family(settings), ==, "sans-serif");
+ webkit_settings_set_default_font_family(settings, "monospace");
+ g_assert_cmpstr(webkit_settings_get_default_font_family(settings), ==, "monospace");
+
+ // Default monospace font family font family is "monospace".
+ g_assert_cmpstr(webkit_settings_get_monospace_font_family(settings), ==, "monospace");
+ webkit_settings_set_monospace_font_family(settings, "sans-serif");
+ g_assert_cmpstr(webkit_settings_get_monospace_font_family(settings), ==, "sans-serif");
+
+ // Default serif font family is "serif".
+ g_assert_cmpstr(webkit_settings_get_serif_font_family(settings), ==, "serif");
+ webkit_settings_set_serif_font_family(settings, "sans-serif");
+ g_assert_cmpstr(webkit_settings_get_serif_font_family(settings), ==, "sans-serif");
+
+ // Default sans serif font family is "sans-serif".
+ g_assert_cmpstr(webkit_settings_get_sans_serif_font_family(settings), ==, "sans-serif");
+ webkit_settings_set_sans_serif_font_family(settings, "serif");
+ g_assert_cmpstr(webkit_settings_get_sans_serif_font_family(settings), ==, "serif");
+
+ // Default cursive font family "serif".
+ g_assert_cmpstr(webkit_settings_get_cursive_font_family(settings), ==, "serif");
+ webkit_settings_set_cursive_font_family(settings, "sans-serif");
+ g_assert_cmpstr(webkit_settings_get_cursive_font_family(settings), ==, "sans-serif");
+
+ // Default fantasy font family is "serif".
+ g_assert_cmpstr(webkit_settings_get_fantasy_font_family(settings), ==, "serif");
+ webkit_settings_set_fantasy_font_family(settings, "sans-serif");
+ g_assert_cmpstr(webkit_settings_get_fantasy_font_family(settings), ==, "sans-serif");
+
+ // Default pictograph font family is "serif".
+ g_assert_cmpstr(webkit_settings_get_pictograph_font_family(settings), ==, "serif");
+ webkit_settings_set_pictograph_font_family(settings, "sans-serif");
+ g_assert_cmpstr(webkit_settings_get_pictograph_font_family(settings), ==, "sans-serif");
+
+ // Default font size is 16.
+ g_assert_cmpuint(webkit_settings_get_default_font_size(settings), ==, 16);
+ webkit_settings_set_default_font_size(settings, 14);
+ g_assert_cmpuint(webkit_settings_get_default_font_size(settings), ==, 14);
+
+ // Default monospace font size is 13.
+ g_assert_cmpuint(webkit_settings_get_default_monospace_font_size(settings), ==, 13);
+ webkit_settings_set_default_monospace_font_size(settings, 10);
+ g_assert_cmpuint(webkit_settings_get_default_monospace_font_size(settings), ==, 10);
+
+ // Default minimum font size is 0.
+ g_assert_cmpuint(webkit_settings_get_minimum_font_size(settings), ==, 0);
+ webkit_settings_set_minimum_font_size(settings, 7);
+ g_assert_cmpuint(webkit_settings_get_minimum_font_size(settings), ==, 7);
+
+ // Default charset is "iso-8859-1".
+ g_assert_cmpstr(webkit_settings_get_default_charset(settings), ==, "iso-8859-1");
+ webkit_settings_set_default_charset(settings, "utf8");
+ g_assert_cmpstr(webkit_settings_get_default_charset(settings), ==, "utf8");
+
+ g_assert(!webkit_settings_get_enable_private_browsing(settings));
+ webkit_settings_set_enable_private_browsing(settings, TRUE);
+ g_assert(webkit_settings_get_enable_private_browsing(settings));
+
+ g_assert(!webkit_settings_get_enable_developer_extras(settings));
+ webkit_settings_set_enable_developer_extras(settings, TRUE);
+ g_assert(webkit_settings_get_enable_developer_extras(settings));
+
+ g_assert(webkit_settings_get_enable_resizable_text_areas(settings));
+ webkit_settings_set_enable_resizable_text_areas(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_resizable_text_areas(settings));
+
+ g_assert(webkit_settings_get_enable_tabs_to_links(settings));
+ webkit_settings_set_enable_tabs_to_links(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_tabs_to_links(settings));
+
+ g_assert(!webkit_settings_get_enable_dns_prefetching(settings));
+ webkit_settings_set_enable_dns_prefetching(settings, TRUE);
+ g_assert(webkit_settings_get_enable_dns_prefetching(settings));
+
+ // Caret browsing is disabled by default.
+ g_assert(!webkit_settings_get_enable_caret_browsing(settings));
+ webkit_settings_set_enable_caret_browsing(settings, TRUE);
+ g_assert(webkit_settings_get_enable_caret_browsing(settings));
+
+ // Fullscreen JavaScript API is enabled by default.
+ g_assert(webkit_settings_get_enable_fullscreen(settings));
+ webkit_settings_set_enable_fullscreen(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_fullscreen(settings));
+
+ // Print backgrounds is enabled by default
+ g_assert(webkit_settings_get_print_backgrounds(settings));
+ webkit_settings_set_print_backgrounds(settings, FALSE);
+ g_assert(!webkit_settings_get_print_backgrounds(settings));
+
+ // WebAudio is disabled by default.
+ g_assert(!webkit_settings_get_enable_webaudio(settings));
+ webkit_settings_set_enable_webaudio(settings, TRUE);
+ g_assert(webkit_settings_get_enable_webaudio(settings));
+
+ // WebGL is disabled by default.
+ g_assert(!webkit_settings_get_enable_webgl(settings));
+ webkit_settings_set_enable_webgl(settings, TRUE);
+ g_assert(webkit_settings_get_enable_webgl(settings));
+
+ // Allow Modal Dialogs is disabled by default.
+ g_assert(!webkit_settings_get_allow_modal_dialogs(settings));
+ webkit_settings_set_allow_modal_dialogs(settings, TRUE);
+ g_assert(webkit_settings_get_allow_modal_dialogs(settings));
+
+ // Zoom text only is disabled by default.
+ g_assert(!webkit_settings_get_zoom_text_only(settings));
+ webkit_settings_set_zoom_text_only(settings, TRUE);
+ g_assert(webkit_settings_get_zoom_text_only(settings));
+
+ // By default, JavaScript cannot access the clipboard.
+ g_assert(!webkit_settings_get_javascript_can_access_clipboard(settings));
+ webkit_settings_set_javascript_can_access_clipboard(settings, TRUE);
+ g_assert(webkit_settings_get_javascript_can_access_clipboard(settings));
+
+ // By default, media playback doesn't require user gestures.
+ g_assert(!webkit_settings_get_media_playback_requires_user_gesture(settings));
+ webkit_settings_set_media_playback_requires_user_gesture(settings, TRUE);
+ g_assert(webkit_settings_get_media_playback_requires_user_gesture(settings));
+
+ // By default, inline media playback is allowed
+ g_assert(webkit_settings_get_media_playback_allows_inline(settings));
+ webkit_settings_set_media_playback_allows_inline(settings, FALSE);
+ g_assert(!webkit_settings_get_media_playback_allows_inline(settings));
+
+ // By default, debug indicators are disabled.
+ g_assert(!webkit_settings_get_draw_compositing_indicators(settings));
+ webkit_settings_set_draw_compositing_indicators(settings, TRUE);
+ g_assert(webkit_settings_get_draw_compositing_indicators(settings));
+
+ // By default, site specific quirks are disabled.
+ g_assert(!webkit_settings_get_enable_site_specific_quirks(settings));
+ webkit_settings_set_enable_site_specific_quirks(settings, TRUE);
+ g_assert(webkit_settings_get_enable_site_specific_quirks(settings));
+
+ // By default, page cache is enabled.
+ g_assert(webkit_settings_get_enable_page_cache(settings));
+ webkit_settings_set_enable_page_cache(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_page_cache(settings));
+
+ // By default, smooth scrolling is disabled.
+ g_assert(!webkit_settings_get_enable_smooth_scrolling(settings));
+ webkit_settings_set_enable_smooth_scrolling(settings, TRUE);
+ g_assert(webkit_settings_get_enable_smooth_scrolling(settings));
+
+ // By default, accelerated 2D canvas is disabled.
+ g_assert(!webkit_settings_get_enable_accelerated_2d_canvas(settings));
+ webkit_settings_set_enable_accelerated_2d_canvas(settings, TRUE);
+ g_assert(webkit_settings_get_enable_accelerated_2d_canvas(settings));
+
+ // By default, writing of console messages to stdout is disabled.
+ g_assert(!webkit_settings_get_enable_write_console_messages_to_stdout(settings));
+ webkit_settings_set_enable_write_console_messages_to_stdout(settings, TRUE);
+ g_assert(webkit_settings_get_enable_write_console_messages_to_stdout(settings));
+
+ // MediaStream is disabled by default.
+ g_assert(!webkit_settings_get_enable_media_stream(settings));
+ webkit_settings_set_enable_media_stream(settings, TRUE);
+ g_assert(webkit_settings_get_enable_media_stream(settings));
+
+ // By default, SpatialNavigation is disabled
+ g_assert(!webkit_settings_get_enable_spatial_navigation(settings));
+ webkit_settings_set_enable_spatial_navigation(settings, TRUE);
+ g_assert(webkit_settings_get_enable_spatial_navigation(settings));
+
+ // MediaSource is disabled by default
+ g_assert(!webkit_settings_get_enable_mediasource(settings));
+ webkit_settings_set_enable_mediasource(settings, TRUE);
+ g_assert(webkit_settings_get_enable_mediasource(settings));
+
+ g_object_unref(G_OBJECT(settings));
+}
+
+void testWebKitSettingsNewWithSettings(Test* test, gconstpointer)
+{
+ GRefPtr<WebKitSettings> settings = adoptGRef(webkit_settings_new_with_settings(
+ "enable-javascript", FALSE,
+ "auto-load-images", FALSE,
+ "load-icons-ignoring-image-load-setting", TRUE,
+ nullptr));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(settings.get()));
+ g_assert(!webkit_settings_get_enable_javascript(settings.get()));
+ g_assert(!webkit_settings_get_auto_load_images(settings.get()));
+ g_assert(webkit_settings_get_load_icons_ignoring_image_load_setting(settings.get()));
+}
+
+static CString convertWebViewMainResourceDataToCString(WebViewTest* test)
+{
+ size_t mainResourceDataSize = 0;
+ const char* mainResourceData = test->mainResourceData(mainResourceDataSize);
+ return CString(mainResourceData, mainResourceDataSize);
+}
+
+static void assertThatUserAgentIsSentInHeaders(WebViewTest* test, const CString& userAgent)
+{
+ test->loadURI(gServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+ ASSERT_CMP_CSTRING(convertWebViewMainResourceDataToCString(test), ==, userAgent);
+}
+
+static void testWebKitSettingsUserAgent(WebViewTest* test, gconstpointer)
+{
+ GRefPtr<WebKitSettings> settings = adoptGRef(webkit_settings_new());
+ CString defaultUserAgent = webkit_settings_get_user_agent(settings.get());
+ webkit_web_view_set_settings(test->m_webView, settings.get());
+
+ g_assert(g_strstr_len(defaultUserAgent.data(), -1, "AppleWebKit"));
+ g_assert(g_strstr_len(defaultUserAgent.data(), -1, "Safari"));
+
+ webkit_settings_set_user_agent(settings.get(), 0);
+ g_assert_cmpstr(defaultUserAgent.data(), ==, webkit_settings_get_user_agent(settings.get()));
+ assertThatUserAgentIsSentInHeaders(test, defaultUserAgent.data());
+
+ webkit_settings_set_user_agent(settings.get(), "");
+ g_assert_cmpstr(defaultUserAgent.data(), ==, webkit_settings_get_user_agent(settings.get()));
+
+ const char* funkyUserAgent = "Funky!";
+ webkit_settings_set_user_agent(settings.get(), funkyUserAgent);
+ g_assert_cmpstr(funkyUserAgent, ==, webkit_settings_get_user_agent(settings.get()));
+ assertThatUserAgentIsSentInHeaders(test, funkyUserAgent);
+
+ webkit_settings_set_user_agent_with_application_details(settings.get(), "WebKitGTK+", 0);
+ const char* userAgentWithNullVersion = webkit_settings_get_user_agent(settings.get());
+ g_assert_cmpstr(g_strstr_len(userAgentWithNullVersion, -1, defaultUserAgent.data()), ==, userAgentWithNullVersion);
+ g_assert(g_strstr_len(userAgentWithNullVersion, -1, "WebKitGTK+"));
+
+ webkit_settings_set_user_agent_with_application_details(settings.get(), "WebKitGTK+", "");
+ g_assert_cmpstr(webkit_settings_get_user_agent(settings.get()), ==, userAgentWithNullVersion);
+
+ webkit_settings_set_user_agent_with_application_details(settings.get(), "WebCatGTK+", "3.4.5");
+ const char* newUserAgent = webkit_settings_get_user_agent(settings.get());
+ g_assert(g_strstr_len(newUserAgent, -1, "3.4.5"));
+ g_assert(g_strstr_len(newUserAgent, -1, "WebCatGTK+"));
+}
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ if (g_str_equal(path, "/")) {
+ const char* userAgent = soup_message_headers_get_one(message->request_headers, "User-Agent");
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, userAgent, strlen(userAgent));
+ soup_message_body_complete(message->response_body);
+ } else
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+}
+
+void beforeAll()
+{
+ gServer = new WebKitTestServer();
+ gServer->run(serverCallback);
+
+ Test::add("WebKitSettings", "webkit-settings", testWebKitSettings);
+ Test::add("WebKitSettings", "new-with-settings", testWebKitSettingsNewWithSettings);
+ WebViewTest::add("WebKitSettings", "user-agent", testWebKitSettingsUserAgent);
+}
+
+void afterAll()
+{
+ delete gServer;
+}
+
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitSettingscpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitVersioncppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestWebKitVersioncpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitVersion.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitVersion.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitVersion.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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,1 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 "TestMain.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+
+static void testWebKitVersion(Test*, gconstpointer)
+{
+ g_assert_cmpuint(webkit_get_major_version(), ==, WEBKIT_MAJOR_VERSION);
+ g_assert_cmpuint(webkit_get_minor_version(), ==, WEBKIT_MINOR_VERSION);
+ g_assert_cmpuint(webkit_get_micro_version(), ==, WEBKIT_MICRO_VERSION);
+}
+
+static void testWebKitCheckVersion(Test*, gconstpointer)
+{
+ g_assert(WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION));
+ g_assert(!WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION + 1, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION));
+ g_assert(!WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION + 1, WEBKIT_MICRO_VERSION));
+ g_assert(!WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION + 1));
+}
+
+void beforeAll()
+{
+ Test::add("WebKitVersion", "version", testWebKitVersion);
+ Test::add("WebKitVersion", "check-version", testWebKitCheckVersion);
+}
+
+void afterAll()
+{
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitVersioncpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitVersion.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebContextcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestWebKitWebContextcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,425 @@
</span><ins>+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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,1 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 "LoadTrackingTest.h"
+#include "WebKitTestServer.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+#include <wtf/HashMap.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/StringHash.h>
+
+static WebKitTestServer* kServer;
+
+static void testWebContextDefault(Test* test, gconstpointer)
+{
+ // Check there's a single instance of the default web context.
+ g_assert(webkit_web_context_get_default() == webkit_web_context_get_default());
+}
+
+class PluginsTest: public Test {
+public:
+ MAKE_GLIB_TEST_FIXTURE(PluginsTest);
+
+ PluginsTest()
+ : m_context(webkit_web_context_get_default())
+ , m_mainLoop(g_main_loop_new(0, TRUE))
+ , m_plugins(0)
+ {
+ webkit_web_context_set_additional_plugins_directory(m_context, WEBKIT_TEST_PLUGIN_DIR);
+ }
+
+ ~PluginsTest()
+ {
+ g_main_loop_unref(m_mainLoop);
+ g_list_free_full(m_plugins, g_object_unref);
+ }
+
+ static void getPluginsAsyncReadyCallback(GObject*, GAsyncResult* result, PluginsTest* test)
+ {
+ test->m_plugins = webkit_web_context_get_plugins_finish(test->m_context, result, 0);
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ GList* getPlugins()
+ {
+ g_list_free_full(m_plugins, g_object_unref);
+ webkit_web_context_get_plugins(m_context, 0, reinterpret_cast<GAsyncReadyCallback>(getPluginsAsyncReadyCallback), this);
+ g_main_loop_run(m_mainLoop);
+ return m_plugins;
+ }
+
+ WebKitWebContext* m_context;
+ GMainLoop* m_mainLoop;
+ GList* m_plugins;
+};
+
+static void testWebContextGetPlugins(PluginsTest* test, gconstpointer)
+{
+ GList* plugins = test->getPlugins();
+ g_assert(plugins);
+
+ GRefPtr<WebKitPlugin> testPlugin;
+ for (GList* item = plugins; item; item = g_list_next(item)) {
+ WebKitPlugin* plugin = WEBKIT_PLUGIN(item->data);
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(plugin));
+ if (!g_strcmp0(webkit_plugin_get_name(plugin), "WebKit Test PlugIn")) {
+ testPlugin = plugin;
+ break;
+ }
+ }
+ g_assert(WEBKIT_IS_PLUGIN(testPlugin.get()));
+
+ GOwnPtr<char> pluginPath(g_build_filename(WEBKIT_TEST_PLUGIN_DIR, "libTestNetscapePlugin.so", NULL));
+ g_assert_cmpstr(webkit_plugin_get_path(testPlugin.get()), ==, pluginPath.get());
+ g_assert_cmpstr(webkit_plugin_get_description(testPlugin.get()), ==, "Simple Netscape® plug-in that handles test content for WebKit");
+ GList* mimeInfoList = webkit_plugin_get_mime_info_list(testPlugin.get());
+ g_assert(mimeInfoList);
+ g_assert_cmpuint(g_list_length(mimeInfoList), ==, 2);
+
+ WebKitMimeInfo* mimeInfo = static_cast<WebKitMimeInfo*>(mimeInfoList->data);
+ g_assert_cmpstr(webkit_mime_info_get_mime_type(mimeInfo), ==, "image/png");
+ g_assert_cmpstr(webkit_mime_info_get_description(mimeInfo), ==, "png image");
+ const gchar* const* extensions = webkit_mime_info_get_extensions(mimeInfo);
+ g_assert(extensions);
+ g_assert_cmpstr(extensions[0], ==, "png");
+
+ mimeInfoList = g_list_next(mimeInfoList);
+ mimeInfo = static_cast<WebKitMimeInfo*>(mimeInfoList->data);
+ g_assert_cmpstr(webkit_mime_info_get_mime_type(mimeInfo), ==, "application/x-webkit-test-netscape");
+ g_assert_cmpstr(webkit_mime_info_get_description(mimeInfo), ==, "test netscape content");
+ extensions = webkit_mime_info_get_extensions(mimeInfo);
+ g_assert(extensions);
+ g_assert_cmpstr(extensions[0], ==, "testnetscape");
+}
+
+static const char* kBarHTML = "<html><body>Bar</body></html>";
+static const char* kEchoHTMLFormat = "<html><body>%s</body></html>";
+static const char* errorDomain = "test";
+static const int errorCode = 10;
+static const char* errorMessage = "Error message.";
+
+class URISchemeTest: public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(URISchemeTest);
+
+ struct URISchemeHandler {
+ URISchemeHandler()
+ : replyLength(0)
+ {
+ }
+
+ URISchemeHandler(const char* reply, int replyLength, const char* mimeType)
+ : reply(reply)
+ , replyLength(replyLength)
+ , mimeType(mimeType)
+ {
+ }
+
+ CString reply;
+ int replyLength;
+ CString mimeType;
+ };
+
+ static void uriSchemeRequestCallback(WebKitURISchemeRequest* request, gpointer userData)
+ {
+ URISchemeTest* test = static_cast<URISchemeTest*>(userData);
+ test->m_uriSchemeRequest = request;
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+
+ g_assert(webkit_uri_scheme_request_get_web_view(request) == test->m_webView);
+
+ GRefPtr<GInputStream> inputStream = adoptGRef(g_memory_input_stream_new());
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inputStream.get()));
+
+ const char* scheme = webkit_uri_scheme_request_get_scheme(request);
+ g_assert(scheme);
+ g_assert(test->m_handlersMap.contains(String::fromUTF8(scheme)));
+
+ if (!g_strcmp0(scheme, "error")) {
+ GOwnPtr<GError> error(g_error_new_literal(g_quark_from_string(errorDomain), errorCode, errorMessage));
+ webkit_uri_scheme_request_finish_error(request, error.get());
+ return;
+ }
+
+ const URISchemeHandler& handler = test->m_handlersMap.get(String::fromUTF8(scheme));
+
+ if (!g_strcmp0(scheme, "echo")) {
+ char* replyHTML = g_strdup_printf(handler.reply.data(), webkit_uri_scheme_request_get_path(request));
+ g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), replyHTML, strlen(replyHTML), g_free);
+ } else if (!g_strcmp0(scheme, "closed"))
+ g_input_stream_close(inputStream.get(), 0, 0);
+ else if (!handler.reply.isNull())
+ g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), handler.reply.data(), handler.reply.length(), 0);
+
+ webkit_uri_scheme_request_finish(request, inputStream.get(), handler.replyLength, handler.mimeType.data());
+ }
+
+ void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType)
+ {
+ m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType));
+ webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this, 0);
+ }
+
+ GRefPtr<WebKitURISchemeRequest> m_uriSchemeRequest;
+ HashMap<String, URISchemeHandler> m_handlersMap;
+};
+
+static void testWebContextURIScheme(URISchemeTest* test, gconstpointer)
+{
+ test->registerURISchemeHandler("foo", kBarHTML, strlen(kBarHTML), "text/html");
+ test->loadURI("foo:blank");
+ test->waitUntilLoadFinished();
+ size_t mainResourceDataSize = 0;
+ const char* mainResourceData = test->mainResourceData(mainResourceDataSize);
+ g_assert_cmpint(mainResourceDataSize, ==, strlen(kBarHTML));
+ g_assert(!strncmp(mainResourceData, kBarHTML, mainResourceDataSize));
+
+ test->registerURISchemeHandler("echo", kEchoHTMLFormat, -1, "text/html");
+ test->loadURI("echo:hello world");
+ test->waitUntilLoadFinished();
+ GOwnPtr<char> echoHTML(g_strdup_printf(kEchoHTMLFormat, webkit_uri_scheme_request_get_path(test->m_uriSchemeRequest.get())));
+ mainResourceDataSize = 0;
+ mainResourceData = test->mainResourceData(mainResourceDataSize);
+ g_assert_cmpint(mainResourceDataSize, ==, strlen(echoHTML.get()));
+ g_assert(!strncmp(mainResourceData, echoHTML.get(), mainResourceDataSize));
+
+ test->registerURISchemeHandler("nomime", kBarHTML, -1, 0);
+ test->m_loadEvents.clear();
+ test->loadURI("nomime:foo bar");
+ test->waitUntilLoadFinished();
+ g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+
+ test->registerURISchemeHandler("empty", 0, 0, "text/html");
+ test->m_loadEvents.clear();
+ test->loadURI("empty:nothing");
+ test->waitUntilLoadFinished();
+ g_assert(!test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+ g_assert(!test->m_loadEvents.contains(LoadTrackingTest::LoadFailed));
+
+ test->registerURISchemeHandler("error", 0, 0, 0);
+ test->m_loadEvents.clear();
+ test->loadURI("error:error");
+ test->waitUntilLoadFinished();
+ g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+ g_assert(test->m_loadFailed);
+ g_assert_error(test->m_error.get(), g_quark_from_string(errorDomain), errorCode);
+ g_assert_cmpstr(test->m_error->message, ==, errorMessage);
+
+ test->registerURISchemeHandler("closed", 0, 0, 0);
+ test->m_loadEvents.clear();
+ test->loadURI("closed:input-stream");
+ test->waitUntilLoadFinished();
+ g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+ g_assert(test->m_loadFailed);
+ g_assert_error(test->m_error.get(), G_IO_ERROR, G_IO_ERROR_CLOSED);
+}
+
+static void testWebContextSpellChecker(Test* test, gconstpointer)
+{
+ WebKitWebContext* webContext = webkit_web_context_get_default();
+
+ // Check what happens if no spell checking language has been set.
+ const gchar* const* currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
+ g_assert(!currentLanguage);
+
+ // Set the language to a specific one.
+ GRefPtr<GPtrArray> languages = adoptGRef(g_ptr_array_new());
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("en_US")));
+ g_ptr_array_add(languages.get(), 0);
+ webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata));
+ currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
+ g_assert_cmpuint(g_strv_length(const_cast<char**>(currentLanguage)), ==, 1);
+ g_assert_cmpstr(currentLanguage[0], ==, "en_US");
+
+ // Set the language string to list of valid languages.
+ g_ptr_array_remove_index_fast(languages.get(), languages->len - 1);
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("en_GB")));
+ g_ptr_array_add(languages.get(), 0);
+ webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata));
+ currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
+ g_assert_cmpuint(g_strv_length(const_cast<char**>(currentLanguage)), ==, 2);
+ g_assert_cmpstr(currentLanguage[0], ==, "en_US");
+ g_assert_cmpstr(currentLanguage[1], ==, "en_GB");
+
+ // Try passing a wrong language along with good ones.
+ g_ptr_array_remove_index_fast(languages.get(), languages->len - 1);
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("bd_WR")));
+ g_ptr_array_add(languages.get(), 0);
+ webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata));
+ currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
+ g_assert_cmpuint(g_strv_length(const_cast<char**>(currentLanguage)), ==, 2);
+ g_assert_cmpstr(currentLanguage[0], ==, "en_US");
+ g_assert_cmpstr(currentLanguage[1], ==, "en_GB");
+
+ // Try passing a list with only wrong languages.
+ languages = adoptGRef(g_ptr_array_new());
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("bd_WR")));
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("wr_BD")));
+ g_ptr_array_add(languages.get(), 0);
+ webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata));
+ currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
+ g_assert(!currentLanguage);
+
+ // Check disabling and re-enabling spell checking.
+ webkit_web_context_set_spell_checking_enabled(webContext, FALSE);
+ g_assert(!webkit_web_context_get_spell_checking_enabled(webContext));
+ webkit_web_context_set_spell_checking_enabled(webContext, TRUE);
+ g_assert(webkit_web_context_get_spell_checking_enabled(webContext));
+}
+
+static void testWebContextLanguages(WebViewTest* test, gconstpointer)
+{
+ static const char* expectedDefaultLanguage = "en";
+ test->loadURI(kServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+ size_t mainResourceDataSize = 0;
+ const char* mainResourceData = test->mainResourceData(mainResourceDataSize);
+ g_assert_cmpuint(mainResourceDataSize, ==, strlen(expectedDefaultLanguage));
+ g_assert(!strncmp(mainResourceData, expectedDefaultLanguage, mainResourceDataSize));
+
+ GRefPtr<GPtrArray> languages = adoptGRef(g_ptr_array_new());
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("en")));
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("ES_es")));
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("dE")));
+ g_ptr_array_add(languages.get(), 0);
+ webkit_web_context_set_preferred_languages(webkit_web_context_get_default(), reinterpret_cast<const char* const*>(languages->pdata));
+
+ static const char* expectedLanguages = "en, es-es;q=0.90, de;q=0.80";
+ test->loadURI(kServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+ mainResourceDataSize = 0;
+ mainResourceData = test->mainResourceData(mainResourceDataSize);
+ g_assert_cmpuint(mainResourceDataSize, ==, strlen(expectedLanguages));
+ g_assert(!strncmp(mainResourceData, expectedLanguages, mainResourceDataSize));
+}
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ if (g_str_equal(path, "/")) {
+ const char* acceptLanguage = soup_message_headers_get_one(message->request_headers, "Accept-Language");
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, acceptLanguage, strlen(acceptLanguage));
+ soup_message_body_complete(message->response_body);
+ } else
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+}
+
+class SecurityPolicyTest: public Test {
+public:
+ MAKE_GLIB_TEST_FIXTURE(SecurityPolicyTest);
+
+ enum SecurityPolicy {
+ Local = 1 << 1,
+ NoAccess = 1 << 2,
+ DisplayIsolated = 1 << 3,
+ Secure = 1 << 4,
+ CORSEnabled = 1 << 5,
+ EmptyDocument = 1 << 6
+ };
+
+ SecurityPolicyTest()
+ : m_manager(webkit_web_context_get_security_manager(webkit_web_context_get_default()))
+ {
+ }
+
+ void verifyThatSchemeMatchesPolicy(const char* scheme, unsigned policy)
+ {
+ if (policy & Local)
+ g_assert(webkit_security_manager_uri_scheme_is_local(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_local(m_manager, scheme));
+ if (policy & NoAccess)
+ g_assert(webkit_security_manager_uri_scheme_is_no_access(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_no_access(m_manager, scheme));
+ if (policy & DisplayIsolated)
+ g_assert(webkit_security_manager_uri_scheme_is_display_isolated(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_display_isolated(m_manager, scheme));
+ if (policy & Secure)
+ g_assert(webkit_security_manager_uri_scheme_is_secure(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_secure(m_manager, scheme));
+ if (policy & CORSEnabled)
+ g_assert(webkit_security_manager_uri_scheme_is_cors_enabled(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_cors_enabled(m_manager, scheme));
+ if (policy & EmptyDocument)
+ g_assert(webkit_security_manager_uri_scheme_is_empty_document(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_empty_document(m_manager, scheme));
+ }
+
+ WebKitSecurityManager* m_manager;
+};
+
+static void testWebContextSecurityPolicy(SecurityPolicyTest* test, gconstpointer)
+{
+ // VerifyThatSchemeMatchesPolicy default policy for well known schemes.
+ test->verifyThatSchemeMatchesPolicy("http", SecurityPolicyTest::CORSEnabled);
+ test->verifyThatSchemeMatchesPolicy("https", SecurityPolicyTest::CORSEnabled | SecurityPolicyTest::Secure);
+ test->verifyThatSchemeMatchesPolicy("file", SecurityPolicyTest::Local);
+ test->verifyThatSchemeMatchesPolicy("data", SecurityPolicyTest::NoAccess | SecurityPolicyTest::Secure);
+ test->verifyThatSchemeMatchesPolicy("about", SecurityPolicyTest::NoAccess | SecurityPolicyTest::Secure | SecurityPolicyTest::EmptyDocument);
+
+ // Custom scheme.
+ test->verifyThatSchemeMatchesPolicy("foo", 0);
+
+ webkit_security_manager_register_uri_scheme_as_local(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local);
+ webkit_security_manager_register_uri_scheme_as_no_access(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess);
+ webkit_security_manager_register_uri_scheme_as_display_isolated(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated);
+ webkit_security_manager_register_uri_scheme_as_secure(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated | SecurityPolicyTest::Secure);
+ webkit_security_manager_register_uri_scheme_as_cors_enabled(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated | SecurityPolicyTest::Secure
+ | SecurityPolicyTest::CORSEnabled);
+ webkit_security_manager_register_uri_scheme_as_empty_document(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated | SecurityPolicyTest::Secure
+ | SecurityPolicyTest::CORSEnabled | SecurityPolicyTest::EmptyDocument);
+}
+
+void beforeAll()
+{
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ Test::add("WebKitWebContext", "default-context", testWebContextDefault);
+ PluginsTest::add("WebKitWebContext", "get-plugins", testWebContextGetPlugins);
+ URISchemeTest::add("WebKitWebContext", "uri-scheme", testWebContextURIScheme);
+ Test::add("WebKitWebContext", "spell-checker", testWebContextSpellChecker);
+ WebViewTest::add("WebKitWebContext", "languages", testWebContextLanguages);
+ SecurityPolicyTest::add("WebKitSecurityManager", "security-policy", testWebContextSecurityPolicy);
+}
+
+void afterAll()
+{
+ delete kServer;
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebContextcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebViewcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestWebKitWebViewcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,608 @@
</span><ins>+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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,1 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 "WebViewTest.h"
+#include <JavaScriptCore/JSStringRef.h>
+#include <JavaScriptCore/JSValueRef.h>
+#include <glib/gstdio.h>
+#include <wtf/gobject/GRefPtr.h>
+
+static void testWebViewDefaultContext(WebViewTest* test, gconstpointer)
+{
+ g_assert(webkit_web_view_get_context(test->m_webView) == webkit_web_context_get_default());
+
+ // Check that a web view created with g_object_new has the default context.
+ GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, NULL));
+ g_assert(webkit_web_view_get_context(webView.get()) == webkit_web_context_get_default());
+}
+
+static void testWebViewCustomCharset(WebViewTest* test, gconstpointer)
+{
+ g_assert(!webkit_web_view_get_custom_charset(test->m_webView));
+ webkit_web_view_set_custom_charset(test->m_webView, "utf8");
+ g_assert_cmpstr(webkit_web_view_get_custom_charset(test->m_webView), ==, "utf8");
+ // Go back to the default charset.
+ webkit_web_view_set_custom_charset(test->m_webView, 0);
+ g_assert(!webkit_web_view_get_custom_charset(test->m_webView));
+}
+
+static void testWebViewSettings(WebViewTest* test, gconstpointer)
+{
+ WebKitSettings* defaultSettings = webkit_web_view_get_settings(test->m_webView);
+ g_assert(defaultSettings);
+ g_assert(webkit_settings_get_enable_javascript(defaultSettings));
+
+ GRefPtr<WebKitSettings> newSettings = adoptGRef(webkit_settings_new());
+ g_object_set(G_OBJECT(newSettings.get()), "enable-javascript", FALSE, NULL);
+ webkit_web_view_set_settings(test->m_webView, newSettings.get());
+
+ WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);
+ g_assert(settings != defaultSettings);
+ g_assert(!webkit_settings_get_enable_javascript(settings));
+
+ GRefPtr<GtkWidget> webView2 = webkit_web_view_new();
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webView2.get()));
+ webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webView2.get()), settings);
+ g_assert(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webView2.get())) == settings);
+
+ GRefPtr<WebKitSettings> newSettings2 = adoptGRef(webkit_settings_new());
+ webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webView2.get()), newSettings2.get());
+ settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webView2.get()));
+ g_assert(settings == newSettings2.get());
+ g_assert(webkit_settings_get_enable_javascript(settings));
+}
+
+static void testWebViewZoomLevel(WebViewTest* test, gconstpointer)
+{
+ g_assert_cmpfloat(webkit_web_view_get_zoom_level(test->m_webView), ==, 1);
+ webkit_web_view_set_zoom_level(test->m_webView, 2.5);
+ g_assert_cmpfloat(webkit_web_view_get_zoom_level(test->m_webView), ==, 2.5);
+
+ webkit_settings_set_zoom_text_only(webkit_web_view_get_settings(test->m_webView), TRUE);
+ // The zoom level shouldn't change when zoom-text-only setting changes.
+ g_assert_cmpfloat(webkit_web_view_get_zoom_level(test->m_webView), ==, 2.5);
+}
+
+static void testWebViewRunJavaScript(WebViewTest* test, gconstpointer)
+{
+ static const char* html = "<html><body><a id='WebKitLink' href='http://www.webkitgtk.org/' title='WebKitGTK+ Title'>WebKitGTK+ Website</a></body></html>";
+ test->loadHtml(html, 0);
+ test->waitUntilLoadFinished();
+
+ GOwnPtr<GError> error;
+ WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.document.getElementById('WebKitLink').title;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ GOwnPtr<char> valueString(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "WebKitGTK+ Title");
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.document.getElementById('WebKitLink').href;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "http://www.webkitgtk.org/");
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.document.getElementById('WebKitLink').textContent", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "WebKitGTK+ Website");
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("a = 25;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(javascriptResult), ==, 25);
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("a = 2.5;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(javascriptResult), ==, 2.5);
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("a = true", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ g_assert(WebViewTest::javascriptResultToBoolean(javascriptResult));
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("a = false", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ g_assert(!WebViewTest::javascriptResultToBoolean(javascriptResult));
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("a = null", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ g_assert(WebViewTest::javascriptResultIsNull(javascriptResult));
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("function Foo() { a = 25; } Foo();", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ g_assert(WebViewTest::javascriptResultIsUndefined(javascriptResult));
+
+ javascriptResult = test->runJavaScriptFromGResourceAndWaitUntilFinished("/org/webkit/webkit2gtk/tests/link-title.js", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "WebKitGTK+ Title");
+
+ javascriptResult = test->runJavaScriptFromGResourceAndWaitUntilFinished("/wrong/path/to/resource.js", &error.outPtr());
+ g_assert(!javascriptResult);
+ g_assert_error(error.get(), G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
+ error.clear();
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("foo();", &error.outPtr());
+ g_assert(!javascriptResult);
+ g_assert_error(error.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED);
+}
+
+class FullScreenClientTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(FullScreenClientTest);
+
+ enum FullScreenEvent {
+ None,
+ Enter,
+ Leave
+ };
+
+ static gboolean viewEnterFullScreenCallback(WebKitWebView*, FullScreenClientTest* test)
+ {
+ test->m_event = Enter;
+ g_main_loop_quit(test->m_mainLoop);
+ return FALSE;
+ }
+
+ static gboolean viewLeaveFullScreenCallback(WebKitWebView*, FullScreenClientTest* test)
+ {
+ test->m_event = Leave;
+ g_main_loop_quit(test->m_mainLoop);
+ return FALSE;
+ }
+
+ FullScreenClientTest()
+ : m_event(None)
+ {
+ webkit_settings_set_enable_fullscreen(webkit_web_view_get_settings(m_webView), TRUE);
+ g_signal_connect(m_webView, "enter-fullscreen", G_CALLBACK(viewEnterFullScreenCallback), this);
+ g_signal_connect(m_webView, "leave-fullscreen", G_CALLBACK(viewLeaveFullScreenCallback), this);
+ }
+
+ ~FullScreenClientTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void requestFullScreenAndWaitUntilEnteredFullScreen()
+ {
+ m_event = None;
+ webkit_web_view_run_javascript(m_webView, "document.documentElement.webkitRequestFullScreen();", 0, 0, 0);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ static gboolean leaveFullScreenIdle(FullScreenClientTest* test)
+ {
+ test->keyStroke(GDK_KEY_Escape);
+ return FALSE;
+ }
+
+ void leaveFullScreenAndWaitUntilLeftFullScreen()
+ {
+ m_event = None;
+ g_idle_add(reinterpret_cast<GSourceFunc>(leaveFullScreenIdle), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ FullScreenEvent m_event;
+};
+
+static void testWebViewFullScreen(FullScreenClientTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+ test->loadHtml("<html><body>FullScreen test</body></html>", 0);
+ test->waitUntilLoadFinished();
+ test->requestFullScreenAndWaitUntilEnteredFullScreen();
+ g_assert_cmpint(test->m_event, ==, FullScreenClientTest::Enter);
+ test->leaveFullScreenAndWaitUntilLeftFullScreen();
+ g_assert_cmpint(test->m_event, ==, FullScreenClientTest::Leave);
+}
+
+static void testWebViewCanShowMIMEType(WebViewTest* test, gconstpointer)
+{
+ // Supported MIME types.
+ g_assert(webkit_web_view_can_show_mime_type(test->m_webView, "text/html"));
+ g_assert(webkit_web_view_can_show_mime_type(test->m_webView, "text/plain"));
+ g_assert(webkit_web_view_can_show_mime_type(test->m_webView, "image/jpeg"));
+
+ // Unsupported MIME types.
+ g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "text/vcard"));
+ g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/pdf"));
+ g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/zip"));
+ g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/octet-stream"));
+
+ // Plugins are only supported when enabled.
+ webkit_web_context_set_additional_plugins_directory(webkit_web_view_get_context(test->m_webView), WEBKIT_TEST_PLUGIN_DIR);
+ g_assert(webkit_web_view_can_show_mime_type(test->m_webView, "application/x-webkit-test-netscape"));
+ webkit_settings_set_enable_plugins(webkit_web_view_get_settings(test->m_webView), FALSE);
+ g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/x-webkit-test-netscape"));
+}
+
+class FormClientTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(FormClientTest);
+
+ static void submitFormCallback(WebKitWebView*, WebKitFormSubmissionRequest* request, FormClientTest* test)
+ {
+ test->submitForm(request);
+ }
+
+ FormClientTest()
+ : m_submitPositionX(0)
+ , m_submitPositionY(0)
+ {
+ g_signal_connect(m_webView, "submit-form", G_CALLBACK(submitFormCallback), this);
+ }
+
+ ~FormClientTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void submitForm(WebKitFormSubmissionRequest* request)
+ {
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+ m_request = request;
+ webkit_form_submission_request_submit(request);
+ quitMainLoop();
+ }
+
+ GHashTable* waitUntilFormSubmittedAndGetTextFields()
+ {
+ g_main_loop_run(m_mainLoop);
+ return webkit_form_submission_request_get_text_fields(m_request.get());
+ }
+
+ static gboolean doClickIdleCallback(FormClientTest* test)
+ {
+ test->clickMouseButton(test->m_submitPositionX, test->m_submitPositionY, 1);
+ return FALSE;
+ }
+
+ void submitFormAtPosition(int x, int y)
+ {
+ m_submitPositionX = x;
+ m_submitPositionY = y;
+ g_idle_add(reinterpret_cast<GSourceFunc>(doClickIdleCallback), this);
+ }
+
+ int m_submitPositionX;
+ int m_submitPositionY;
+ GRefPtr<WebKitFormSubmissionRequest> m_request;
+};
+
+static void testWebViewSubmitForm(FormClientTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+
+ const char* formHTML =
+ "<html><body>"
+ " <form action='#'>"
+ " <input type='text' name='text1' value='value1'>"
+ " <input type='text' name='text2' value='value2'>"
+ " <input type='password' name='password' value='secret'>"
+ " <textarea cols='5' rows='5' name='textarea'>Text</textarea>"
+ " <input type='hidden' name='hidden1' value='hidden1'>"
+ " <input type='submit' value='Submit' style='position:absolute; left:1; top:1' size='10'>"
+ " </form>"
+ "</body></html>";
+
+ test->loadHtml(formHTML, "file:///");
+ test->waitUntilLoadFinished();
+
+ test->submitFormAtPosition(5, 5);
+ GHashTable* values = test->waitUntilFormSubmittedAndGetTextFields();
+ g_assert(values);
+ g_assert_cmpuint(g_hash_table_size(values), ==, 3);
+ g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "text1")), ==, "value1");
+ g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "text2")), ==, "value2");
+ g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "password")), ==, "secret");
+}
+
+class SaveWebViewTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(SaveWebViewTest);
+
+ SaveWebViewTest()
+ : m_tempDirectory(g_dir_make_tmp("WebKit2SaveViewTest-XXXXXX", 0))
+ {
+ }
+
+ ~SaveWebViewTest()
+ {
+ if (G_IS_FILE(m_file.get()))
+ g_file_delete(m_file.get(), 0, 0);
+
+ if (G_IS_INPUT_STREAM(m_inputStream.get()))
+ g_input_stream_close(m_inputStream.get(), 0, 0);
+
+ if (m_tempDirectory)
+ g_rmdir(m_tempDirectory.get());
+ }
+
+ static void webViewSavedToStreamCallback(GObject* object, GAsyncResult* result, SaveWebViewTest* test)
+ {
+ GOwnPtr<GError> error;
+ test->m_inputStream = adoptGRef(webkit_web_view_save_finish(test->m_webView, result, &error.outPtr()));
+ g_assert(G_IS_INPUT_STREAM(test->m_inputStream.get()));
+ g_assert(!error);
+
+ test->quitMainLoop();
+ }
+
+ static void webViewSavedToFileCallback(GObject* object, GAsyncResult* result, SaveWebViewTest* test)
+ {
+ GOwnPtr<GError> error;
+ g_assert(webkit_web_view_save_to_file_finish(test->m_webView, result, &error.outPtr()));
+ g_assert(!error);
+
+ test->quitMainLoop();
+ }
+
+ void saveAndWaitForStream()
+ {
+ webkit_web_view_save(m_webView, WEBKIT_SAVE_MODE_MHTML, 0, reinterpret_cast<GAsyncReadyCallback>(webViewSavedToStreamCallback), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ void saveAndWaitForFile()
+ {
+ m_saveDestinationFilePath.set(g_build_filename(m_tempDirectory.get(), "testWebViewSaveResult.mht", NULL));
+ m_file = adoptGRef(g_file_new_for_path(m_saveDestinationFilePath.get()));
+ webkit_web_view_save_to_file(m_webView, m_file.get(), WEBKIT_SAVE_MODE_MHTML, 0, reinterpret_cast<GAsyncReadyCallback>(webViewSavedToFileCallback), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ GOwnPtr<char> m_tempDirectory;
+ GOwnPtr<char> m_saveDestinationFilePath;
+ GRefPtr<GInputStream> m_inputStream;
+ GRefPtr<GFile> m_file;
+};
+
+static void testWebViewSave(SaveWebViewTest* test, gconstpointer)
+{
+ test->loadHtml("<html>"
+ "<body>"
+ " <p>A paragraph with plain text</p>"
+ " <p>"
+ " A red box: <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AYWDTMVwnSZnwAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAFklEQVQI12P8z8DAwMDAxMDAwMDAAAANHQEDK+mmyAAAAABJRU5ErkJggg=='></br>"
+ " A blue box: <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AYWDTMvBHhALQAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAFklEQVQI12Nk4PnPwMDAxMDAwMDAAAALrwEPPIs1pgAAAABJRU5ErkJggg=='>"
+ " </p>"
+ "</body>"
+ "</html>", 0);
+ test->waitUntilLoadFinished();
+
+ // Write to a file and to an input stream.
+ test->saveAndWaitForFile();
+ test->saveAndWaitForStream();
+
+ // We should have exactly the same amount of bytes in the file
+ // than those coming from the GInputStream. We don't compare the
+ // strings read since the 'Date' field and the boundaries will be
+ // different on each case. MHTML functionality will be tested by
+ // Layout tests, so checking the amount of bytes is enough.
+ GOwnPtr<GError> error;
+ gchar buffer[512] = { 0 };
+ gssize readBytes = 0;
+ gssize totalBytesFromStream = 0;
+ while (readBytes = g_input_stream_read(test->m_inputStream.get(), &buffer, 512, 0, &error.outPtr())) {
+ g_assert(!error);
+ totalBytesFromStream += readBytes;
+ }
+
+ // Check that the file exists and that it contains the same amount of bytes.
+ GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_info(test->m_file.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE, static_cast<GFileQueryInfoFlags>(0), 0, 0));
+ g_assert_cmpint(g_file_info_get_size(fileInfo.get()), ==, totalBytesFromStream);
+}
+
+static void testWebViewMode(WebViewTest* test, gconstpointer)
+{
+ static const char* indexHTML = "<html><body><p>Test Web View Mode</p></body></html>";
+
+ // Web mode.
+ g_assert_cmpuint(webkit_web_view_get_view_mode(test->m_webView), ==, WEBKIT_VIEW_MODE_WEB);
+ test->loadHtml(indexHTML, 0);
+ test->waitUntilLoadFinished();
+ WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.document.body.textContent;", 0);
+ GOwnPtr<char> valueString(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "Test Web View Mode");
+
+ // Source mode.
+ webkit_web_view_set_view_mode(test->m_webView, WEBKIT_VIEW_MODE_SOURCE);
+ test->loadHtml(indexHTML, 0);
+ test->waitUntilLoadFinished();
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.document.body.textContent;", 0);
+ valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, indexHTML);
+}
+
+// To test page visibility API. Currently only 'visible' and 'hidden' states are implemented fully in WebCore.
+// See also http://www.w3.org/TR/2011/WD-page-visibility-20110602/ and https://developers.google.com/chrome/whitepapers/pagevisibility
+static void testWebViewPageVisibility(WebViewTest* test, gconstpointer)
+{
+ test->loadHtml("<html><title></title>"
+ "<body><p>Test Web Page Visibility</p>"
+ "<script>"
+ "document.addEventListener(\"visibilitychange\", onVisibilityChange, false);"
+ "function onVisibilityChange() {"
+ " document.title = document.visibilityState;"
+ "}"
+ "</script>"
+ "</body></html>",
+ 0);
+
+ // Wait untill the page is loaded. Initial visibility should be 'hidden'.
+ test->waitUntilLoadFinished();
+
+ GOwnPtr<GError> error;
+ WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.visibilityState;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ GOwnPtr<char> valueString(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "hidden");
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.hidden;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ g_assert(WebViewTest::javascriptResultToBoolean(javascriptResult));
+
+ // Show the page. The visibility should be updated to 'visible'.
+ test->showInWindow();
+ test->waitUntilTitleChanged();
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.visibilityState;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "visible");
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.hidden;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ g_assert(!WebViewTest::javascriptResultToBoolean(javascriptResult));
+
+ // Hide the page. The visibility should be updated to 'hidden'.
+ gtk_widget_hide(GTK_WIDGET(test->m_webView));
+ test->waitUntilTitleChanged();
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.visibilityState;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(valueString.get(), ==, "hidden");
+
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.hidden;", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+ g_assert(WebViewTest::javascriptResultToBoolean(javascriptResult));
+}
+
+class SnapshotWebViewTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(SnapshotWebViewTest);
+
+ static void onSnapshotCancelledReady(WebKitWebView* web_view, GAsyncResult* res, SnapshotWebViewTest* test)
+ {
+ GOwnPtr<GError> error;
+ test->m_surface = webkit_web_view_get_snapshot_finish(web_view, res, &error.outPtr());
+ g_assert(!test->m_surface);
+ g_assert_error(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED);
+ test->quitMainLoop();
+ }
+
+ gboolean getSnapshotAndCancel()
+ {
+ if (m_surface)
+ cairo_surface_destroy(m_surface);
+ m_surface = 0;
+ GRefPtr<GCancellable> cancellable = adoptGRef(g_cancellable_new());
+ webkit_web_view_get_snapshot(m_webView, WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE, cancellable.get(), reinterpret_cast<GAsyncReadyCallback>(onSnapshotCancelledReady), this);
+ g_cancellable_cancel(cancellable.get());
+ g_main_loop_run(m_mainLoop);
+
+ return true;
+ }
+
+};
+
+static void testWebViewSnapshot(SnapshotWebViewTest* test, gconstpointer)
+{
+ test->loadHtml("<html><body><p>Whatever</p></body></html>", 0);
+ test->waitUntilLoadFinished();
+
+ // WebView not visible.
+ cairo_surface_t* surface1 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE);
+ g_assert(!surface1);
+
+ // Show surface, resize to 50x50, try again.
+ test->showInWindowAndWaitUntilMapped();
+ test->resizeView(50, 50);
+ surface1 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE);
+ g_assert(surface1);
+
+ // obtained surface should be at the most 50x50. Store the size
+ // for comparison later.
+ int width = cairo_image_surface_get_width(surface1);
+ int height = cairo_image_surface_get_height(surface1);
+ g_assert_cmpint(width, <=, 50);
+ g_assert_cmpint(height, <=, 50);
+
+ // Select all text in the WebView, request a snapshot ignoring selection.
+ test->selectAll();
+ surface1 = cairo_surface_reference(test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE));
+ g_assert(surface1);
+ g_assert_cmpint(cairo_image_surface_get_width(surface1), ==, width);
+ g_assert_cmpint(cairo_image_surface_get_height(surface1), ==, height);
+
+ // Create identical surface.
+ cairo_surface_t* surface2 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE);
+ g_assert(surface2);
+
+ // Compare these two, they should be identical.
+ g_assert(Test::cairoSurfacesEqual(surface1, surface2));
+
+ // Request a new snapshot, including the selection this time. The
+ // size should be the same but the result must be different to the
+ // one previously obtained.
+ surface2 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING);
+ g_assert(surface2);
+ g_assert_cmpint(cairo_image_surface_get_width(surface2), ==, width);
+ g_assert_cmpint(cairo_image_surface_get_height(surface2), ==, height);
+ g_assert(!Test::cairoSurfacesEqual(surface1, surface2));
+
+ // Request a snapshot of the whole document in the WebView. The
+ // result should be different from the size obtained previously.
+ surface2 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE);
+ g_assert(surface2);
+ g_assert_cmpint(cairo_image_surface_get_width(surface2), >, width);
+ g_assert_cmpint(cairo_image_surface_get_height(surface2), >, height);
+ g_assert(!Test::cairoSurfacesEqual(surface1, surface2));
+
+ cairo_surface_destroy(surface1);
+
+ g_assert(test->getSnapshotAndCancel());
+}
+
+void beforeAll()
+{
+ WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
+ WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset);
+ WebViewTest::add("WebKitWebView", "settings", testWebViewSettings);
+ WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel);
+ WebViewTest::add("WebKitWebView", "run-javascript", testWebViewRunJavaScript);
+ FullScreenClientTest::add("WebKitWebView", "fullscreen", testWebViewFullScreen);
+ WebViewTest::add("WebKitWebView", "can-show-mime-type", testWebViewCanShowMIMEType);
+ FormClientTest::add("WebKitWebView", "submit-form", testWebViewSubmitForm);
+ SaveWebViewTest::add("WebKitWebView", "save", testWebViewSave);
+ WebViewTest::add("WebKitWebView", "view-mode", testWebViewMode);
+ SnapshotWebViewTest::add("WebKitWebView", "snapshot", testWebViewSnapshot);
+ WebViewTest::add("WebKitWebView", "page-visibility", testWebViewPageVisibility);
+}
+
+void afterAll()
+{
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebViewcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebViewGroupcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestWebKitWebViewGroupcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebViewGroup.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebViewGroup.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebViewGroup.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebViewGroup.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,206 @@
</span><ins>+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * 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,1 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 "WebKitTestServer.h"
+#include "WebViewTest.h"
+#include <cstdarg>
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+#include <wtf/gobject/GRefPtr.h>
+
+static WebKitTestServer* kServer;
+
+// These are all here so that they can be changed easily, if necessary.
+static const char* kStyleSheetHTML = "<html><div id=\"styledElement\">Sweet stylez!</div></html>";
+static const char* kInjectedStyleSheet = "#styledElement { font-weight: bold; }";
+static const char* kStyleSheetTestScript = "getComputedStyle(document.getElementById('styledElement'))['font-weight']";
+static const char* kStyleSheetTestScriptResult = "bold";
+
+static void testWebViewGroupDefault(Test* test, gconstpointer)
+{
+ // Default group is shared by all WebViews by default.
+ GRefPtr<WebKitWebView> webView1 = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ GRefPtr<WebKitWebView> webView2 = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ g_assert(webkit_web_view_get_group(webView1.get()) == webkit_web_view_get_group(webView2.get()));
+
+ // Settings are shared by all web view in the same group.
+ g_assert(webkit_web_view_get_settings(webView1.get()) == webkit_web_view_get_settings(webView2.get()));
+ g_assert(webkit_web_view_get_settings(webView1.get()) == webkit_web_view_group_get_settings(webkit_web_view_get_group(webView2.get())));
+}
+
+static void testWebViewGroupNewGroup(Test* test, gconstpointer)
+{
+ // Passing 0 as group name generates the name automatically.
+ GRefPtr<WebKitWebViewGroup> viewGroup1 = adoptGRef(webkit_web_view_group_new(0));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(viewGroup1.get()));
+ g_assert(webkit_web_view_group_get_name(viewGroup1.get()));
+
+ // New group with a given name.
+ GRefPtr<WebKitWebViewGroup> viewGroup2 = adoptGRef(webkit_web_view_group_new("TestGroup2"));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(viewGroup2.get()));
+ g_assert_cmpstr(webkit_web_view_group_get_name(viewGroup2.get()), ==, "TestGroup2");
+ g_assert_cmpstr(webkit_web_view_group_get_name(viewGroup2.get()), !=, webkit_web_view_group_get_name(viewGroup1.get()));
+
+ // Every group has its own settings.
+ g_assert(webkit_web_view_group_get_settings(viewGroup1.get()) != webkit_web_view_group_get_settings(viewGroup2.get()));
+}
+
+static void testWebViewNewWithGroup(Test* test, gconstpointer)
+{
+ GRefPtr<WebKitWebViewGroup> viewGroup1 = adoptGRef(webkit_web_view_group_new("TestGroup1"));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(viewGroup1.get()));
+ GRefPtr<WebKitWebView> webView1 = WEBKIT_WEB_VIEW(webkit_web_view_new_with_group(viewGroup1.get()));
+ g_assert(webkit_web_view_get_group(webView1.get()) == viewGroup1.get());
+
+ GRefPtr<WebKitWebView> webView2 = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ g_assert(webkit_web_view_get_group(webView2.get()) != viewGroup1.get());
+
+ // Settings should be different for views in different groups.
+ g_assert(webkit_web_view_get_settings(webView1.get()) != webkit_web_view_get_settings(webView2.get()));
+}
+
+static void testWebViewGroupSettings(Test* test, gconstpointer)
+{
+ GRefPtr<WebKitWebViewGroup> viewGroup1 = adoptGRef(webkit_web_view_group_new("TestGroup1"));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(viewGroup1.get()));
+ GRefPtr<WebKitSettings> newSettings = adoptGRef(webkit_settings_new_with_settings("enable-javascript", FALSE, nullptr));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(newSettings.get()));
+ webkit_web_view_group_set_settings(viewGroup1.get(), newSettings.get());
+ g_assert(webkit_web_view_group_get_settings(viewGroup1.get()) == newSettings.get());
+
+ GRefPtr<WebKitWebView> webView1 = WEBKIT_WEB_VIEW(webkit_web_view_new_with_group(viewGroup1.get()));
+ GRefPtr<WebKitWebView> webView2 = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ WebKitSettings* webView1Settings = webkit_web_view_get_settings(webView1.get());
+ WebKitSettings* webView2Settings = webkit_web_view_get_settings(webView2.get());
+ g_assert(webView1Settings != webView2Settings);
+ g_assert(webkit_settings_get_enable_javascript(webView1Settings) != webkit_settings_get_enable_javascript(webView2Settings));
+
+ webkit_web_view_set_settings(webView1.get(), webView2Settings);
+ g_assert(webkit_web_view_get_settings(webView1.get()) == webView2Settings);
+ g_assert(webkit_web_view_group_get_settings(webkit_web_view_get_group(webView1.get())) == webView2Settings);
+}
+
+static bool isStyleSheetInjectedForURLAtPath(WebViewTest* test, const char* path)
+{
+ test->loadURI(kServer->getURIForPath(path).data());
+ test->waitUntilLoadFinished();
+
+ GOwnPtr<GError> error;
+ WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished(kStyleSheetTestScript, &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error.get());
+
+ GOwnPtr<char> resultString(WebViewTest::javascriptResultToCString(javascriptResult));
+ return !g_strcmp0(resultString.get(), kStyleSheetTestScriptResult);
+}
+
+static void fillURLListFromPaths(char** list, const char* path, ...)
+{
+ va_list argumentList;
+ va_start(argumentList, path);
+
+ int i = 0;
+ while (path) {
+ // FIXME: We must use a wildcard for the host here until http://wkbug.com/112476 is fixed.
+ // Until that time patterns with port numbers in them will not properly match URLs with port numbers.
+ list[i++] = g_strdup_printf("http://*/%s*", path);
+ path = va_arg(argumentList, const char*);
+ }
+}
+
+static void removeOldInjectedStyleSheetsAndResetLists(WebKitWebViewGroup* group, char** whitelist, char** blacklist)
+{
+ webkit_web_view_group_remove_all_user_style_sheets(group);
+
+ while (*whitelist) {
+ g_free(*whitelist);
+ *whitelist = 0;
+ whitelist++;
+ }
+
+ while (*blacklist) {
+ g_free(*blacklist);
+ *blacklist = 0;
+ blacklist++;
+ }
+}
+
+static void testWebViewGroupInjectedStyleSheet(WebViewTest* test, gconstpointer)
+{
+ WebKitWebViewGroup* group = webkit_web_view_get_group(test->m_webView);
+ char* whitelist[3] = { 0, 0, 0 };
+ char* blacklist[3] = { 0, 0, 0 };
+
+ removeOldInjectedStyleSheetsAndResetLists(group, whitelist, blacklist);
+
+ // Without a whitelist or a blacklist all URLs should have the injected style sheet.
+ static const char* randomPath = "somerandompath";
+ g_assert(!isStyleSheetInjectedForURLAtPath(test, randomPath));
+ webkit_web_view_group_add_user_style_sheet(group, kInjectedStyleSheet, 0, 0, 0, WEBKIT_INJECTED_CONTENT_FRAMES_ALL);
+ g_assert(isStyleSheetInjectedForURLAtPath(test, randomPath));
+
+ removeOldInjectedStyleSheetsAndResetLists(group, whitelist, blacklist);
+
+ fillURLListFromPaths(blacklist, randomPath, 0);
+ webkit_web_view_group_add_user_style_sheet(group, kInjectedStyleSheet, 0, 0, blacklist, WEBKIT_INJECTED_CONTENT_FRAMES_ALL);
+ g_assert(!isStyleSheetInjectedForURLAtPath(test, randomPath));
+ g_assert(isStyleSheetInjectedForURLAtPath(test, "someotherrandompath"));
+
+ removeOldInjectedStyleSheetsAndResetLists(group, whitelist, blacklist);
+
+ static const char* inTheWhiteList = "inthewhitelist";
+ static const char* notInWhitelist = "notinthewhitelist";
+ static const char* inTheWhiteListAndBlackList = "inthewhitelistandblacklist";
+
+ fillURLListFromPaths(whitelist, inTheWhiteList, inTheWhiteListAndBlackList, 0);
+ fillURLListFromPaths(blacklist, inTheWhiteListAndBlackList, 0);
+ webkit_web_view_group_add_user_style_sheet(group, kInjectedStyleSheet, 0, whitelist, blacklist, WEBKIT_INJECTED_CONTENT_FRAMES_ALL);
+ g_assert(isStyleSheetInjectedForURLAtPath(test, inTheWhiteList));
+ g_assert(!isStyleSheetInjectedForURLAtPath(test, inTheWhiteListAndBlackList));
+ g_assert(!isStyleSheetInjectedForURLAtPath(test, notInWhitelist));
+
+ // It's important to clean up the environment before other tests.
+ removeOldInjectedStyleSheetsAndResetLists(group, whitelist, blacklist);
+}
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kStyleSheetHTML, strlen(kStyleSheetHTML));
+ soup_message_body_complete(message->response_body);
+}
+
+void beforeAll()
+{
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ Test::add("WebKitWebViewGroup", "default-group", testWebViewGroupDefault);
+ Test::add("WebKitWebViewGroup", "new-group", testWebViewGroupNewGroup);
+ Test::add("WebKitWebView", "new-with-group", testWebViewNewWithGroup);
+ Test::add("WebKitWebViewGroup", "settings", testWebViewGroupSettings);
+ WebViewTest::add("WebKitWebViewGroup", "injected-style-sheet", testWebViewGroupInjectedStyleSheet);
+}
+
+void afterAll()
+{
+ delete kServer;
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebViewGroupcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebViewGroup.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebViewEditorcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsTestWebViewEditorcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebViewEditor.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,202 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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,1 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 "WebViewTest.h"
+#include <wtf/gobject/GRefPtr.h>
+
+class EditorTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(EditorTest);
+
+ static const unsigned kClipboardWaitTimeout = 50;
+ static const unsigned kClipboardWaitMaxTries = 2;
+
+ EditorTest()
+ : m_clipboard(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD))
+ , m_canExecuteEditingCommand(false)
+ , m_triesCount(0)
+ {
+ gtk_clipboard_clear(m_clipboard);
+ }
+
+ static void canExecuteEditingCommandReadyCallback(GObject*, GAsyncResult* result, EditorTest* test)
+ {
+ GOwnPtr<GError> error;
+ test->m_canExecuteEditingCommand = webkit_web_view_can_execute_editing_command_finish(test->m_webView, result, &error.outPtr());
+ g_assert(!error.get());
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ bool canExecuteEditingCommand(const char* command)
+ {
+ m_canExecuteEditingCommand = false;
+ webkit_web_view_can_execute_editing_command(m_webView, command, 0, reinterpret_cast<GAsyncReadyCallback>(canExecuteEditingCommandReadyCallback), this);
+ g_main_loop_run(m_mainLoop);
+ return m_canExecuteEditingCommand;
+ }
+
+ static gboolean waitForClipboardText(EditorTest* test)
+ {
+ test->m_triesCount++;
+ if (gtk_clipboard_wait_is_text_available(test->m_clipboard) || test->m_triesCount > kClipboardWaitMaxTries) {
+ g_main_loop_quit(test->m_mainLoop);
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ void copyClipboard()
+ {
+ webkit_web_view_execute_editing_command(m_webView, WEBKIT_EDITING_COMMAND_COPY);
+ // There's no way to know when the selection has been copied to
+ // the clipboard, so use a timeout source to query the clipboard.
+ m_triesCount = 0;
+ g_timeout_add(kClipboardWaitTimeout, reinterpret_cast<GSourceFunc>(waitForClipboardText), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ GtkClipboard* m_clipboard;
+ bool m_canExecuteEditingCommand;
+ size_t m_triesCount;
+};
+
+static void testWebViewEditorCutCopyPasteNonEditable(EditorTest* test, gconstpointer)
+{
+ static const char* selectedSpanHTML = "<html><body contentEditable=\"false\">"
+ "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>"
+ "<script>document.getSelection().collapse();\n"
+ "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n"
+ "</script></body></html>";
+
+ // Nothing loaded yet.
+ g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT));
+ g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY));
+ g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE));
+
+ test->loadHtml(selectedSpanHTML, 0);
+ test->waitUntilLoadFinished();
+
+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY));
+ // It's not possible to cut and paste when content is not editable
+ // even if there's a selection.
+ g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT));
+ g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE));
+
+ test->copyClipboard();
+ GOwnPtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard));
+ g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull");
+}
+
+static void testWebViewEditorCutCopyPasteEditable(EditorTest* test, gconstpointer)
+{
+ static const char* selectedSpanHTML = "<html><body contentEditable=\"true\">"
+ "<span id=\"mainspan\">All work and no play <span>make Jack a dull</span> boy.</span>"
+ "<script>document.getSelection().collapse();\n"
+ "document.getSelection().selectAllChildren(document.getElementById('mainspan'));\n"
+ "</script></body></html>";
+
+ // Nothing loaded yet.
+ g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT));
+ g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY));
+ g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE));
+
+ test->loadHtml(selectedSpanHTML, 0);
+ test->waitUntilLoadFinished();
+
+ // There's a selection.
+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT));
+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY));
+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE));
+
+ test->copyClipboard();
+ GOwnPtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard));
+ g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy.");
+}
+
+static void testWebViewEditorSelectAllNonEditable(EditorTest* test, gconstpointer)
+{
+ static const char* selectedSpanHTML = "<html><body contentEditable=\"false\">"
+ "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>"
+ "<script>document.getSelection().collapse();\n"
+ "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n"
+ "</script></body></html>";
+
+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));
+
+ test->loadHtml(selectedSpanHTML, 0);
+ test->waitUntilLoadFinished();
+
+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));
+
+ test->copyClipboard();
+ GOwnPtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard));
+
+ // Initially only the subspan is selected.
+ g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull");
+
+ webkit_web_view_execute_editing_command(test->m_webView, WEBKIT_EDITING_COMMAND_SELECT_ALL);
+ test->copyClipboard();
+ clipboardText.set(gtk_clipboard_wait_for_text(test->m_clipboard));
+
+ // The mainspan should be selected after calling SELECT_ALL.
+ g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy.");
+}
+
+static void testWebViewEditorSelectAllEditable(EditorTest* test, gconstpointer)
+{
+ static const char* selectedSpanHTML = "<html><body contentEditable=\"true\">"
+ "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>"
+ "<script>document.getSelection().collapse();\n"
+ "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n"
+ "</script></body></html>";
+
+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));
+
+ test->loadHtml(selectedSpanHTML, 0);
+ test->waitUntilLoadFinished();
+
+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));
+
+ test->copyClipboard();
+ GOwnPtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard));
+
+ // Initially only the subspan is selected.
+ g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull");
+
+ webkit_web_view_execute_editing_command(test->m_webView, WEBKIT_EDITING_COMMAND_SELECT_ALL);
+ test->copyClipboard();
+ clipboardText.set(gtk_clipboard_wait_for_text(test->m_clipboard));
+
+ // The mainspan should be selected after calling SELECT_ALL.
+ g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy.");
+}
+
+void beforeAll()
+{
+ EditorTest::add("WebKitWebView", "cut-copy-paste/non-editable", testWebViewEditorCutCopyPasteNonEditable);
+ EditorTest::add("WebKitWebView", "cut-copy-paste/editable", testWebViewEditorCutCopyPasteEditable);
+ EditorTest::add("WebKitWebView", "select-all/non-editable", testWebViewEditorSelectAllNonEditable);
+ EditorTest::add("WebKitWebView", "select-all/editable", testWebViewEditorSelectAllEditable);
+}
+
+void afterAll()
+{
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebViewEditorcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkWebExtensionTestcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsWebExtensionTestcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,266 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 <JavaScriptCore/JSContextRef.h>
+#include <JavaScriptCore/JSRetainPtr.h>
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <webkit2/webkit-web-extension.h>
+#include <wtf/Deque.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+static const char introspectionXML[] =
+ "<node>"
+ " <interface name='org.webkit.gtk.WebExtensionTest'>"
+ " <method name='GetTitle'>"
+ " <arg type='t' name='pageID' direction='in'/>"
+ " <arg type='s' name='title' direction='out'/>"
+ " </method>"
+ " <method name='AbortProcess'>"
+ " </method>"
+ " <method name='RunJavaScriptInIsolatedWorld'>"
+ " <arg type='t' name='pageID' direction='in'/>"
+ " <arg type='s' name='script' direction='in'/>"
+ " </method>"
+ " <signal name='DocumentLoaded'/>"
+ " <signal name='URIChanged'>"
+ " <arg type='s' name='uri' direction='out'/>"
+ " </signal>"
+ " </interface>"
+ "</node>";
+
+typedef enum {
+ DocumentLoadedSignal,
+ URIChangedSignal,
+} DelayedSignalType;
+
+struct DelayedSignal {
+ DelayedSignal(DelayedSignalType type)
+ : type(type)
+ {
+ }
+
+ DelayedSignal(DelayedSignalType type, const char* uri)
+ : type(type)
+ , uri(uri)
+ {
+ }
+
+ DelayedSignalType type;
+ CString uri;
+};
+
+Deque<OwnPtr<DelayedSignal>> delayedSignalsQueue;
+
+static void emitDocumentLoaded(GDBusConnection* connection)
+{
+ bool ok = g_dbus_connection_emit_signal(
+ connection,
+ 0,
+ "/org/webkit/gtk/WebExtensionTest",
+ "org.webkit.gtk.WebExtensionTest",
+ "DocumentLoaded",
+ 0,
+ 0);
+ g_assert(ok);
+}
+
+static void documentLoadedCallback(WebKitWebPage*, WebKitWebExtension* extension)
+{
+ gpointer data = g_object_get_data(G_OBJECT(extension), "dbus-connection");
+ if (data)
+ emitDocumentLoaded(G_DBUS_CONNECTION(data));
+ else
+ delayedSignalsQueue.append(adoptPtr(new DelayedSignal(DocumentLoadedSignal)));
+}
+
+static void emitURIChanged(GDBusConnection* connection, const char* uri)
+{
+ bool ok = g_dbus_connection_emit_signal(
+ connection,
+ 0,
+ "/org/webkit/gtk/WebExtensionTest",
+ "org.webkit.gtk.WebExtensionTest",
+ "URIChanged",
+ g_variant_new("(s)", uri),
+ 0);
+ g_assert(ok);
+}
+
+static void uriChangedCallback(WebKitWebPage* webPage, GParamSpec* pspec, WebKitWebExtension* extension)
+{
+ gpointer data = g_object_get_data(G_OBJECT(extension), "dbus-connection");
+ if (data)
+ emitURIChanged(G_DBUS_CONNECTION(data), webkit_web_page_get_uri(webPage));
+ else
+ delayedSignalsQueue.append(adoptPtr(new DelayedSignal(URIChangedSignal, webkit_web_page_get_uri(webPage))));
+}
+
+static gboolean sendRequestCallback(WebKitWebPage*, WebKitURIRequest* request, WebKitURIResponse*, gpointer)
+{
+ const char* requestURI = webkit_uri_request_get_uri(request);
+ g_assert(requestURI);
+
+ if (const char* suffix = g_strrstr(requestURI, "/remove-this/javascript.js")) {
+ GOwnPtr<char> prefix(g_strndup(requestURI, strlen(requestURI) - strlen(suffix)));
+ GOwnPtr<char> newURI(g_strdup_printf("%s/javascript.js", prefix.get()));
+ webkit_uri_request_set_uri(request, newURI.get());
+ } else if (g_str_has_suffix(requestURI, "/add-do-not-track-header")) {
+ SoupMessageHeaders* headers = webkit_uri_request_get_http_headers(request);
+ g_assert(headers);
+ soup_message_headers_append(headers, "DNT", "1");
+ } else if (g_str_has_suffix(requestURI, "/cancel-this.js"))
+ return TRUE;
+
+ return FALSE;
+}
+
+static void pageCreatedCallback(WebKitWebExtension* extension, WebKitWebPage* webPage, gpointer)
+{
+ g_signal_connect(webPage, "document-loaded", G_CALLBACK(documentLoadedCallback), extension);
+ g_signal_connect(webPage, "notify::uri", G_CALLBACK(uriChangedCallback), extension);
+ g_signal_connect(webPage, "send-request", G_CALLBACK(sendRequestCallback), 0);
+}
+
+static JSValueRef echoCallback(JSContextRef jsContext, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef*)
+{
+ if (argumentCount <= 0)
+ return JSValueMakeUndefined(jsContext);
+
+ JSRetainPtr<JSStringRef> string(Adopt, JSValueToStringCopy(jsContext, arguments[0], 0));
+ return JSValueMakeString(jsContext, string.get());
+}
+
+static void windowObjectCleared(WebKitScriptWorld* world, WebKitWebPage* page, WebKitFrame* frame, gpointer)
+{
+ JSGlobalContextRef jsContext = webkit_frame_get_javascript_context_for_script_world(frame, world);
+ g_assert(jsContext);
+ JSObjectRef globalObject = JSContextGetGlobalObject(jsContext);
+ g_assert(globalObject);
+
+ JSRetainPtr<JSStringRef> functionName(Adopt, JSStringCreateWithUTF8CString("echo"));
+ JSObjectRef function = JSObjectMakeFunctionWithCallback(jsContext, functionName.get(), echoCallback);
+ JSObjectSetProperty(jsContext, globalObject, functionName.get(), function, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly, 0);
+}
+
+static WebKitWebPage* getWebPage(WebKitWebExtension* extension, uint64_t pageID, GDBusMethodInvocation* invocation)
+{
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, pageID);
+ if (!page) {
+ g_dbus_method_invocation_return_error(
+ invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
+ "Invalid page ID: %" G_GUINT64_FORMAT, pageID);
+ return 0;
+ }
+
+ g_assert_cmpuint(webkit_web_page_get_id(page), ==, pageID);
+ return page;
+}
+
+static void methodCallCallback(GDBusConnection* connection, const char* sender, const char* objectPath, const char* interfaceName, const char* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData)
+{
+ if (g_strcmp0(interfaceName, "org.webkit.gtk.WebExtensionTest"))
+ return;
+
+ if (!g_strcmp0(methodName, "GetTitle")) {
+ uint64_t pageID;
+ g_variant_get(parameters, "(t)", &pageID);
+ WebKitWebPage* page = getWebPage(WEBKIT_WEB_EXTENSION(userData), pageID, invocation);
+ if (!page)
+ return;
+
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ GOwnPtr<char> title(webkit_dom_document_get_title(document));
+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", title.get()));
+ } else if (!g_strcmp0(methodName, "RunJavaScriptInIsolatedWorld")) {
+ uint64_t pageID;
+ const char* script;
+ g_variant_get(parameters, "(t&s)", &pageID, &script);
+ WebKitWebPage* page = getWebPage(WEBKIT_WEB_EXTENSION(userData), pageID, invocation);
+ if (!page)
+ return;
+
+ GRefPtr<WebKitScriptWorld> world = adoptGRef(webkit_script_world_new());
+ g_assert(webkit_script_world_get_default() != world.get());
+ WebKitFrame* frame = webkit_web_page_get_main_frame(page);
+ JSGlobalContextRef jsContext = webkit_frame_get_javascript_context_for_script_world(frame, world.get());
+ JSRetainPtr<JSStringRef> jsScript(Adopt, JSStringCreateWithUTF8CString(script));
+ JSEvaluateScript(jsContext, jsScript.get(), 0, 0, 0, 0);
+ g_dbus_method_invocation_return_value(invocation, 0);
+ } else if (!g_strcmp0(methodName, "AbortProcess"))
+ abort();
+}
+
+static const GDBusInterfaceVTable interfaceVirtualTable = {
+ methodCallCallback, 0, 0, { 0, }
+};
+
+static void busAcquiredCallback(GDBusConnection* connection, const char* name, gpointer userData)
+{
+ static GDBusNodeInfo* introspectionData = 0;
+ if (!introspectionData)
+ introspectionData = g_dbus_node_info_new_for_xml(introspectionXML, 0);
+
+ GOwnPtr<GError> error;
+ unsigned registrationID = g_dbus_connection_register_object(
+ connection,
+ "/org/webkit/gtk/WebExtensionTest",
+ introspectionData->interfaces[0],
+ &interfaceVirtualTable,
+ g_object_ref(userData),
+ static_cast<GDestroyNotify>(g_object_unref),
+ &error.outPtr());
+ if (!registrationID)
+ g_warning("Failed to register object: %s\n", error->message);
+
+ g_object_set_data(G_OBJECT(userData), "dbus-connection", connection);
+ while (delayedSignalsQueue.size()) {
+ OwnPtr<DelayedSignal> delayedSignal = delayedSignalsQueue.takeFirst();
+ switch (delayedSignal->type) {
+ case DocumentLoadedSignal:
+ emitDocumentLoaded(connection);
+ break;
+ case URIChangedSignal:
+ emitURIChanged(connection, delayedSignal->uri.data());
+ break;
+ }
+ }
+}
+
+extern "C" void webkit_web_extension_initialize(WebKitWebExtension* extension)
+{
+ g_signal_connect(extension, "page-created", G_CALLBACK(pageCreatedCallback), extension);
+ g_signal_connect(webkit_script_world_get_default(), "window-object-cleared", G_CALLBACK(windowObjectCleared), 0);
+
+ g_bus_own_name(
+ G_BUS_TYPE_SESSION,
+ "org.webkit.gtk.WebExtensionTest",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ busAcquiredCallback,
+ 0, 0,
+ g_object_ref(extension),
+ static_cast<GDestroyNotify>(g_object_unref));
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkWebExtensionTestcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkWebProcessTestcppfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsWebProcessTestcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTest.cpp) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,106 @@
</span><ins>+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * 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 "WebProcessTest.h"
+
+#include <gio/gio.h>
+#include <wtf/gobject/GOwnPtr.h>
+
+typedef HashMap<String, std::function<PassOwnPtr<WebProcessTest> ()>> TestsMap;
+static TestsMap& testsMap()
+{
+ DEFINE_STATIC_LOCAL(TestsMap, s_testsMap, ());
+ return s_testsMap;
+}
+
+void WebProcessTest::add(const String& testName, std::function<PassOwnPtr<WebProcessTest> ()> closure)
+{
+ testsMap().add(testName, std::forward<std::function<PassOwnPtr<WebProcessTest> ()>>(closure));
+}
+
+PassOwnPtr<WebProcessTest> WebProcessTest::create(const String& testName)
+{
+ g_assert(testsMap().contains(testName));
+ return testsMap().get(testName)();
+}
+
+static const char introspectionXML[] =
+ "<node>"
+ " <interface name='org.webkit.gtk.WebProcessTest'>"
+ " <method name='RunTest'>"
+ " <arg type='s' name='path' direction='in'/>"
+ " <arg type='a{sv}' name='args' direction='in'/>"
+ " <arg type='b' name='result' direction='out'/>"
+ " </method>"
+ " </interface>"
+ "</node>";
+
+static void methodCallCallback(GDBusConnection* connection, const char* sender, const char* objectPath, const char* interfaceName, const char* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData)
+{
+ if (g_strcmp0(interfaceName, "org.webkit.gtk.WebProcessTest"))
+ return;
+
+ if (!g_strcmp0(methodName, "RunTest")) {
+ const char* testPath;
+ GVariant* args;
+ g_variant_get(parameters, "(&s@a{sv})", &testPath, &args);
+ OwnPtr<WebProcessTest> test = WebProcessTest::create(String::fromUTF8(testPath));
+ bool result = test->runTest(g_strrstr(testPath, "/") + 1, WEBKIT_WEB_EXTENSION(userData), args);
+ g_variant_unref(args);
+
+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", result));
+ } else
+ g_assert_not_reached();
+}
+
+static const GDBusInterfaceVTable interfaceVirtualTable = {
+ methodCallCallback, 0, 0, { 0, }
+};
+
+static void busAcquiredCallback(GDBusConnection* connection, const char* name, gpointer userData)
+{
+ static GDBusNodeInfo* introspectionData = 0;
+ if (!introspectionData)
+ introspectionData = g_dbus_node_info_new_for_xml(introspectionXML, 0);
+
+ GOwnPtr<GError> error;
+ unsigned registrationID = g_dbus_connection_register_object(
+ connection,
+ "/org/webkit/gtk/WebProcessTest",
+ introspectionData->interfaces[0],
+ &interfaceVirtualTable,
+ g_object_ref(userData),
+ static_cast<GDestroyNotify>(g_object_unref),
+ &error.outPtr());
+ if (!registrationID)
+ g_warning("Failed to register object: %s\n", error->message);
+}
+
+extern "C" void webkit_web_extension_initialize(WebKitWebExtension* extension)
+{
+ g_bus_own_name(
+ G_BUS_TYPE_SESSION,
+ "org.webkit.gtk.WebProcessTest",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ busAcquiredCallback,
+ 0, 0,
+ g_object_ref(extension),
+ static_cast<GDestroyNotify>(g_object_unref));
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkWebProcessTestcpp"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkWebProcessTesthfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsWebProcessTesth"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebProcessTest.h) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * 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 <webkit2/webkit-web-extension.h>
+#include <wtf/HashMap.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+class WebProcessTest {
+public:
+ virtual ~WebProcessTest() { }
+ virtual bool runTest(const char* testName, WebKitWebExtension*, GVariant* args) = 0;
+
+ static void add(const String& testName, std::function<PassOwnPtr<WebProcessTest> ()>);
+ static PassOwnPtr<WebProcessTest> create(const String& testName);
+};
+
+#define REGISTER_TEST(ClassName, TestName) \
+ WebProcessTest::add(String::fromUTF8(TestName), ClassName::create)
+
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkWebProcessTesth"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Gtkresourceslinktitlejsfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsresourceslinktitlejs"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/link-title.js (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/link-title.js         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/link-title.js        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+window.document.getElementById('WebKitLink').title;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Gtkresourceslinktitlejs"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/link-title.js</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Gtkresourcestestcertpemfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsresourcestestcertpem"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/test-cert.pem (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/resources/test-cert.pem) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/test-cert.pem         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/test-cert.pem        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+-----BEGIN CERTIFICATE-----
+MIIB9jCCAV+gAwIBAgIJALeuXBo+vwz9MA0GCSqGSIb3DQEBBQUAMBQxEjAQBgNV
+BAMMCTEyNy4wLjAuMTAeFw0xMjA3MTIxMjQ4MjRaFw0yMjA3MTAxMjQ4MjRaMBQx
+EjAQBgNVBAMMCTEyNy4wLjAuMTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
+0TUzOQxHBIKDD2mkuq+tU92mQvDZg73B0G+Nhr2T2G6MbcLqIwjg1QYtBZWJ83tZ
+xMMEfiweHLF85Z9ohavAgxJlKG7YmvZO79KkFpmjV2W5CVRm0eYMPnzmxNCoaYqo
+DLl0zsH6KZOLPKu/fX4eDX9XpAP1f83hWB1UFBmHKN8CAwEAAaNQME4wHQYDVR0O
+BBYEFDHv5ZQ1BdmhzTsDUEoY55EXyUdKMB8GA1UdIwQYMBaAFDHv5ZQ1BdmhzTsD
+UEoY55EXyUdKMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAh3qMBx7v
+jSodMf3OyTqTLE7deLnmnCeBVpgzxRZEoizcGqYcjiqO27i5N5Z6KVQsnITnLiyC
+mUtuR5KnF69uTKUw4m/ugZe5whjig5Mq2l410KVK6EeG4tdLlfXR+wi4U5K4KjP6
+p4nchQUXLa2zcbJn+VBexJn6/9wdhr+DUGY=
+-----END CERTIFICATE-----
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Gtkresourcestestkeypemfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsresourcestestkeypem"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/test-key.pem (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/resources/test-key.pem) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/test-key.pem         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/test-key.pem        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANE1MzkMRwSCgw9p
+pLqvrVPdpkLw2YO9wdBvjYa9k9hujG3C6iMI4NUGLQWVifN7WcTDBH4sHhyxfOWf
+aIWrwIMSZShu2Jr2Tu/SpBaZo1dluQlUZtHmDD585sTQqGmKqAy5dM7B+imTizyr
+v31+Hg1/V6QD9X/N4VgdVBQZhyjfAgMBAAECgYB2QwOUsRsIMprRwJ9tJNfvO7G7
+z5i1/zOrlxPC4jHMPBnIBlICwgcOhLI4oOLdr5H8R12n0VqoT7DRwP396iwlJipF
+iO1heDMn/8z8LPGwkCK/+ck04rMDksxWIdMwYKBXt9ahnJ/xRLzQ1/3AJiAGnoe5
+/QLXQweofd4mmfsjKQJBAO2CwT7uMP6nMjXgtVMJq5QP8UbeCS1sEOPJJbHuDxJB
+/HePQHBjq4kzG6CL4oO7T+5fDv4g+fIIHzuXerZ0imsCQQDhfmiTIc9OucEIfg6/
+ms0JiKSmWc+qoiOCtrILuQvFoNwJRciQANqeJs6wpaDvevSUvBLGfG/7b3HvaE5X
+iqBdAkBEQIvp2qcHtuJN60oQF7pPrRknxUyb2e8sljQX4pJAK+gyL19ULMAxiBdL
+Vod8VYqNtJFpY+6Pp9fZ1xjzb6ALAkEA4JzrDAw0lQXA+3WduUw4ixOadr2ldyG0
+36KebcDwsfZO18m0Q4UmPz0Gy7zgN0wxzuochaw0W6+iPUiYKOlEXQJBAMWQrPlu
+rrinoZS2f8doJ9BNNUa+RNpMug6UXc55qoUJlyiXEh+tu4AaMOtxuGIyC0sAcuw6
+XdAPVPXKd7Mne70=
+-----END PRIVATE KEY-----
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Gtkresourceswebkit2gtktestsgresourcexmlfromrev161365trunkSourceWebKit2UIProcessAPIgtktestsresourceswebkit2gtktestsgresourcexml"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml (from rev 161365, trunk/Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/webkit/webkit2gtk/tests/">
+ <file alias="link-title.js">Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/link-title.js</file>
+ </gresource>
+</gresources>
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Gtkresourceswebkit2gtktestsgresourcexml"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKitGtkCMakeListstxtfromrev161365trunkSourceWebKitgtktestsCMakeListstxt"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/CMakeLists.txt (from rev 161365, trunk/Source/WebKit/gtk/tests/CMakeLists.txt) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/CMakeLists.txt         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/CMakeLists.txt        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+add_definitions(-DTEST_PLUGIN_DIR="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
+include_directories(
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/Source
+ ${CMAKE_SOURCE_DIR}/Source/JavaScriptCore/ForwardingHeaders
+ ${CMAKE_SOURCE_DIR}/Source/WebKit/gtk
+ ${CMAKE_SOURCE_DIR}/Source/WebCore/platform/gtk
+ ${CMAKE_SOURCE_DIR}/Source/WebCore/platform
+ ${CMAKE_SOURCE_DIR}/Source/WTF
+ ${DERIVED_SOURCES_DIR}
+ ${DERIVED_SOURCES_WEBKITGTK_DIR}
+ ${GLIB_INCLUDE_DIRS}
+ ${GTK3_INCLUDE_DIRS}
+ ${LIBSOUP_INCLUDE_DIRS}
+)
+
+macro(ADD_WK1_TEST test_name)
+ add_executable(${test_name} ${ARGN})
+ target_link_libraries(${test_name}
+ JavaScriptCore
+ WebKit
+ ${GLIB_LIBRARIES}
+ ${GTK3_LIBRARIES}
+ ${LIBSOUP_LIBRARIES}
+ )
+ set_target_properties(${test_name} PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/TestWebKitAPI/WebKitGtk
+ )
+endmacro()
+
+ADD_WK1_TEST(testapplicationcache testapplicationcache.c)
+ADD_WK1_TEST(testatkroles testatkroles.c)
+ADD_WK1_TEST(testatk testatk.c)
+ADD_WK1_TEST(testcontextmenu testcontextmenu.c)
+ADD_WK1_TEST(testcopyandpaste testcopyandpaste.c ${WEBCORE_DIR}/platform/gtk/GtkVersioning.c)
+ADD_WK1_TEST(testdomdocument testdomdocument.c)
+ADD_WK1_TEST(testdomdomwindow testdomdomwindow.c)
+ADD_WK1_TEST(testdomnode testdomnode.c)
+ADD_WK1_TEST(testdownload testdownload.c)
+ADD_WK1_TEST(testfavicondatabase testfavicondatabase.c test_utils.c)
+ADD_WK1_TEST(testglobals testglobals.c)
+ADD_WK1_TEST(testhittestresult testhittestresult.c)
+ADD_WK1_TEST(testhttpbackend testhttpbackend.c)
+ADD_WK1_TEST(testkeyevents testkeyevents.c)
+ADD_WK1_TEST(testloading testloading.c)
+ADD_WK1_TEST(testmimehandling testmimehandling.c test_utils.c)
+ADD_WK1_TEST(testnetworkrequest testnetworkrequest.c)
+ADD_WK1_TEST(testnetworkresponse testnetworkresponse.c)
+ADD_WK1_TEST(testwebbackforwardlist testwebbackforwardlist.c)
+ADD_WK1_TEST(testwebdatasource testwebdatasource.c)
+ADD_WK1_TEST(testwebframe testwebframe.c)
+ADD_WK1_TEST(testwebhistoryitem testwebhistoryitem.c)
+ADD_WK1_TEST(testwebinspector testwebinspector.c test_utils.c)
+ADD_WK1_TEST(testwebplugindatabase testwebplugindatabase.c)
+ADD_WK1_TEST(testwebresource testwebresource.c)
+ADD_WK1_TEST(testwebsettings testwebsettings.c)
+ADD_WK1_TEST(testwebview testwebview.c test_utils.c)
+ADD_WK1_TEST(testwindow testwindow.c)
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitGtkCMakeListstxt"></a>
<div class="propset"><h4>Property changes: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/CMakeLists.txt</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkToolsTestWebKitAPITestsWebKitGtkresourcesblankicofromrev161365trunkSourceWebKitgtktestsresourcesblankico"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/resources/blank.ico (from rev 161365, trunk/Source/WebKit/gtk/tests/resources/blank.ico) (0 => 161366)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/resources/blank.ico         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/resources/blank.ico        2014-01-06 21:14:30 UTC (rev 161366)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+ \xB0 (