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..0ba4af03d623b7f7adb13f4dafa402c2c83c5e7a |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/forms/label/label-selection-by-textSelection-and-click.html |
@@ -0,0 +1,51 @@ |
+<!DOCTYPE html> |
+<script src='../../../resources/testharness.js'></script> |
+<script src='../../../resources/testharnessreport.js'></script> |
+<p id="textId">Selected Text</p> |
Srirama
2017/04/28 12:56:45
you can remove id here and below and directly use
tanvir
2017/05/02 10:02:51
Done.
|
+<label id="labelId"> |
+<img id="imageId" src="../resources/green.jpg" width=100 height=100> |
+<br><input type=radio name=a id="radioId"> Then click the image |
+</label> |
+<script type="text/javascript"> |
Srirama
2017/04/28 12:56:45
remove type
tanvir
2017/05/02 10:02:51
Done.
|
+ |
+var radioID = document.getElementById("radioId"); |
Srirama
2017/04/28 12:56:45
may be just use radio instead of radioID
|
+var textID = document.getElementById("textId"); |
Srirama
2017/04/28 12:56:45
s/textID/text
|
+var targetTextRect = textID.getBoundingClientRect(); |
+var textLeft = targetTextRect.left; |
+var textTop = targetTextRect.top; |
+var textWidth = targetTextRect.width; |
+var imageID = document.getElementById("imageId"); |
+var targetImageRect = imageID.getBoundingClientRect(); |
+var imageLeft = targetImageRect.left; |
+var imageTop = targetImageRect.top; |
+ |
+function callbackValidMoveCount() { |
+ testTouchMove.step(function () { |
Srirama
2017/04/28 12:56:45
nit:remove space before ()
tanvir
2017/05/02 10:02:50
Done.
|
+ assert_equals(window.getSelection().toString(), "Selected Text"); |
+ assert_equals(radioID.checked, true); |
Srirama
2017/04/28 12:56:45
use assert_true
tanvir
2017/05/02 10:02:51
Done.
|
+ }); |
+ testTouchMove.done(); |
+} |
+ |
+function testLabelClickOnSelectedText() { |
+ if (window.chrome && chrome.gpuBenchmarking) { |
+ var pointerActions = |
+ [{source: "mouse", |
Srirama
2017/04/28 12:56:45
nit:space before "source"
tanvir
2017/05/02 10:02:50
Done.
|
+ 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 get checked if label clicked along with a text selection.'); |
Srirama
2017/04/28 12:56:45
s/get/gets
tanvir
2017/05/02 10:02:50
Done.
|
+// This test run as follows. |
Srirama
2017/04/28 12:56:45
s/run/runs
tanvir
2017/05/02 10:02:51
Done.
|
+// 1. Select the text. |
+// 2. Then click on label element image. |
+// 3. Radio button should be checked. |
+testLabelClickOnSelectedText(); |
+</script> |