5 <script src=
"../../resources/js-test.js"></script>
6 <style type=
"text/css">
7 .selectionDisabled { -webkit-user-select: none
; }
8 .selectionEnabled { -webkit-user-select: auto
; }
12 <div id=
"container"></div>
13 <pre id=
"console" style=
"visibility: hidden;"></pre>
17 document
.getElementById("console").appendChild(document
.createTextNode(message
+ "\n"));
20 function testFindString(text
, target
, disableSelection
, expected
)
22 var selectionStatus
= disableSelection
? "selection disabled:" : "selection enabled:";
23 log("Searching for '" + target
+ "' in '" + text
+ "' with " + selectionStatus
);
25 var container
= document
.getElementById("container");
26 container
.innerText
= text
;
27 document
.body
.offsetTop
;
29 container
.className
= disableSelection
? "selectionDisabled" : "selectionEnabled";
31 shouldBe("testRunner.findString('" + target
+ "', [])", expected
);
33 container
.innerText
= "";
37 if (!window
.testRunner
)
38 testFailed('This test requires the testRunner object');
40 for (i
= 0; i
< 2; i
++) {
41 var disableSelection
= (i
== 1);
43 testFindString("Some sample text that can be searched", "e", disableSelection
, "true");
44 testFindString("Some sample text that can be searched", "o", disableSelection
, "true");
45 testFindString("Some sample text that can be searched", "y", disableSelection
, "false");
46 testFindString("Some sample text that can be searched", "t t", disableSelection
, "true");
47 testFindString("insurmountable mountain", "mount", disableSelection
, "true");
48 testFindString("insurmountable mountain", "Wally", disableSelection
, "false");
52 document
.getElementById("console").style
.removeProperty("visibility");
54 var successfullyParsed
= true;