Changes between Version 2 and Version 3 of Writing Layout Tests to test iOS UI features
- Timestamp:
- Sep 30, 2015 3:13:58 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Writing Layout Tests to test iOS UI features
v2 v3 24 24 }}} 25 25 26 Now we want to write some script to read the zoom scale in the UI process. TestRunnernow has a runUIScript() function, which takes a string and a callback:26 Now we want to write some script to read the zoom scale in the UI process. [https://trac.webkit.org/browser/trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl TestRunner] now has a runUIScript() function, which takes a string and a callback: 27 27 {{{ 28 28 interface TestRunner { … … 34 34 so we can use this in our test in some script that would run from the onload handler: 35 35 {{{ 36 37 38 39 40 41 document.getElementById('target').innerText = result;42 43 44 45 36 function runTest() 37 { 38 testRunner.waitUntilDone(); 39 if (testRunner.runUIScript) { 40 testRunner.runUIScript("...", function(result) { 41 document.getElementById('result').innerText = result; 42 testRunner.notifyDone(); 43 }); 44 } 45 } 46 46 }}} 47 48 The script passed in to runUIScript() is just a string. You can pass a string literal here, or, for longer scripts make script tag: 49 {{{ 50 <script id="ui-script" type="text/plain"> 51 ... 52 </script> 53 54 <script> 55 function getUIScript() 56 { 57 return document.getElementById('ui-script').text; 58 } 59 60 testRunner.runUIScript(getUIScript(), function(result) { 61 ... 62 }); 63 }}}