| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright (C) 2012 Samsung Electronics. All rights reserved. | 2 Copyright (C) 2012 Samsung Electronics. All rights reserved. |
| 3 | 3 |
| 4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
| 5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
| 6 are met: | 6 are met: |
| 7 | 7 |
| 8 1. Redistributions of source code must retain the above copyright | 8 1. Redistributions of source code must retain the above copyright |
| 9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
| 10 2. Redistributions in binary form must reproduce the above copyright | 10 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 InspectorTest.evaluateInPage = function(string, callback) | 276 InspectorTest.evaluateInPage = function(string, callback) |
| 277 { | 277 { |
| 278 this.sendCommand("Runtime.evaluate", { "expression": string }, function(mess
age) { | 278 this.sendCommand("Runtime.evaluate", { "expression": string }, function(mess
age) { |
| 279 if (message.error) | 279 if (message.error) |
| 280 InspectorTest.log("Error while executing '" + string + "': " + messa
ge.error.message); | 280 InspectorTest.log("Error while executing '" + string + "': " + messa
ge.error.message); |
| 281 else if (callback) | 281 else if (callback) |
| 282 callback(message.result.result.value); | 282 callback(message.result.result.value); |
| 283 }); | 283 }); |
| 284 }; | 284 }; |
| 285 | 285 |
| 286 InspectorTest._asyncCallbacks = {}; | 286 InspectorTest.evaluateInPageAsync = function(expression) |
| 287 InspectorTest._asyncCallbackId = 0; | |
| 288 | |
| 289 InspectorTest.evaluateInPageAsync = function(string, callback) | |
| 290 { | 287 { |
| 291 var id = ++InspectorTest._asyncCallbackId; | 288 return InspectorTest.sendCommandPromise("Runtime.evaluate", { "expression":
expression, awaitPromise: true }).then((message) => message.result.result.value)
; |
| 292 InspectorTest._asyncCallbacks[id] = callback; | |
| 293 var callbackString = "testRunner.evaluateInWebInspector.bind(testRunner, 42,
\"InspectorTest._evaluateInPageAsyncCompleted(" + id + ")\")"; | |
| 294 var code = string.replace("%callback", callbackString); | |
| 295 InspectorTest.evaluateInPage(code); | |
| 296 }; | |
| 297 | |
| 298 InspectorTest._evaluateInPageAsyncCompleted = function(id) | |
| 299 { | |
| 300 var callback = InspectorTest._asyncCallbacks[id]; | |
| 301 delete InspectorTest._asyncCallbacks[id]; | |
| 302 if (!callback) { | |
| 303 InspectorTest.log("Error: no callback for async function"); | |
| 304 InspectorTest.completeTest(); | |
| 305 return; | |
| 306 } | |
| 307 callback(); | |
| 308 } | 289 } |
| 309 | 290 |
| 310 InspectorTest.completeTestIfError = function(messageObject) | 291 InspectorTest.completeTestIfError = function(messageObject) |
| 311 { | 292 { |
| 312 if (messageObject.error) { | 293 if (messageObject.error) { |
| 313 InspectorTest.log(messageObject.error.message); | 294 InspectorTest.log(messageObject.error.message); |
| 314 InspectorTest.completeTest(); | 295 InspectorTest.completeTest(); |
| 315 return true; | 296 return true; |
| 316 } | 297 } |
| 317 return false; | 298 return false; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 var callback = didResolve ? callbacks.resolve : callbacks.reject; | 411 var callback = didResolve ? callbacks.resolve : callbacks.reject; |
| 431 delete pendingPromiseEvalRequests[callId]; | 412 delete pendingPromiseEvalRequests[callId]; |
| 432 callback(value); | 413 callback(value); |
| 433 } | 414 } |
| 434 | 415 |
| 435 window.addEventListener("load", InspectorTest.readyForTest.bind(InspectorTest),
false); | 416 window.addEventListener("load", InspectorTest.readyForTest.bind(InspectorTest),
false); |
| 436 | 417 |
| 437 </script> | 418 </script> |
| 438 </head> | 419 </head> |
| 439 </html> | 420 </html> |
| OLD | NEW |