browserHelpers.js (850B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 6 // testSteps is expected to be defined by the file including this file. 7 /* global testSteps */ 8 9 var testGenerator = testSteps(); 10 11 var testResult; 12 13 function runTest() { 14 testGenerator.next(); 15 } 16 17 function finishTestNow() { 18 if (testGenerator) { 19 testGenerator.return(); 20 testGenerator = undefined; 21 } 22 } 23 24 function finishTest() { 25 setTimeout(finishTestNow, 0); 26 setTimeout(() => { 27 window.parent.postMessage(testResult, "*"); 28 }, 0); 29 } 30 31 function grabEventAndContinueHandler(event) { 32 testGenerator.next(event); 33 } 34 35 function errorHandler(event) { 36 throw new Error("indexedDB error, code " + event.target.error.name); 37 } 38 39 function continueToNextStep() { 40 SimpleTest.executeSoon(function () { 41 testGenerator.next(); 42 }); 43 }