OLD | NEW |
1 if (window.GCController) | 1 if (window.GCController) |
2 GCController.collectAll(); | 2 GCController.collectAll(); |
3 | 3 |
4 var initialize_InspectorTest = function() { | 4 var initialize_InspectorTest = function() { |
5 Protocol.InspectorBackend.Options.suppressRequestErrors = true; | 5 Protocol.InspectorBackend.Options.suppressRequestErrors = true; |
6 var results = []; | 6 var results = []; |
7 | 7 |
8 function consoleOutputHook(messageType) | 8 function consoleOutputHook(messageType) |
9 { | 9 { |
10 InspectorTest.addResult(messageType + ": " + Array.prototype.slice.call(argu
ments, 1)); | 10 InspectorTest.addResult(messageType + ": " + Array.prototype.slice.call(argu
ments, 1)); |
(...skipping 26 matching lines...) Expand all Loading... |
37 { | 37 { |
38 InspectorTest.RuntimeAgent.evaluate("completeTest(\"" + escape(JSON.stringif
y(results)) + "\")", "test"); | 38 InspectorTest.RuntimeAgent.evaluate("completeTest(\"" + escape(JSON.stringif
y(results)) + "\")", "test"); |
39 } | 39 } |
40 | 40 |
41 InspectorTest.flushResults = function() | 41 InspectorTest.flushResults = function() |
42 { | 42 { |
43 InspectorTest.RuntimeAgent.evaluate("flushResults(\"" + escape(JSON.stringif
y(results)) + "\")", "test"); | 43 InspectorTest.RuntimeAgent.evaluate("flushResults(\"" + escape(JSON.stringif
y(results)) + "\")", "test"); |
44 results = []; | 44 results = []; |
45 } | 45 } |
46 | 46 |
47 InspectorTest.evaluateInPage = function(code, callback) | 47 InspectorTest.evaluateInPage = async function(code, callback) |
48 { | 48 { |
49 callback = InspectorTest.safeWrap(callback); | 49 var response = await InspectorTest.RuntimeAgent.invoke_evaluate({ |
50 | 50 expression: code, |
51 function mycallback(error, result, exceptionDetails) | 51 objectGroup: "console" |
52 { | 52 }); |
53 if (!error) | 53 if (!response[Protocol.Error]) |
54 callback(InspectorTest.runtimeModel.createRemoteObject(result), exce
ptionDetails); | 54 InspectorTest.safeWrap(callback)(InspectorTest.runtimeModel.createRemote
Object(response.result), response.exceptionDetails); |
55 } | |
56 InspectorTest.RuntimeAgent.evaluate(code, "console", false, mycallback); | |
57 } | 55 } |
58 | 56 |
59 InspectorTest.addScriptUISourceCode = function(url, content, isContentScript, wo
rldId) { | 57 InspectorTest.addScriptUISourceCode = function(url, content, isContentScript, wo
rldId) { |
60 content += '\n//# sourceURL=' + url; | 58 content += '\n//# sourceURL=' + url; |
61 if (isContentScript) | 59 if (isContentScript) |
62 content = `testRunner.evaluateScriptInIsolatedWorld(${worldId}, \`${cont
ent}\`)`; | 60 content = `testRunner.evaluateScriptInIsolatedWorld(${worldId}, \`${cont
ent}\`)`; |
63 InspectorTest.evaluateInPagePromise(content); | 61 InspectorTest.evaluateInPagePromise(content); |
64 return InspectorTest.waitForUISourceCode(url); | 62 return InspectorTest.waitForUISourceCode(url); |
65 } | 63 } |
66 | 64 |
67 InspectorTest.addScriptForFrame = function(url, content, frame) { | 65 InspectorTest.addScriptForFrame = function(url, content, frame) { |
68 content += '\n//# sourceURL=' + url; | 66 content += '\n//# sourceURL=' + url; |
69 var executionContext = InspectorTest.runtimeModel.executionContexts().find(c
ontext => context.frameId === frame.id); | 67 var executionContext = InspectorTest.runtimeModel.executionContexts().find(c
ontext => context.frameId === frame.id); |
70 InspectorTest.RuntimeAgent.evaluate(content, "console", false, false, execut
ionContext.id, function() { }); | 68 InspectorTest.RuntimeAgent.evaluate(content, "console", false, false, execut
ionContext.id); |
71 } | 69 } |
72 | 70 |
73 InspectorTest.evaluateInPagePromise = function(code) | 71 InspectorTest.evaluateInPagePromise = function(code) |
74 { | 72 { |
75 return new Promise(succ => InspectorTest.evaluateInPage(code, succ)); | 73 return new Promise(succ => InspectorTest.evaluateInPage(code, succ)); |
76 } | 74 } |
77 | 75 |
78 InspectorTest.evaluateInPageAsync = function(code) | 76 InspectorTest.evaluateInPageAsync = async function(code) |
79 { | 77 { |
80 var callback; | 78 var response = await InspectorTest.RuntimeAgent.invoke_evaluate({ |
81 var promise = new Promise((fulfill) => { callback = fulfill }); | 79 expression: code, |
82 InspectorTest.RuntimeAgent.evaluate(code, | 80 objectGroup: "console", |
83 "console", | 81 includeCommandLineAPI: false, |
84 /* includeCommandLineAPI */ false, | 82 silent: undefined, |
85 /* doNotPauseOnExceptionsAndMuteConsole */ undefined, | 83 contextId: undefined, |
86 /* contextId */ undefined, | 84 returnByValue: undefined, |
87 /* returnByValue */ undefined, | 85 generatePreview: undefined, |
88 /* generatePreview */ undefined, | 86 userGesture: undefined, |
89 /* userGesture */ undefined, | 87 awaitPromise: true |
90 /* awaitPromise */ true, | 88 }); |
91 mycallback); | |
92 | 89 |
93 function mycallback(error, result, exceptionDetails) | 90 var error = response[Protocol.Error]; |
94 { | 91 if (!error && !response.exceptionDetails) |
95 if (!error && !exceptionDetails) { | 92 return InspectorTest.runtimeModel.createRemoteObject(response.result); |
96 callback(InspectorTest.runtimeModel.createRemoteObject(result)); | 93 InspectorTest.addResult("Error: " + (error || response.exceptionDetails && r
esponse.exceptionDetails.text || "exception while evaluation in page.")); |
97 } else { | 94 InspectorTest.completeTest(); |
98 if (error) | |
99 InspectorTest.addResult("Error: " + error); | |
100 else | |
101 InspectorTest.addResult("Error: " + (exceptionDetails ? exceptio
nDetails.text : " exception while evaluation in page.")); | |
102 InspectorTest.completeTest(); | |
103 } | |
104 } | |
105 return promise; | |
106 } | 95 } |
107 | 96 |
108 InspectorTest.callFunctionInPageAsync = function(name, args) | 97 InspectorTest.callFunctionInPageAsync = function(name, args) |
109 { | 98 { |
110 args = args || []; | 99 args = args || []; |
111 return InspectorTest.evaluateInPageAsync(name + "(" + args.map(JSON.stringif
y).join(",") + ")"); | 100 return InspectorTest.evaluateInPageAsync(name + "(" + args.map(JSON.stringif
y).join(",") + ")"); |
112 } | 101 } |
113 | 102 |
114 InspectorTest.evaluateInPageWithTimeout = function(code) | 103 InspectorTest.evaluateInPageWithTimeout = function(code) |
115 { | 104 { |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 _output("[page] " + text); | 1293 _output("[page] " + text); |
1305 } | 1294 } |
1306 | 1295 |
1307 function _output(result) | 1296 function _output(result) |
1308 { | 1297 { |
1309 if (!outputElement) | 1298 if (!outputElement) |
1310 createOutputElement(); | 1299 createOutputElement(); |
1311 outputElement.appendChild(document.createTextNode(result)); | 1300 outputElement.appendChild(document.createTextNode(result)); |
1312 outputElement.appendChild(document.createElement("br")); | 1301 outputElement.appendChild(document.createElement("br")); |
1313 } | 1302 } |
OLD | NEW |