Chromium Code Reviews| Index: chrome/test/data/android/webvr_instrumentation/resources/webvr_e2e.js |
| diff --git a/chrome/test/data/android/webvr_instrumentation/resources/webvr_e2e.js b/chrome/test/data/android/webvr_instrumentation/resources/webvr_e2e.js |
| index 03f006cb53132eeb496354a78c88589773bbcf45..cf8d38c3b373c9d9407f748cdda7a5541bad119f 100644 |
| --- a/chrome/test/data/android/webvr_instrumentation/resources/webvr_e2e.js |
| +++ b/chrome/test/data/android/webvr_instrumentation/resources/webvr_e2e.js |
| @@ -4,14 +4,28 @@ |
| var testPassed = false; |
| var resultString = ""; |
| -var asyncCounter = 0; |
| var javascriptDone = false; |
| -var vrDisplayPromiseDone = false; |
| +var initializationSteps = {"load": false}; |
|
mthiesse
2017/05/30 15:30:46
nit: Unnecessary quotes around 'load'.
bsheedy
2017/05/30 18:15:36
Done.
|
| function finishJavaScriptStep() { |
| javascriptDone = true; |
| } |
| +// Used to check when JavaScript is in an acceptable state to start testing |
| +// after a page load, as Chromium thinking that the page has finished loading |
|
tiborg
2017/05/30 14:41:23
Nit: I think we use the name Chrome to refer to th
bsheedy
2017/05/30 18:15:36
Done.
|
| +// is not always sufficient. By default waits until the load event is fired. |
| +function isInitializationComplete() { |
| + for (var step in initializationSteps) { |
| + if (!initializationSteps[step]) { |
| + return false; |
| + } |
| + } |
| + return true; |
| +} |
| + |
| +window.addEventListener("load", |
| + () => {initializationSteps["load"] = true;}, false); |
| + |
| function checkResultsForFailures(tests, harness_status) { |
| testPassed = true; |
| if (harness_status["status"] != 0) { |
| @@ -34,9 +48,13 @@ function checkResultsForFailures(tests, harness_status) { |
| } |
| } |
| -add_completion_callback( (tests, harness_status) => { |
| - checkResultsForFailures(tests, harness_status); |
| - console.debug("Test result: " + (testPassed ? "Pass" : "Fail")); |
| - console.debug("Test result string: " + resultString); |
| - finishJavaScriptStep(); |
| -}); |
| +// Only interact with testharness.js if it was actually included on the page |
| +// before this file |
| +if (typeof add_completion_callback !== "undefined") { |
| + add_completion_callback( (tests, harness_status) => { |
| + checkResultsForFailures(tests, harness_status); |
| + console.debug("Test result: " + (testPassed ? "Pass" : "Fail")); |
| + console.debug("Test result string: " + resultString); |
| + finishJavaScriptStep(); |
| + }); |
| +} |