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

Side by Side Diff: third_party/WebKit/LayoutTests/editing/selection/script-tests/user-select-js-property.html

Issue 2246293003: Unprefix CSS user-select property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script> 2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script> 3 <script src="../../../resources/testharnessreport.js"></script>
4 <style>
5 #foo {
6 user-select: none;
7 }
8 #bar {
9 -webkit-user-select: none;
10 }
11 </style>
4 <div id="container"> 12 <div id="container">
5 <p id="description">Test setting CSSStyleDeclaration.webkitUserStyle</p> 13 <p id="description">Test setting CSSStyleDeclaration.webkitUserStyle and userSty le</p>
6 <div id="sample1" contenteditable="true">editable</div> 14 <div id="sample1" contenteditable="true">editable</div>
7 <div id="sample2" contenteditable="false">uneditable</div> 15 <div id="sample2" contenteditable="false">uneditable</div>
16 <div class="none" style="user-select:none"></div>
17 <div class="none" style="-webkit-user-select:none"></div>
8 </div> 18 </div>
9 <div id="log"></div> 19 <div id="log"></div>
10 <script> 20 <script>
11 var selection = window.getSelection(); 21 var selection = window.getSelection();
12 function setSelection(node) 22 function setSelection(node)
13 { 23 {
14 var range = document.createRange(); 24 var range = document.createRange();
15 range.selectNodeContents(node); 25 range.selectNodeContents(node);
16 selection.empty(); 26 selection.empty();
17 selection.addRange(range); 27 selection.addRange(range);
18 } 28 }
19 29
20 test(function(){ 30 test(function(){
21 // user-select:none in editable element 31 // user-select:none in editable element
22 sample1.style.webkitUserSelect = 'none'; 32 sample1.style.webkitUserSelect = "none";
23 setSelection(sample1); 33 setSelection(sample1);
24 assert_equals(selection.type, 'Range'); 34 assert_equals(selection.type, "Range");
25 35
26 // user-select:none in uneditable element 36 // user-select:none in uneditable element
27 sample2.style.webkitUserSelect = 'none'; 37 sample2.style.webkitUserSelect = "none";
28 setSelection(sample2); 38 setSelection(sample2);
29 assert_equals(selection.type, 'None'); 39 assert_equals(selection.type, "None");
30 }); 40 });
41
42 var style = document.createElement("baz").style;
43 test(function () {
44 assert_true("userSelect" in style);
45 }, "'userSelect' in style");
46 test(function () {
47 assert_true("webkitUserSelect" in style);
48 }, "'webkitUserSelect' in style");
49
50 Array.prototype.forEach.call(document.styleSheets[0].cssRules, function (cssRule ) {
51 testUserSelect(cssRule.style, cssRule.cssText);
52 });
53
54 Array.prototype.forEach.call(document.querySelectorAll(".none"), function (eleme nt) {
55 testUserSelect(getComputedStyle(element), element.getAttribute("style"));
56 });
57
58 function testUserSelect(style, title) {
59 test(function () {
60 assert_equals(style.userSelect, "none");
61 }, "userSelect of '" + title + "' should be 'none'");
62 test(function () {
63 assert_equals(style.webkitUserSelect, "none");
64 }, "webkitUserSelect of '" + title + "' should be 'none'");
65 }
31 </script> 66 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698