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

Unified Diff: chrome/test/data/android/webvr_instrumentation/resources/webvr_e2e.js

Issue 2883273006: Better generalize VR test framework (Closed)
Patch Set: Address nits Created 3 years, 7 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
« no previous file with comments | « chrome/test/data/android/webvr_instrumentation/resources/webvr_boilerplate.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..abf05cb4af39fe5c6adcaacb8e332950c100b672 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};
function finishJavaScriptStep() {
javascriptDone = true;
}
+// Used to check when JavaScript is in an acceptable state to start testing
+// after a page load, as Chrome thinking that the page has finished loading
+// 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();
+ });
+}
« no previous file with comments | « chrome/test/data/android/webvr_instrumentation/resources/webvr_boilerplate.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698