Skip to content

Commit 4fdd84b

Browse files
Mikhail Pozdnyakovwebkit-commit-queue
authored andcommitted
WebKitTestRunner needs testRunner.queueLoadingScript and testRunner.queueNonLoadingScript
https://bugs.webkit.org/show_bug.cgi?id=42675 Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> on 2012-10-22 Reviewed by Kenneth Rohde Christiansen. Tools: Added implementation of testRunner.queueLoadingScript and testRunner.queueNonLoadingScript. * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: (WTR::InjectedBundle::queueLoadingScript): (WTR): (WTR::InjectedBundle::queueNonLoadingScript): * WebKitTestRunner/InjectedBundle/InjectedBundle.h: (InjectedBundle): * WebKitTestRunner/InjectedBundle/TestRunner.cpp: (WTR::TestRunner::queueLoadingScript): (WTR): (WTR::TestRunner::queueNonLoadingScript): * WebKitTestRunner/InjectedBundle/TestRunner.h: (TestRunner): * WebKitTestRunner/TestInvocation.cpp: (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): * WebKitTestRunner/WorkQueueManager.cpp: (WTR): (WTR::runJavaScriptFunction): (ScriptItem): (WTR::ScriptItem::ScriptItem): (WTR::ScriptItem::invoke): (WTR::WorkQueueManager::queueBackNavigation): (WTR::WorkQueueManager::queueLoadingScript): (WTR::WorkQueueManager::queueNonLoadingScript): * WebKitTestRunner/WorkQueueManager.h: (WorkQueueManager): LayoutTests: Unskipped corresponding test cases for WK2. Put those which still fail to appropriate groups. * platform/wk2/TestExpectations: Canonical link: https://commits.webkit.org/117976@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@132041 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 9087d75 commit 4fdd84b

11 files changed

Lines changed: 166 additions & 43 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2012-10-22 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
2+
3+
WebKitTestRunner needs testRunner.queueLoadingScript and testRunner.queueNonLoadingScript
4+
https://bugs.webkit.org/show_bug.cgi?id=42675
5+
6+
Reviewed by Kenneth Rohde Christiansen.
7+
8+
Unskipped corresponding test cases for WK2. Put those which still fail to appropriate
9+
groups.
10+
11+
* platform/wk2/TestExpectations:
12+
113
2012-10-22 Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
214

315
[EFL] Rebaseline pixel expectations after r131941 and r131991, part 2.

LayoutTests/platform/wk2/TestExpectations

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -293,34 +293,9 @@ svg/custom/manually-parsed-embedded-svg-allowed-in-dashboard.html
293293
svg/custom/manually-parsed-svg-allowed-in-dashboard.html
294294
svg/custom/svg-allowed-in-dashboard-object.html
295295

296-
# WebKitTestRunner needs testRunner.queueNonLoadingScript
297-
# <https://bugs.webkit.org/show_bug.cgi?id=98141>
298-
http/tests/navigation/anchor-goback.html
299-
http/tests/navigation/error404-goback.html
300-
http/tests/navigation/javascriptlink-goback.html
301-
http/tests/navigation/metaredirect-goback.html
302-
http/tests/navigation/post-goback2.html
303-
http/tests/navigation/postredirect-basic.html
304-
http/tests/navigation/postredirect-frames.html
305-
http/tests/navigation/postredirect-goback1.html
306-
http/tests/navigation/postredirect-goback2.html
307-
http/tests/navigation/redirect302-goback.html
308-
http/tests/navigation/relativeanchor-basic.html
309-
http/tests/navigation/relativeanchor-frames.html
310-
http/tests/navigation/relativeanchor-goback.html
311-
http/tests/navigation/restore-form-state-https.html
312-
http/tests/navigation/success200-frames-loadsame.html
313-
http/tests/navigation/success200-goback.html
314-
http/tests/navigation/success200-loadsame.html
315-
http/tests/navigation/success200-reload.html
316-
http/tests/navigation/timerredirect-goback.html
317-
318-
# WebKitTestRunner needs testRunner.queueLoadingScript
319-
# <https://bugs.webkit.org/show_bug.cgi?id=42675>
296+
# WebKitTestRunner needs testRunner.queueForwardNavigation
297+
# <https://bugs.webkit.org/show_bug.cgi?id=99700>
320298
http/tests/cache/subresource-failover-to-network.html
321-
http/tests/navigation/forward-and-cancel.html
322-
http/tests/navigation/post-goback-same-url.html
323-
http/tests/navigation/postredirect-reload.html
324299

325300
# WebKitTestRunner needs layoutTestController.setCacheModel
326301
# <https://bugs.webkit.org/show_bug.cgi?id=42684>
@@ -749,6 +724,13 @@ http/tests/navigation/response204.html
749724
http/tests/navigation/success200-subframeload.html
750725
http/tests/navigation/timerredirect-subframeload.html
751726

727+
# Redirected to unexpected page. Might be EFL port specific issue.
728+
http/tests/navigation/postredirect-basic.html
729+
http/tests/navigation/postredirect-goback1.html
730+
731+
# Unexpected output from scrolling. Might be EFL port specific issue.
732+
http/tests/navigation/relativeanchor-frames.html
733+
752734
### END OF (2) Classified failures without bug reports (yet)
753735
########################################
754736

Tools/ChangeLog

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
2012-10-22 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
2+
3+
WebKitTestRunner needs testRunner.queueLoadingScript and testRunner.queueNonLoadingScript
4+
https://bugs.webkit.org/show_bug.cgi?id=42675
5+
6+
Reviewed by Kenneth Rohde Christiansen.
7+
8+
Added implementation of testRunner.queueLoadingScript and testRunner.queueNonLoadingScript.
9+
10+
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
11+
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
12+
(WTR::InjectedBundle::queueLoadingScript):
13+
(WTR):
14+
(WTR::InjectedBundle::queueNonLoadingScript):
15+
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
16+
(InjectedBundle):
17+
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
18+
(WTR::TestRunner::queueLoadingScript):
19+
(WTR):
20+
(WTR::TestRunner::queueNonLoadingScript):
21+
* WebKitTestRunner/InjectedBundle/TestRunner.h:
22+
(TestRunner):
23+
* WebKitTestRunner/TestInvocation.cpp:
24+
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
25+
* WebKitTestRunner/WorkQueueManager.cpp:
26+
(WTR):
27+
(WTR::runJavaScriptFunction):
28+
(ScriptItem):
29+
(WTR::ScriptItem::ScriptItem):
30+
(WTR::ScriptItem::invoke):
31+
(WTR::WorkQueueManager::queueBackNavigation):
32+
(WTR::WorkQueueManager::queueLoadingScript):
33+
(WTR::WorkQueueManager::queueNonLoadingScript):
34+
* WebKitTestRunner/WorkQueueManager.h:
35+
(WorkQueueManager):
36+
137
2012-10-22 Zan Dobersek <zandobersek@gmail.com>
238

339
Unreviewed, a follow-up to r132034 where I forgot to address

Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,5 +186,7 @@ interface TestRunner {
186186
void queueBackNavigation(in unsigned long howFarBackward);
187187
void queueLoad(in DOMString url, in DOMString target);
188188
void queueReload();
189+
void queueLoadingScript(in DOMString script);
190+
void queueNonLoadingScript(in DOMString script);
189191
};
190192

Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,4 +507,20 @@ void InjectedBundle::queueReload()
507507
WKBundlePostMessage(m_bundle, messageName.get(), 0);
508508
}
509509

510+
void InjectedBundle::queueLoadingScript(WKStringRef script)
511+
{
512+
m_useWorkQueue = true;
513+
514+
WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueLoadingScript"));
515+
WKBundlePostMessage(m_bundle, messageName.get(), script);
516+
}
517+
518+
void InjectedBundle::queueNonLoadingScript(WKStringRef script)
519+
{
520+
m_useWorkQueue = true;
521+
522+
WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueNonLoadingScript"));
523+
WKBundlePostMessage(m_bundle, messageName.get(), script);
524+
}
525+
510526
} // namespace WTR

Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ class InjectedBundle {
104104
void queueBackNavigation(unsigned howFarBackward);
105105
void queueLoad(WKStringRef url, WKStringRef target);
106106
void queueReload();
107+
void queueLoadingScript(WKStringRef script);
108+
void queueNonLoadingScript(WKStringRef script);
107109

108110
private:
109111
InjectedBundle();

Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,4 +852,16 @@ void TestRunner::queueReload()
852852
InjectedBundle::shared().queueReload();
853853
}
854854

855+
void TestRunner::queueLoadingScript(JSStringRef script)
856+
{
857+
WKRetainPtr<WKStringRef> scriptWK = toWK(script);
858+
InjectedBundle::shared().queueLoadingScript(scriptWK.get());
859+
}
860+
861+
void TestRunner::queueNonLoadingScript(JSStringRef script)
862+
{
863+
WKRetainPtr<WKStringRef> scriptWK = toWK(script);
864+
InjectedBundle::shared().queueNonLoadingScript(scriptWK.get());
865+
}
866+
855867
} // namespace WTR

Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ class TestRunner : public JSWrappable {
265265
void queueBackNavigation(unsigned howFarBackward);
266266
void queueLoad(JSStringRef url, JSStringRef target);
267267
void queueReload();
268+
void queueLoadingScript(JSStringRef script);
269+
void queueNonLoadingScript(JSStringRef script);
268270

269271
private:
270272
static const double waitToDumpWatchdogTimerInterval;

Tools/WebKitTestRunner/TestInvocation.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,20 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
466466
return;
467467
}
468468

469+
if (WKStringIsEqualToUTF8CString(messageName, "QueueLoadingScript")) {
470+
ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
471+
WKStringRef script = static_cast<WKStringRef>(messageBody);
472+
TestController::shared().workQueueManager().queueLoadingScript(toWTFString(script));
473+
return;
474+
}
475+
476+
if (WKStringIsEqualToUTF8CString(messageName, "QueueNonLoadingScript")) {
477+
ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
478+
WKStringRef script = static_cast<WKStringRef>(messageBody);
479+
TestController::shared().workQueueManager().queueNonLoadingScript(toWTFString(script));
480+
return;
481+
}
482+
469483
ASSERT_NOT_REACHED();
470484
}
471485

Tools/WebKitTestRunner/WorkQueueManager.cpp

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "PlatformWebView.h"
3030
#include "TestController.h"
3131
#include <WebKit2/WKPage.h>
32+
#include <WebKit2/WKRetainPtr.h>
3233
#include <wtf/PassOwnPtr.h>
3334
#include <wtf/text/CString.h>
3435

@@ -53,11 +54,48 @@ static inline bool goToItemAtIndex(int index)
5354
return true;
5455
}
5556

57+
class WorkQueueItem {
58+
public:
59+
enum Type {
60+
Loading,
61+
NonLoading
62+
};
63+
64+
virtual ~WorkQueueItem() { }
65+
virtual Type invoke() const = 0;
66+
};
67+
68+
// Required by WKPageRunJavaScriptInMainFrame().
69+
static void runJavaScriptFunction(WKSerializedScriptValueRef, WKErrorRef, void*)
70+
{
71+
}
72+
73+
template <WorkQueueItem::Type type>
74+
class ScriptItem : public WorkQueueItem {
75+
public:
76+
explicit ScriptItem(const String& script)
77+
: m_script(AdoptWK, WKStringCreateWithUTF8CString(script.utf8().data()))
78+
{
79+
}
80+
81+
WorkQueueItem::Type invoke() const
82+
{
83+
WKPageRunJavaScriptInMainFrame(mainPage(), m_script.get(), 0, runJavaScriptFunction);
84+
return type;
85+
}
86+
87+
WKRetainPtr<WKStringRef> m_script;
88+
};
89+
5690
WorkQueueManager::WorkQueueManager()
5791
: m_processing(false)
5892
{
5993
}
6094

95+
WorkQueueManager::~WorkQueueManager()
96+
{
97+
}
98+
6199
void WorkQueueManager::clearWorkQueue()
62100
{
63101
m_processing = false;
@@ -69,7 +107,7 @@ bool WorkQueueManager::processWorkQueue()
69107
m_processing = false;
70108
while (!m_processing && !m_workQueue.isEmpty()) {
71109
OwnPtr<WorkQueueItem> item(m_workQueue.takeFirst());
72-
m_processing = item->invoke();
110+
m_processing = (item->invoke() == WorkQueueItem::Loading);
73111
}
74112

75113
return !m_processing;
@@ -85,15 +123,15 @@ void WorkQueueManager::queueLoad(const String& url, const String& target)
85123
{
86124
}
87125

88-
bool invoke() const
126+
WorkQueueItem::Type invoke() const
89127
{
90128
if (!m_target.isEmpty()) {
91129
// FIXME: Use target. Some layout tests cannot pass as they rely on this functionality.
92130
fprintf(stderr, "queueLoad for a specific target is not implemented.\n");
93-
return false;
131+
return WorkQueueItem::NonLoading;
94132
}
95133
WKPageLoadURL(mainPage(), m_url.get());
96-
return true;
134+
return WorkQueueItem::Loading;
97135
}
98136

99137
WKRetainPtr<WKURLRef> m_url;
@@ -107,9 +145,9 @@ void WorkQueueManager::queueBackNavigation(unsigned howFarBackward)
107145
{
108146
class BackNavigationItem : public WorkQueueItem {
109147
public:
110-
BackNavigationItem(unsigned howFarBackward) : m_howFarBackward(howFarBackward) { }
148+
explicit BackNavigationItem(unsigned howFarBackward) : m_howFarBackward(howFarBackward) { }
111149

112-
bool invoke() const { return goToItemAtIndex(-m_howFarBackward); }
150+
WorkQueueItem::Type invoke() const { return goToItemAtIndex(-m_howFarBackward) ? WorkQueueItem::Loading : WorkQueueItem::NonLoading; }
113151

114152
unsigned m_howFarBackward;
115153
};
@@ -121,16 +159,26 @@ void WorkQueueManager::queueReload()
121159
{
122160
class ReloadItem : public WorkQueueItem {
123161
public:
124-
bool invoke() const
162+
WorkQueueItem::Type invoke() const
125163
{
126164
WKPageReload(mainPage());
127-
return true;
165+
return WorkQueueItem::Loading;
128166
}
129167
};
130168

131169
enqueue(new ReloadItem());
132170
}
133171

172+
void WorkQueueManager::queueLoadingScript(const String& script)
173+
{
174+
enqueue(new ScriptItem<WorkQueueItem::Loading>(script));
175+
}
176+
177+
void WorkQueueManager::queueNonLoadingScript(const String& script)
178+
{
179+
enqueue(new ScriptItem<WorkQueueItem::NonLoading>(script));
180+
}
181+
134182
void WorkQueueManager::enqueue(WorkQueueItem* item)
135183
{
136184
ASSERT(item);

0 commit comments

Comments
 (0)