Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: third_party/WebKit/LayoutTests/fast/forms/label/label-selection-by-textSelection-and-click.html

Issue 2833313003: Pass clickEvent to controlElement inside label if targetNode can't start selection (Closed)
Patch Set: Review Comments updated Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8a79c90dad7e33a72c179ced95691900c259b5c1
--- /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 name=a> Then click the image
+</label>
+<script>
+
+var text = document.querySelector("p");
+var label = document.querySelector("label");
+var radio = label.querySelector("input[name=a]");
yosin_UTC9 2017/05/08 03:25:56 nit: better to use 'input[type=radio]'. In this wa
tanvir 2017/05/08 14:02:52 Done.
+var image = label.querySelector("img");
+var targetTextRect = text.getBoundingClientRect();
+var textLeft = targetTextRect.left;
+var textTop = targetTextRect.top;
+var textWidth = targetTextRect.width;
+var targetImageRect = image.getBoundingClientRect();
+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) {
+ var pointerActions =
+ [{ source: "mouse",
+ actions: [
+ { name: "pointerDown", x: textLeft, y: textTop },
+ { name: "pointerMove", x: textLeft+textWidth, y: textTop },
yosin_UTC9 2017/05/08 03:25:56 nit: s/+/ + /
tanvir 2017/05/08 14:02:52 Done.
+ { 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.');
yosin_UTC9 2017/05/08 03:25:56 nit: Could you use double-quote here? Since, other
tanvir 2017/05/08 14:02:51 Done.
+// This test runs as follows.
+// 1. Select the text.
+// 2. Then click on label element image.
+// 3. Radio button should be checked.
+testLabelClickOnSelectedText();
+</script>

Powered by Google App Engine
This is Rietveld 408576698