 Chromium Code Reviews
 Chromium Code Reviews Issue 2833313003:
  Pass clickEvent to controlElement inside label if targetNode can't start selection   (Closed)
    
  
    Issue 2833313003:
  Pass clickEvent to controlElement inside label if targetNode can't start selection   (Closed) 
  | Index: third_party/WebKit/LayoutTests/fast/forms/label/label-selection-by-textSelection-and-click.html | 
| diff --git a/third_party/WebKit/LayoutTests/fast/forms/label/label-selection-by-textSelection-and-click.html b/third_party/WebKit/LayoutTests/fast/forms/label/label-selection-by-textSelection-and-click.html | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..d7b81eb63c6cd32c20b6c9166ed20889f0d0f2eb | 
| --- /dev/null | 
| +++ b/third_party/WebKit/LayoutTests/fast/forms/label/label-selection-by-textSelection-and-click.html | 
| @@ -0,0 +1,52 @@ | 
| +<!DOCTYPE html> | 
| +<script src='../../../resources/testharness.js'></script> | 
| +<script src='../../../resources/testharnessreport.js'></script> | 
| +<p>Selected Text</p> | 
| +<label> | 
| +<img src="../resources/green.jpg" width=100 height=100> | 
| +<br><input type=radio> Then click the image | 
| +</label> | 
| +<script> | 
| + | 
| +var text = document.querySelector("p"); | 
| +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.
 | 
| +var radio = label.querySelector("input[type=radio]"); | 
| +var image = label.querySelector("img"); | 
| +var targetTextRect = text.getBoundingClientRect(); | 
| 
tkent
2017/05/11 06:35:09
nit:
var targetTextRect = document.querySelector(
 
tanvir
2017/05/11 11:47:52
Done.
 | 
| +var textLeft = targetTextRect.left; | 
| +var textTop = targetTextRect.top; | 
| +var textWidth = targetTextRect.width; | 
| +var targetImageRect = image.getBoundingClientRect(); | 
| 
tkent
2017/05/11 06:35:09
nit:
var targetImageRect = document.querySelector(
 
tanvir
2017/05/11 11:47:52
Done.
 | 
| +var imageLeft = targetImageRect.left; | 
| +var imageTop = targetImageRect.top; | 
| + | 
| +function callbackValidMoveCount() { | 
| + testTouchMove.step(function() { | 
| + assert_equals(window.getSelection().toString(), "Selected Text"); | 
| + assert_true(radio.checked); | 
| + }); | 
| + testTouchMove.done(); | 
| +} | 
| + | 
| +function testLabelClickOnSelectedText() { | 
| + 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.
 | 
| + var pointerActions = | 
| + [{ source: "mouse", | 
| + actions: [ | 
| + { name: "pointerDown", x: textLeft, y: textTop }, | 
| + { name: "pointerMove", x: textLeft + textWidth, y: textTop }, | 
| + { name: "pointerUp" }, | 
| + { name:"pause"}, | 
| + { name: "pointerDown", x: imageLeft, y: imageTop}, | 
| + { name: "pointerUp" }]}]; | 
| + chrome.gpuBenchmarking.pointerActionSequence(pointerActions, callbackValidMoveCount); | 
| + } | 
| +} | 
| + | 
| +var testTouchMove = async_test("Tests that Radio Input gets checked if label clicked along with a text selection."); | 
| +// This test runs as follows. | 
| +// 1. Select the text. | 
| +// 2. Then click on label element image. | 
| +// 3. Radio button should be checked. | 
| +testLabelClickOnSelectedText(); | 
| +</script> |