WebKit Bugzilla
Attachment 342053 Details for
Bug 186045
: webkit-test-runner: Add support for the reftest-wait class name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch (WIP)
0001-webkit-test-runner-Add-support-for-the-reftest-wait-.patch (text/plain), 8.62 KB, created by
Frédéric Wang (:fredw)
on 2018-06-06 09:46:48 PDT
(
hide
)
Description:
Patch (WIP)
Filename:
MIME Type:
Creator:
Frédéric Wang (:fredw)
Created:
2018-06-06 09:46:48 PDT
Size:
8.62 KB
patch
obsolete
>From 1d5347a52ffd4307a74a2349cda57aecef7a9b12 Mon Sep 17 00:00:00 2001 >From: Frederic Wang <fwang@igalia.com> >Date: Wed, 6 Jun 2018 18:45:32 +0200 >Subject: [PATCH xserver] webkit-test-runner: Add support for the reftest-wait > attribute > >--- > .../reftest-wait-expected-mismatch.html | 6 ++++ > LayoutTests/reftest-wait.html | 12 ++++++++ > .../InjectedBundle/InjectedBundle.cpp | 30 +++++++++++++++++++ > .../InjectedBundle/InjectedBundle.h | 1 + > Tools/WebKitTestRunner/TestController.cpp | 6 ++++ > Tools/WebKitTestRunner/TestController.h | 1 + > Tools/WebKitTestRunner/TestInvocation.cpp | 6 +++- > Tools/WebKitTestRunner/TestInvocation.h | 2 ++ > 8 files changed, 63 insertions(+), 1 deletion(-) > create mode 100644 LayoutTests/reftest-wait-expected-mismatch.html > create mode 100644 LayoutTests/reftest-wait.html > >diff --git a/LayoutTests/reftest-wait-expected-mismatch.html b/LayoutTests/reftest-wait-expected-mismatch.html >new file mode 100644 >index 00000000000..d3c8149089b >--- /dev/null >+++ b/LayoutTests/reftest-wait-expected-mismatch.html >@@ -0,0 +1,6 @@ >+<html> >+<style> >+:root {background-color:red} >+</style> >+<p>This test passes if the background becomes green after two seconds.</p> >+</html> >diff --git a/LayoutTests/reftest-wait.html b/LayoutTests/reftest-wait.html >new file mode 100644 >index 00000000000..080d7b306b1 >--- /dev/null >+++ b/LayoutTests/reftest-wait.html >@@ -0,0 +1,12 @@ >+<html class="reftest-wait"> >+<style> >+:root {background-color:red} >+</style> >+<script> >+window.setTimeout(function() { >+ document.documentElement.style.backgroundColor = "green"; >+ document.documentElement.className = ""; >+}, 2000); >+</script> >+<p>This test passes if the background becomes green after two seconds.</p> >+</html> >diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp >index da162cbd05e..ea2dacfe13d 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp >@@ -209,6 +209,9 @@ void InjectedBundle::didReceiveMessageToPage(WKBundlePageRef page, WKStringRef m > WKRetainPtr<WKStringRef> dumpJSConsoleLogInStdErrKey(AdoptWK, WKStringCreateWithUTF8CString("DumpJSConsoleLogInStdErr")); > m_dumpJSConsoleLogInStdErr = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, dumpJSConsoleLogInStdErrKey.get()))); > >+ WKRetainPtr<WKStringRef> checkReftestWaitKey(AdoptWK, WKStringCreateWithUTF8CString("CheckReftestWait")); >+ m_checkReftestWait = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, checkReftestWaitKey.get()))); >+ > WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithUTF8CString("Ack")); > WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithUTF8CString("BeginTest")); > WKBundlePagePostMessage(page, ackMessageName.get(), ackMessageBody.get()); >@@ -395,6 +398,30 @@ bool InjectedBundle::booleanForKey(WKDictionaryRef dictionary, const char* key) > return WKBooleanGetValue(static_cast<WKBooleanRef>(value)); > } > >+static const char* checkReftestWaitScript = >+ "(() => {" >+ " function checkReftestWait()" >+ " {" >+ " if (document.documentElement.className === 'reftest-wait')" >+ " testRunner.waitUntilDone();" >+ " else" >+ " testRunner.notifyDone();" >+ " };" >+ " function init() {" >+ " checkReftestWait();" >+ " (new MutationObserver((mutationsList) => {" >+ " for (var mutation of mutationsList) {" >+ " if (mutation.type == 'attributes' && mutation.attributeName == 'class')" >+ " checkReftestWait();" >+ " }" >+ " })).observe(document.documentElement, { attributes: true });" >+ " }" >+ " if (document.readyState === 'complete')" >+ " init();" >+ " else" >+ " window.addEventListener('load', init);" >+ "})();"; >+ > void InjectedBundle::beginTesting(WKDictionaryRef settings, BegingTestingMode testingMode) > { > m_state = Testing; >@@ -461,6 +488,9 @@ void InjectedBundle::beginTesting(WKDictionaryRef settings, BegingTestingMode te > // [WK2] REGRESSION(r128623): It made layout tests extremely slow > // https://bugs.webkit.org/show_bug.cgi?id=96862 > // WKBundleSetDatabaseQuota(m_bundle, 5 * 1024 * 1024); >+ >+ if (m_checkReftestWait) >+ queueNonLoadingScript(WTR::toWK(checkReftestWaitScript).get()); > } > > void InjectedBundle::done() >diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h >index 7307b6c9ecd..f32439622c9 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h >+++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h >@@ -193,6 +193,7 @@ private: > int m_timeout; > bool m_pixelResultIsPending { false }; > bool m_dumpJSConsoleLogInStdErr { false }; >+ bool m_checkReftestWait { false }; > > WKRetainPtr<WKDataRef> m_audioResult; > WKRetainPtr<WKImageRef> m_pixelResult; >diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp >index 2ac9ec60a75..91f79adb9bc 100644 >--- a/Tools/WebKitTestRunner/TestController.cpp >+++ b/Tools/WebKitTestRunner/TestController.cpp >@@ -1234,11 +1234,15 @@ TestCommand parseInputLine(const std::string& inputLine) > result.expectedPixelHash = tokenizer.next(); > } else if (arg == std::string("--dump-jsconsolelog-in-stderr")) > result.dumpJSConsoleLogInStdErr = true; >+ else if (arg == std::string("--check-reftest-wait")) >+ result.checkReftestWait = true; > else if (arg == std::string("--absolutePath")) > result.absolutePath = tokenizer.next(); > else > die(inputLine); > } >+ // TODO: Move that to webkitpy. >+ result.checkReftestWait = true; > return result; > } > >@@ -1261,6 +1265,8 @@ bool TestController::runTest(const char* inputLine) > if (command.timeout > 0) > m_currentInvocation->setCustomTimeout(command.timeout); > m_currentInvocation->setDumpJSConsoleLogInStdErr(command.dumpJSConsoleLogInStdErr || options.dumpJSConsoleLogInStdErr); >+ if (command.checkReftestWait) >+ m_currentInvocation->setCheckReftestWait(command.checkReftestWait); > > platformWillRunTest(*m_currentInvocation); > >diff --git a/Tools/WebKitTestRunner/TestController.h b/Tools/WebKitTestRunner/TestController.h >index bc10f6cbd0c..6b4ab9af0b6 100644 >--- a/Tools/WebKitTestRunner/TestController.h >+++ b/Tools/WebKitTestRunner/TestController.h >@@ -443,6 +443,7 @@ struct TestCommand { > std::string expectedPixelHash; > int timeout { 0 }; > bool dumpJSConsoleLogInStdErr { false }; >+ bool checkReftestWait { false }; > }; > > } // namespace WTR >diff --git a/Tools/WebKitTestRunner/TestInvocation.cpp b/Tools/WebKitTestRunner/TestInvocation.cpp >index 94c8a2d967e..8583909940a 100644 >--- a/Tools/WebKitTestRunner/TestInvocation.cpp >+++ b/Tools/WebKitTestRunner/TestInvocation.cpp >@@ -143,7 +143,11 @@ WKRetainPtr<WKMutableDictionaryRef> TestInvocation::createTestSettingsDictionary > WKRetainPtr<WKStringRef> dumpJSConsoleLogInStdErrKey = adoptWK(WKStringCreateWithUTF8CString("DumpJSConsoleLogInStdErr")); > WKRetainPtr<WKBooleanRef> dumpJSConsoleLogInStdErrValue = adoptWK(WKBooleanCreate(m_dumpJSConsoleLogInStdErr)); > WKDictionarySetItem(beginTestMessageBody.get(), dumpJSConsoleLogInStdErrKey.get(), dumpJSConsoleLogInStdErrValue.get()); >- >+ >+ WKRetainPtr<WKStringRef> checkReftestWaitKey = adoptWK(WKStringCreateWithUTF8CString("CheckReftestWait")); >+ WKRetainPtr<WKBooleanRef> checkReftestWaitValue = adoptWK(WKBooleanCreate(m_checkReftestWait)); >+ WKDictionarySetItem(beginTestMessageBody.get(), checkReftestWaitKey.get(), checkReftestWaitValue.get()); >+ > return beginTestMessageBody; > } > >diff --git a/Tools/WebKitTestRunner/TestInvocation.h b/Tools/WebKitTestRunner/TestInvocation.h >index 940b3249518..278b7215332 100644 >--- a/Tools/WebKitTestRunner/TestInvocation.h >+++ b/Tools/WebKitTestRunner/TestInvocation.h >@@ -53,6 +53,7 @@ public: > // Milliseconds > void setCustomTimeout(int duration) { m_timeout = duration; } > void setDumpJSConsoleLogInStdErr(bool value) { m_dumpJSConsoleLogInStdErr = value; } >+ void setCheckReftestWait(bool value) { m_checkReftestWait = value; } > > // Seconds > double shortTimeout() const; >@@ -111,6 +112,7 @@ private: > > int m_timeout { 0 }; > bool m_dumpJSConsoleLogInStdErr { false }; >+ bool m_checkReftestWait { false }; > > // Invocation state > bool m_startedTesting { false }; >-- >2.17.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186045
:
341479
|
341562
|
342053
|
342129
|
342130
|
342134
|
342135
|
342137
|
342140
|
342141
|
342142
|
342143
|
342144
|
342145
|
342146
|
342154
|
342158
|
342193
|
408200
|
408201
|
408361
|
408385