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..a2bc34cd5acbd4706319e77e10f581258759fb73 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,17 @@ IntegrationTestRunner._setupTestHelpers = function(target) { |
}; |
/** |
- * @param {string} code |
+ * @param {string|!Function} code |
* @param {!Function} callback |
*/ |
TestRunner.evaluateInPage = async function(code, callback) { |
+ if (typeof code === 'function') { |
+ if (code.length) { |
+ TestRunner.addResult('ERROR: do not use evaluateInPage on a function with parameters: ' + code.toString()); |
+ TestRunner.addResult('TestRunner.evaluateInPage invokes the function without arguments'); |
+ } |
+ code = `(${code.toString()})()`; |
+ } |
var response = await TestRunner.RuntimeAgent.invoke_evaluate({expression: code, objectGroup: 'console'}); |
if (!response[Protocol.Error]) { |
TestRunner.safeWrap(callback)( |
@@ -53,7 +60,7 @@ TestRunner.evaluateInPage = async function(code, callback) { |
}; |
/** |
- * @param {string} code |
+ * @param {string|!Function} code |
* @return {!Promise<!SDK.RemoteObject>} |
*/ |
TestRunner.evaluateInPagePromise = function(code) { |
@@ -69,6 +76,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; |