diff --git a/testing/web-platform/tests/reporting/bufferSize.html b/testing/web-platform/tests/reporting/bufferSize.html new file mode 100644 index 000000000000..b3512b3bc93b --- /dev/null +++ b/testing/web-platform/tests/reporting/bufferSize.html @@ -0,0 +1,29 @@ + + +Reporting: Buffer size + + + + + + diff --git a/testing/web-platform/tests/reporting/disconnect.html b/testing/web-platform/tests/reporting/disconnect.html new file mode 100644 index 000000000000..2dc5e8fd2de7 --- /dev/null +++ b/testing/web-platform/tests/reporting/disconnect.html @@ -0,0 +1,25 @@ + + +Reporting: Disconnect + + + + + + diff --git a/testing/web-platform/tests/reporting/generateTestReport.html b/testing/web-platform/tests/reporting/generateTestReport.html new file mode 100644 index 000000000000..e3c2735686a0 --- /dev/null +++ b/testing/web-platform/tests/reporting/generateTestReport.html @@ -0,0 +1,27 @@ + + +Reporting: Generate Test Report + + + + + + diff --git a/testing/web-platform/tests/reporting/nestedReport.html b/testing/web-platform/tests/reporting/nestedReport.html new file mode 100644 index 000000000000..156338ee7465 --- /dev/null +++ b/testing/web-platform/tests/reporting/nestedReport.html @@ -0,0 +1,30 @@ + + +Reporting: Nested report + + + + + + diff --git a/testing/web-platform/tests/reporting/order.html b/testing/web-platform/tests/reporting/order.html new file mode 100644 index 000000000000..c43964220c98 --- /dev/null +++ b/testing/web-platform/tests/reporting/order.html @@ -0,0 +1,32 @@ + + +Reporting: Order + + + + + +

No error

+ + + diff --git a/testing/web-platform/tests/resources/testdriver.js b/testing/web-platform/tests/resources/testdriver.js index e328302e4f34..031be1b7e550 100644 --- a/testing/web-platform/tests/resources/testdriver.js +++ b/testing/web-platform/tests/resources/testdriver.js @@ -194,6 +194,20 @@ */ action_sequence: function(actions) { return window.test_driver_internal.action_sequence(actions); + }, + + /** + * Generates a test report on the current page + * + * The generate_test_report function generates a report (to be observed + * by ReportingObserver) for testing purposes, as described in + * {@link https://w3c.github.io/reporting/#generate-test-report-command} + * + * @returns {Promise} fulfilled after the report is generated, or + * rejected if the report generation fails + */ + generate_test_report: function(message) { + return window.test_driver_internal.generate_test_report(message); } }; @@ -281,6 +295,17 @@ */ action_sequence: function(actions) { return Promise.reject(new Error("unimplemented")); + }, + + /** + * Generates a test report on the current page + * + * @param {String} message - the message to be contained in the report + * @returns {Promise} fulfilled after the report is generated, or + * rejected if the report generation fails + */ + generate_test_report: function(message) { + return Promise.reject(new Error("unimplemented")); } }; })(); diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py index 0e54eca778b3..41cf2c641d29 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py @@ -509,7 +509,8 @@ class CallbackHandler(object): self.actions = { "click": ClickAction(self.logger, self.protocol), "send_keys": SendKeysAction(self.logger, self.protocol), - "action_sequence": ActionSequenceAction(self.logger, self.protocol) + "action_sequence": ActionSequenceAction(self.logger, self.protocol), + "generate_test_report": GenerateTestReportAction(self.logger, self.protocol) } def __call__(self, result): @@ -593,3 +594,13 @@ class ActionSequenceAction(object): def get_element(self, selector): element = self.protocol.select.element_by_selector(selector) return element + +class GenerateTestReportAction(object): + def __init__(self, logger, protocol): + self.logger = logger + self.protocol = protocol + + def __call__(self, payload): + message = payload["message"] + self.logger.debug("Generating test report: %s" % message) + self.protocol.generate_test_report.generate_test_report(message) diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py index 3784163d7019..817b2717cb71 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py @@ -20,7 +20,8 @@ from .protocol import (BaseProtocolPart, ClickProtocolPart, SendKeysProtocolPart, ActionSequenceProtocolPart, - TestDriverProtocolPart) + TestDriverProtocolPart, + GenerateTestReportProtocolPart) from ..testrunner import Stop import webdriver as client @@ -188,6 +189,15 @@ class WebDriverTestDriverProtocolPart(TestDriverProtocolPart): self.webdriver.execute_script("window.postMessage(%s, '*')" % json.dumps(obj)) +class WebDriverGenerateTestReportProtocolPart(GenerateTestReportProtocolPart): + def setup(self): + self.webdriver = self.parent.webdriver + + def generate_test_report(self, message): + json_message = {"message": message} + self.webdriver.send_session_command("POST", "reporting/generate_test_report", json_message) + + class WebDriverProtocol(Protocol): implements = [WebDriverBaseProtocolPart, WebDriverTestharnessProtocolPart, @@ -195,7 +205,8 @@ class WebDriverProtocol(Protocol): WebDriverClickProtocolPart, WebDriverSendKeysProtocolPart, WebDriverActionSequenceProtocolPart, - WebDriverTestDriverProtocolPart] + WebDriverTestDriverProtocolPart, + WebDriverGenerateTestReportProtocolPart] def __init__(self, executor, browser, capabilities, **kwargs): super(WebDriverProtocol, self).__init__(executor, browser) diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/protocol.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/protocol.py index aa3565e5726a..d08b74bfc36a 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/protocol.py +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/protocol.py @@ -265,6 +265,7 @@ class ClickProtocolPart(ProtocolPart): :param element: A protocol-specific handle to an element.""" pass + class SendKeysProtocolPart(ProtocolPart): """Protocol part for performing trusted clicks""" __metaclass__ = ABCMeta @@ -280,6 +281,20 @@ class SendKeysProtocolPart(ProtocolPart): pass +class GenerateTestReportProtocolPart(ProtocolPart): + """Protocol part for generating test reports""" + __metaclass__ = ABCMeta + + name = "generate_test_report" + + @abstractmethod + def generate_test_report(self, message): + """Generate a test report. + + :param message: The message to be contained in the report.""" + pass + + class ActionSequenceProtocolPart(ProtocolPart): """Protocol part for performing trusted clicks""" __metaclass__ = ABCMeta diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/testdriver-extra.js b/testing/web-platform/tests/tools/wptrunner/wptrunner/testdriver-extra.js index 6336d227db8d..09d7c2908671 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/testdriver-extra.js +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/testdriver-extra.js @@ -90,4 +90,13 @@ window.__wptrunner_message_queue.push({"type": "action", "action": "action_sequence", "actions": actions}); return pending_promise; }; + + window.test_driver_internal.generate_test_report = function(message) { + const pending_promise = new Promise(function(resolve, reject) { + pending_resolve = resolve; + pending_reject = reject; + }); + window.__wptrunner_message_queue.push({"type": "action", "action": "generate_test_report", "message": message}); + return pending_promise; + }; })();