UIScriptController: script with no async tasks fails if an earlier script registered...
[WebKit-https.git] / LayoutTests / fast / harness / ui-side-script-with-callback.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5     <script src="../../resources/js-test-pre.js"></script>
6     <script>
7         
8         var jsTestIsAsync = true;
9         
10         function getAsyncTaskScript()
11         {
12             return `(function() {
13                 uiController.willBeginZoomingCallback = function() {};
14
15                 uiController.doAsyncTask(function() {
16                     uiController.uiScriptComplete('async task complete');
17                 });
18             })();`;
19         }
20
21         function getImmediateScript()
22         {
23             return `(function() {
24                 return 'immediate script complete';
25             })();`;
26         }
27     
28         var scriptResult;
29         function runTest()
30         {
31             description('Test that a second immediate UI script returns if an earlier script registered a callback');
32
33             if (!window.testRunner) {
34                 debug('This test requires testRunner');
35                 return;
36             }
37
38             if (!testRunner.runUIScript) {
39                 debug('This test requires runUIScript');
40                 return;
41             }
42
43             testRunner.runUIScript(getAsyncTaskScript(), function(result) {
44                 scriptResult = result;
45                 shouldBeEqualToString('scriptResult', 'async task complete');
46
47                 testRunner.runUIScript(getImmediateScript(), function(result) {
48                     scriptResult = result;
49                     shouldBeEqualToString('scriptResult', 'immediate script complete');
50                     finishJSTest();
51                 });
52             });
53         }
54         window.addEventListener('load', runTest, false);
55     </script>
56 </head>
57 <body>
58
59 <pre id="results"></pre>
60 <script src="../../resources/js-test-post.js"></script>
61 </body>
62 </html>