Changes between Version 2 and Version 3 of Writing Layout Tests to test iOS UI features


Ignore:
Timestamp:
Sep 30, 2015 3:13:58 PM (7 years ago)
Author:
Simon Fraser
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Writing Layout Tests to test iOS UI features

    v2 v3  
    2424}}}
    2525
    26 Now we want to write some script to read the zoom scale in the UI process. TestRunner now has a runUIScript() function, which takes a string and a callback:
     26Now 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:
    2727{{{
    2828interface TestRunner {
     
    3434so we can use this in our test in some script that would run from the onload handler:
    3535{{{
    36         function runTest()
    37         {
    38             testRunner.waitUntilDone();
    39             if (testRunner.runUIScript) {
    40                 testRunner.runUIScript("...", function(result) {
    41                     document.getElementById('target').innerText = result;
    42                     testRunner.notifyDone();
    43                 });
    44             }
    45         }
     36function 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}
    4646}}}
     47
     48The 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}}}