OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src='../../../resources/testharness.js'></script> |
| 3 <script src='../../../resources/testharnessreport.js'></script> |
| 4 <p>Selected Text</p> |
| 5 <label> |
| 6 <img src="../resources/green.jpg" width=100 height=100> |
| 7 <br><input type=radio> Then click the image |
| 8 </label> |
| 9 <script> |
| 10 var radio = document.querySelector("input[type=radio]"); |
| 11 var targetTextRect = document.querySelector("p").getBoundingClientRect(); |
| 12 var textLeft = targetTextRect.left; |
| 13 var textTop = targetTextRect.top; |
| 14 var textWidth = targetTextRect.width; |
| 15 var targetImageRect = document.querySelector("img").getBoundingClientRect(); |
| 16 var imageLeft = targetImageRect.left; |
| 17 var imageTop = targetImageRect.top; |
| 18 |
| 19 var testLabelClickWithSelectedText = async_test("Tests that Radio Input gets che
cked if label clicked along with a text selection."); |
| 20 |
| 21 // This test runs as follows: |
| 22 // 1. Select the text. |
| 23 // 2. Then click on label element image. |
| 24 // 3. Radio button should be checked. |
| 25 |
| 26 testLabelClickWithSelectedText.step(() => { |
| 27 assert_exists(window, "chrome"); |
| 28 assert_exists(chrome, "gpuBenchmarking"); |
| 29 |
| 30 var pointerActions = |
| 31 [{ source: "mouse", |
| 32 actions: [ |
| 33 { name: "pointerDown", x: textLeft, y: textTop }, |
| 34 { name: "pointerMove", x: textLeft + textWidth, y: textTop }, |
| 35 { name: "pointerUp" }, |
| 36 { name: "pause" }, |
| 37 { name: "pointerDown", x: imageLeft, y: imageTop }, |
| 38 { name: "pointerUp" }]}]; |
| 39 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, testLabelClickWit
hSelectedText.step_func_done(() => { |
| 40 assert_equals(window.getSelection().toString(), "Selected Text"); |
| 41 assert_true(radio.checked); |
| 42 })); |
| 43 }); |
| 44 </script> |
OLD | NEW |