Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: third_party/WebKit/Source/devtools/front_end/integration_test_runner/IntegrationTestRunner.js

Issue 2975523002: DevTools: add console test helpers to new test runner & migrate a console test (Closed)
Patch Set: fix Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/integration_test_runner/IntegrationTestRunner.js
diff --git a/third_party/WebKit/Source/devtools/front_end/integration_test_runner/IntegrationTestRunner.js b/third_party/WebKit/Source/devtools/front_end/integration_test_runner/IntegrationTestRunner.js
index 8743227abb8ef443d54b94a0781d9b416178b1a8..9e26557cbdf347b5cd1fc3eef51977653fc88583 100644
--- a/third_party/WebKit/Source/devtools/front_end/integration_test_runner/IntegrationTestRunner.js
+++ b/third_party/WebKit/Source/devtools/front_end/integration_test_runner/IntegrationTestRunner.js
@@ -41,10 +41,12 @@ IntegrationTestRunner._setupTestHelpers = function(target) {
};
/**
- * @param {string} code
+ * @param {string|!Function} code
* @param {!Function} callback
*/
TestRunner.evaluateInPage = async function(code, callback) {
+ if (typeof code === 'function')
caseq 2017/07/12 01:04:33 Should we assert code.length === 0 in this case, s
chenwilliam 2017/07/12 22:02:58 Done.
+ code = `(${code.toString()})()`;
var response = await TestRunner.RuntimeAgent.invoke_evaluate({expression: code, objectGroup: 'console'});
if (!response[Protocol.Error]) {
TestRunner.safeWrap(callback)(
@@ -53,7 +55,7 @@ TestRunner.evaluateInPage = async function(code, callback) {
};
/**
- * @param {string} code
+ * @param {string|!Function} code
* @return {!Promise<!SDK.RemoteObject>}
*/
TestRunner.evaluateInPagePromise = function(code) {
@@ -69,6 +71,15 @@ TestRunner.deprecatedRunAfterPendingDispatches = function(callback) {
Promise.all(promises).then(TestRunner.safeWrap(callback));
};
+/**
+ * @param {string} html
+ * @return {!Promise<!SDK.RemoteObject>}
+ */
+TestRunner.loadHTML = function(html) {
+ html = html.replace(/'/g, '\\\'').replace(/\n/g, '\\n');
+ return TestRunner.evaluateInPagePromise(`document.write('${html}');document.close();`);
+};
+
/** @type {boolean} */
IntegrationTestRunner._startedTest = false;

Powered by Google App Engine
This is Rietveld 408576698