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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/text/script-tests/find-backwards.js

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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/text/find-backwards-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 description("Tests find going both forward and backwards in small and large docu ments.");
2
3 var selection = getSelection();
4
5 function testFind(subjectString, pattern, backwards)
6 {
7 var textNode = document.createTextNode(subjectString);
8 document.body.appendChild(textNode);
9 selection.removeAllRanges();
10 if (backwards) {
11 var afterTextNodeRange = document.createRange();
12 afterTextNodeRange.setStartAfter(textNode);
13 afterTextNodeRange.setEndAfter(textNode);
14 selection.addRange(afterTextNodeRange);
15 } else {
16 var beforeTextNodeRange = document.createRange();
17 beforeTextNodeRange.setStartBefore(textNode);
18 beforeTextNodeRange.setEndBefore(textNode);
19 selection.addRange(beforeTextNodeRange);
20 }
21 var result;
22 if (!find(pattern, false, backwards))
23 result = "not found"
24 else if (selection.rangeCount != 1)
25 result = "internal inconsistency";
26 else {
27 var resultRange = selection.getRangeAt(0);
28 if (resultRange.startContainer !== textNode || resultRange.endContainer !== textNode)
29 result = "not found";
30 else
31 result = resultRange.startOffset + ", " + resultRange.endOffset;
32 }
33 document.body.removeChild(textNode);
34 return result;
35 }
36
37 var forward = false;
38 var backward = true;
39
40 var manyCharacters = "1234567890"
41 for (i = 0; i < 10; ++i)
42 manyCharacters += manyCharacters;
43 var tenThousandCharacters = manyCharacters.substring(0, 10000);
44
45 shouldBe("testFind('abc', 'a', forward)", "'0, 1'");
46 shouldBe("testFind('abc', 'b', forward)", "'1, 2'");
47 shouldBe("testFind('abc', 'c', forward)", "'2, 3'");
48 shouldBe("testFind('abc', 'a', backward)", "'0, 1'");
49 shouldBe("testFind('abc', 'b', backward)", "'1, 2'");
50 shouldBe("testFind('abc', 'c', backward)", "'2, 3'");
51 shouldBe("testFind(tenThousandCharacters + 'abc' + tenThousandCharacters, 'a', f orward)", "'10000, 10001'");
52 shouldBe("testFind(tenThousandCharacters + 'abc' + tenThousandCharacters, 'b', f orward)", "'10001, 10002'");
53 shouldBe("testFind(tenThousandCharacters + 'abc' + tenThousandCharacters, 'c', f orward)", "'10002, 10003'");
54 shouldBe("testFind(tenThousandCharacters + 'abc' + tenThousandCharacters, 'a', b ackward)", "'10000, 10001'");
55 shouldBe("testFind(tenThousandCharacters + 'abc' + tenThousandCharacters, 'b', b ackward)", "'10001, 10002'");
56 shouldBe("testFind(tenThousandCharacters + 'abc' + tenThousandCharacters, 'c', b ackward)", "'10002, 10003'");
57 shouldBe("testFind('abcabc', 'a', forward)", "'0, 1'");
58 shouldBe("testFind('abcabc', 'b', forward)", "'1, 2'");
59 shouldBe("testFind('abcabc', 'c', forward)", "'2, 3'");
60 shouldBe("testFind('abcabc', 'a', backward)", "'3, 4'");
61 shouldBe("testFind('abcabc', 'b', backward)", "'4, 5'");
62 shouldBe("testFind('abcabc', 'c', backward)", "'5, 6'");
63 shouldBe("testFind(tenThousandCharacters + 'abcabc' + tenThousandCharacters, 'a' , forward)", "'10000, 10001'");
64 shouldBe("testFind(tenThousandCharacters + 'abcabc' + tenThousandCharacters, 'b' , forward)", "'10001, 10002'");
65 shouldBe("testFind(tenThousandCharacters + 'abcabc' + tenThousandCharacters, 'c' , forward)", "'10002, 10003'");
66 shouldBe("testFind(tenThousandCharacters + 'abcabc' + tenThousandCharacters, 'a' , backward)", "'10003, 10004'");
67 shouldBe("testFind(tenThousandCharacters + 'abcabc' + tenThousandCharacters, 'b' , backward)", "'10004, 10005'");
68 shouldBe("testFind(tenThousandCharacters + 'abcabc' + tenThousandCharacters, 'c' , backward)", "'10005, 10006'");
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/text/find-backwards-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698