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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/text/find-backwards.html

Issue 2905013004: Speed up LayoutTests/fast/text/find-backwards.html (Closed)
Patch Set: Created 3 years, 6 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 PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <title>find forwards and backwards</title>
5 </head> 5 <script src="../../resources/testharness.js"></script>
6 <body> 6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="script-tests/find-backwards.js"></script> 7 </head>
8 </body> 8 <body>
9 <p>
10 Tests find going both forward and backwards in small and large documents.
11 </p>
12 <script>
13 function findForwards(textNode, pattern) {
14 var selection = window.getSelection();
15 selection.removeAllRanges();
16
17 var beforeTextNodeRange = document.createRange();
18 beforeTextNodeRange.setStartBefore(textNode);
19 beforeTextNodeRange.setEndBefore(textNode);
20 selection.addRange(beforeTextNodeRange);
21
22 assert_true(find(pattern, false), 'Match expected.');
23 assert_equals(selection.rangeCount, 1, 'Exactly one match expected.');
24
25 var resultRange = selection.getRangeAt(0);
26 assert_equals(resultRange.startContainer, textNode);
27 assert_equals(resultRange.endContainer, textNode);
28
29 return resultRange.startOffset + ', ' + resultRange.endOffset;
30 }
31
32 function findBackwards(textNode, pattern) {
33 var selection = window.getSelection();
34 selection.removeAllRanges();
35
36 var afterTextNodeRange = document.createRange();
37 afterTextNodeRange.setStartAfter(textNode);
38 afterTextNodeRange.setEndAfter(textNode);
39 selection.addRange(afterTextNodeRange);
40
41 assert_true(find(pattern, false, true), 'Match expected.');
42 assert_equals(selection.rangeCount, 1, 'Exactly one match expected.');
43
44 var resultRange = selection.getRangeAt(0);
45 assert_equals(resultRange.startContainer, textNode);
46 assert_equals(resultRange.endContainer, textNode);
47
48 return resultRange.startOffset + ', ' + resultRange.endOffset;
49 }
50
51 var textNode = document.createTextNode('');
52 document.body.appendChild(textNode);
53
54 textNode.textContent = 'abc';
55 test(function() {
56 assert_equals(findForwards(textNode, 'a'), '0, 1');
57 assert_equals(findForwards(textNode, 'b'), '1, 2');
58 assert_equals(findForwards(textNode, 'c'), '2, 3');
59 }, 'Find forwards for short document.');
60
61 test(function() {
62 assert_equals(findBackwards(textNode, 'a'), '0, 1');
63 assert_equals(findBackwards(textNode, 'b'), '1, 2');
64 assert_equals(findBackwards(textNode, 'c'), '2, 3');
65 }, 'Find backwards for short document.');
66
67 var tenThousandChars = Array(10001).join('0');
68 textNode.textContent = tenThousandChars + 'abc' + tenThousandChars;
69
70 test(function() {
71 assert_equals(findForwards(textNode, 'a'), '10000, 10001');
72 assert_equals(findForwards(textNode, 'b'), '10001, 10002');
73 assert_equals(findForwards(textNode, 'c'), '10002, 10003');
74 }, 'Find forwards for long document.');
75
76 test(function() {
77 assert_equals(findBackwards(textNode, 'a'), '10000, 10001');
78 assert_equals(findBackwards(textNode, 'b'), '10001, 10002');
79 assert_equals(findBackwards(textNode, 'c'), '10002, 10003');
80 }, 'Find backwards for long document.');
81
82 document.body.removeChild(textNode);
83 </script>
84 </body>
9 </html> 85 </html>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/SlowTests ('k') | third_party/WebKit/LayoutTests/fast/text/find-backwards-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698