Chromium Code Reviews| 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 | |
| 11 var text = document.querySelector("p"); | |
| 12 var label = document.querySelector("label"); | |
|
tkent
2017/05/11 06:35:10
nit:
The following two |label.querySelector()| can
tanvir
2017/05/11 11:47:52
Done.
| |
| 13 var radio = label.querySelector("input[type=radio]"); | |
| 14 var image = label.querySelector("img"); | |
| 15 var targetTextRect = text.getBoundingClientRect(); | |
|
tkent
2017/05/11 06:35:09
nit:
var targetTextRect = document.querySelector(
tanvir
2017/05/11 11:47:52
Done.
| |
| 16 var textLeft = targetTextRect.left; | |
| 17 var textTop = targetTextRect.top; | |
| 18 var textWidth = targetTextRect.width; | |
| 19 var targetImageRect = image.getBoundingClientRect(); | |
|
tkent
2017/05/11 06:35:09
nit:
var targetImageRect = document.querySelector(
tanvir
2017/05/11 11:47:52
Done.
| |
| 20 var imageLeft = targetImageRect.left; | |
| 21 var imageTop = targetImageRect.top; | |
| 22 | |
| 23 function callbackValidMoveCount() { | |
| 24 testTouchMove.step(function() { | |
| 25 assert_equals(window.getSelection().toString(), "Selected Text"); | |
| 26 assert_true(radio.checked); | |
| 27 }); | |
| 28 testTouchMove.done(); | |
| 29 } | |
| 30 | |
| 31 function testLabelClickOnSelectedText() { | |
| 32 if (window.chrome && chrome.gpuBenchmarking) { | |
|
tkent
2017/05/11 06:35:09
This test should fail explicitly if there are no w
tanvir
2017/05/11 11:47:52
Done.
| |
| 33 var pointerActions = | |
| 34 [{ source: "mouse", | |
| 35 actions: [ | |
| 36 { name: "pointerDown", x: textLeft, y: textTop }, | |
| 37 { name: "pointerMove", x: textLeft + textWidth, y: textTop }, | |
| 38 { name: "pointerUp" }, | |
| 39 { name:"pause"}, | |
| 40 { name: "pointerDown", x: imageLeft, y: imageTop}, | |
| 41 { name: "pointerUp" }]}]; | |
| 42 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, callbackVal idMoveCount); | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 var testTouchMove = async_test("Tests that Radio Input gets checked if label cli cked along with a text selection."); | |
| 47 // This test runs as follows. | |
| 48 // 1. Select the text. | |
| 49 // 2. Then click on label element image. | |
| 50 // 3. Radio button should be checked. | |
| 51 testLabelClickOnSelectedText(); | |
| 52 </script> | |
| OLD | NEW |