diff --git a/reporting/bufferSize.html b/reporting/bufferSize.html new file mode 100644 index 00000000000000..b3512b3bc93b32 --- /dev/null +++ b/reporting/bufferSize.html @@ -0,0 +1,29 @@ + + +Reporting: Buffer size + + + + + + diff --git a/reporting/disconnect.html b/reporting/disconnect.html new file mode 100644 index 00000000000000..2dc5e8fd2de724 --- /dev/null +++ b/reporting/disconnect.html @@ -0,0 +1,25 @@ + + +Reporting: Disconnect + + + + + + diff --git a/reporting/generateTestReport.html b/reporting/generateTestReport.html new file mode 100644 index 00000000000000..e3c2735686a05e --- /dev/null +++ b/reporting/generateTestReport.html @@ -0,0 +1,27 @@ + + +Reporting: Generate Test Report + + + + + + diff --git a/reporting/nestedReport.html b/reporting/nestedReport.html new file mode 100644 index 00000000000000..156338ee74653b --- /dev/null +++ b/reporting/nestedReport.html @@ -0,0 +1,30 @@ + + +Reporting: Nested report + + + + + + diff --git a/reporting/order.html b/reporting/order.html new file mode 100644 index 00000000000000..c43964220c981f --- /dev/null +++ b/reporting/order.html @@ -0,0 +1,32 @@ + + +Reporting: Order + + + + + +

No error

+ + + diff --git a/resources/testdriver.js b/resources/testdriver.js index e328302e4f3451..031be1b7e55016 100644 --- a/resources/testdriver.js +++ b/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/tools/wptrunner/wptrunner/executors/base.py b/tools/wptrunner/wptrunner/executors/base.py index 0e54eca778b3d6..41cf2c641d291b 100644 --- a/tools/wptrunner/wptrunner/executors/base.py +++ b/tools/wptrunner/wptrunner/executors/base.py @@ -509,7 +509,8 @@ def __init__(self, logger, protocol, test_window): 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 @@ def __call__(self, payload): 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/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/tools/wptrunner/wptrunner/executors/executorwebdriver.py index 3f8c2bb5a3f94a..f18e8c86e2c157 100644 --- a/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/tools/wptrunner/wptrunner/executors/executorwebdriver.py @@ -20,7 +20,8 @@ ClickProtocolPart, SendKeysProtocolPart, ActionSequenceProtocolPart, - TestDriverProtocolPart) + TestDriverProtocolPart, + GenerateTestReportProtocolPart) from ..testrunner import Stop import webdriver as client @@ -188,6 +189,15 @@ def send_message(self, message_type, status, message=None): 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/tools/wptrunner/wptrunner/executors/protocol.py b/tools/wptrunner/wptrunner/executors/protocol.py index aa3565e5726a06..d08b74bfc36ae9 100644 --- a/tools/wptrunner/wptrunner/executors/protocol.py +++ b/tools/wptrunner/wptrunner/executors/protocol.py @@ -265,6 +265,7 @@ def element(self, element): :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 @@ def send_keys(self, element, keys): 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/tools/wptrunner/wptrunner/testdriver-extra.js b/tools/wptrunner/wptrunner/testdriver-extra.js index 6336d227db8d7d..09d7c290867122 100644 --- a/tools/wptrunner/wptrunner/testdriver-extra.js +++ b/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; + }; })();