Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / text / find-spaces.html
blob6a5ed4b369c08fb7db037ec957044988b6d43df2
1 <html>
2 <head>
3 <script>
4 function canFind(target, specimen)
6 getSelection().empty();
7 document.body.innerHTML = specimen;
8 document.execCommand("FindString", false, target);
9 var result = getSelection().rangeCount != 0;
10 getSelection().empty();
11 return result;
14 function runTests()
16 if (window.testRunner)
17 testRunner.dumpAsText();
19 var success = true;
21 var nbsp = String.fromCharCode(0xA0);
23 var message = "FAILURE:";
25 if (canFind("", "a b")) {
26 success = false;
27 message += " Was able to find the empty string.";
30 if (!canFind(" ", "a b")) {
31 success = false;
32 message += " Cannot find space.";
35 if (canFind(" ", "a b")) {
36 success = false;
37 message += " Two spaces are matching even though they should be collapsed.";
40 if (!canFind(" ", "<pre>a b</pre>")) {
41 success = false;
42 message += " Cannot find two spaces in a &lt;pre&gt; element.";
45 if (!canFind(" ", "a&nbsp;b")) {
46 success = false;
47 message += " Cannot find an &amp;nbsp; when searching for a space.";
50 if (!canFind(" ", "a &nbsp;b")) {
51 success = false;
52 message += " Cannot find a space followed by &amp;nbsp; when searching for two spaces.";
55 if (!canFind(" ", "a&nbsp; b")) {
56 success = false;
57 message += " Cannot find an &amp;nbsp; followed by a space when searching for two spaces.";
60 if (!canFind(nbsp, "a b")) {
61 success = false;
62 message += " Cannot find space.";
65 if (canFind(nbsp + nbsp, "a b")) {
66 success = false;
67 message += " Two spaces are matching even though they should be collapsed.";
70 if (!canFind(nbsp + nbsp, "<pre>a b</pre>")) {
71 success = false;
72 message += " Cannot find two spaces in a &lt;pre&gt; element.";
75 if (!canFind(nbsp, "a&nbsp;b")) {
76 success = false;
77 message += " Cannot find an &amp;nbsp; when searching for a space.";
80 if (!canFind(nbsp + nbsp, "a &nbsp;b")) {
81 success = false;
82 message += " Cannot find a space followed by &amp;nbsp; when searching for two spaces.";
85 if (!canFind(nbsp + nbsp, "a&nbsp; b")) {
86 success = false;
87 message += " Cannot find an &amp;nbsp; followed by a space when searching for two spaces.";
90 if (success)
91 message = "SUCCESS: Found all the spaces as expected.";
93 document.body.innerHTML = message;
95 </script>
96 </head>
97 <body onload="runTests()"></body>
98 </html>