Commit b267f90b authored by justing's avatar justing

New/updated layout tests for:

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=4904>
        Bug with baseOffset and extentOffset in selections (for writely.com)
        <rdar://problem/4259818>
        selection object incorrect after double-clicking a word

        * editing/selection/anchor-focus1-expected.txt: Added.
        * editing/selection/anchor-focus1.html: Added.
        * editing/selection/anchor-focus2-expected.txt: Added.
        * editing/selection/anchor-focus2.html: Added.
        * editing/selection/anchor-focus3-expected.txt: Added.
        * editing/selection/anchor-focus3.html: Added.
        * editing/selection/getRangeAt-expected.txt: Added.
        * editing/selection/getRangeAt.html: Added.
        * editing/selection/unrendered-001-expected.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11858 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 02ba5929
2006-01-03 Justin Garcia <justin.garcia@apple.com>
New/updated layout tests for:
<http://bugzilla.opendarwin.org/show_bug.cgi?id=4904>
Bug with baseOffset and extentOffset in selections (for writely.com)
<rdar://problem/4259818>
selection object incorrect after double-clicking a word
* editing/selection/anchor-focus1-expected.txt: Added.
* editing/selection/anchor-focus1.html: Added.
* editing/selection/anchor-focus2-expected.txt: Added.
* editing/selection/anchor-focus2.html: Added.
* editing/selection/anchor-focus3-expected.txt: Added.
* editing/selection/anchor-focus3.html: Added.
* editing/selection/getRangeAt-expected.txt: Added.
* editing/selection/getRangeAt.html: Added.
* editing/selection/unrendered-001-expected.txt:
2006-01-03 Anders Carlsson <andersca@mac.com>
Reviewed by Maciej.
......
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > SPAN > DIV > BODY > HTML > #document to 4 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
This tests the anchorNode, anchorOffset, focusNode and focusOffset properties of the Selection object. These properties are part of Mozilla's Selection object API, and so their values should be consistent in both browsers.
text
Anchor ([object Text], 0) is correct.
Focus ([object Text], 4) is correct.
<html>
<head>
<script>
function log(str) {
var li = document.createElement("li");
li.appendChild(document.createTextNode(str));
var console = document.getElementById("console");
console.appendChild(li);
}
function runTest() {
var elem = document.getElementById("test");
var selection = window.getSelection();
var anchorNode = selection.anchorNode;
var anchorOffset = selection.anchorOffset;
var focusNode = selection.focusNode;
var focusOffset = selection.focusOffset;
var anchorString = "Anchor (" + anchorNode + ", " + anchorOffset + ")";
var anchorCorrect = (anchorNode == elem || anchorNode == elem.firstChild) && anchorOffset == 0;
if (anchorCorrect)
log(anchorString + " is correct.");
else
throw(anchorString + " is incorrect.");
var focusString = "Focus (" + focusNode + ", " + focusOffset + ")";
var focusCorrect = (focusNode == elem && focusOffset == 1 || focusNode == elem.firstChild && focusOffset == elem.firstChild.length);
if (focusCorrect)
log(focusString + " is correct.");
else
throw(focusString + " is incorrect.");
}
function manualTest() {
try {
runTest();
} catch(e) {
log("Test Failed. Error was: " + e);
}
}
function automaticTest() {
try {
if (!window.layoutTestController)
throw("This test uses the layoutTestController's eventSender to do mouse clicks. To run it manually, double click on the text inside the blue box and click the 'Run Test' button.");
window.layoutTestController.dumpAsText();
var elem = document.getElementById("test");
// x, y should be in the middle of elem.
x = elem.offsetLeft + elem.offsetWidth / 2;
y = elem.offsetTop + elem.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
eventSender.mouseDown();
eventSender.mouseUp();
runTest();
} catch(e) {
log("Test Failed. Error was: " + e);
}
}
</script>
</head>
<body>
<p>This tests the anchorNode, anchorOffset, focusNode and focusOffset properties of the Selection object. These properties are part of Mozilla's Selection object API, and so their values should be consistent in both browsers.</p>
<input type="button" onclick="manualTest();" value="Run Test">
<div style="border: 1px solid blue; padding: 1em;"><span id="test">text</span></div>
<ul id="console"></ul>
<script>automaticTest();</script>
</body>
</html>
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
This tests the anchorNode, anchorOffset, focusNode and focusOffset properties of the Selection object. These properties are part of Mozilla's Selection object API, and so their values should be consistent in both browsers.
text
Anchor ([object Text], 0) is correct.
Focus ([object Text], 4) is correct.
<html>
<head>
<script>
var x1, x2, y;
function log(str) {
var li = document.createElement("li");
li.appendChild(document.createTextNode(str));
var console = document.getElementById("console");
console.appendChild(li);
}
function runTest() {
var elem = document.getElementById("test");
var selection = window.getSelection();
var anchorNode = selection.anchorNode;
var anchorOffset = selection.anchorOffset;
var focusNode = selection.focusNode;
var focusOffset = selection.focusOffset;
var anchorString = "Anchor (" + anchorNode + ", " + anchorOffset + ")";
var anchorCorrect = (anchorNode == elem || anchorNode == elem.firstChild) && anchorOffset == 0;
if (anchorCorrect)
log(anchorString + " is correct.");
else
throw(anchorString + " is incorrect.");
var focusString = "Focus (" + focusNode + ", " + focusOffset + ")";
var focusCorrect = (focusNode == elem && focusOffset == 1 || focusNode == elem.firstChild && focusOffset == elem.firstChild.length);
if (focusCorrect)
log(focusString + " is correct.");
else
throw(focusString + " is incorrect.");
}
function manualTest() {
try {
runTest();
} catch(e) {
log("Test Failed. Error was: " + e);
}
}
function automaticTest() {
try {
if (!window.layoutTestController)
throw("This test uses the layoutTestController's eventSender to do mouse clicks. To run it manually, from left to right, select 'text' in the box below, then click the 'Run Test' button.");
window.layoutTestController.dumpAsText();
var elem = document.getElementById("test");
// (x1, y) to (x2, y) should select the element.
// selects the text from left to right.
x1 = elem.offsetLeft;
x2 = elem.offsetLeft + elem.offsetWidth;
y = elem.offsetTop + elem.offsetHeight / 2;
eventSender.mouseMoveTo(x1, y);
eventSender.mouseDown();
eventSender.mouseMoveTo(x1, y);
eventSender.mouseMoveTo(x2, y);
eventSender.mouseUp();
runTest();
} catch(e) {
log("Test Failed. Error was: " + e);
}
}
</script>
</head>
<body>
<p>This tests the anchorNode, anchorOffset, focusNode and focusOffset properties of the Selection object. These properties are part of Mozilla's Selection object API, and so their values should be consistent in both browsers.</p>
<input type="button" onclick="manualTest();" value="Run Test">
<div style="border: 1px solid blue;" id="test">text</div>
<ul id="console"></ul>
<script>automaticTest();</script>
</body>
</html>
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
This tests the anchorNode, anchorOffset, focusNode and focusOffset properties of the Selection object. These properties are part of Mozilla's Selection object API, and so their values should be consistent in both browsers.
text
Anchor ([object Text], 4) is correct.
Focus ([object Text], 0) is correct.
<html>
<head>
<script>
function log(str) {
var li = document.createElement("li");
li.appendChild(document.createTextNode(str));
var console = document.getElementById("console");
console.appendChild(li);
}
function runTest() {
var elem = document.getElementById("test");
var selection = window.getSelection();
var anchorNode = selection.anchorNode;
var anchorOffset = selection.anchorOffset;
var focusNode = selection.focusNode;
var focusOffset = selection.focusOffset;
var anchorString = "Anchor (" + anchorNode + ", " + anchorOffset + ")";
var anchorCorrect = anchorNode == elem && anchorOffset == 1 || anchorNode == elem.firstChild && anchorOffset == elem.firstChild.length;
if (anchorCorrect)
log(anchorString + " is correct.");
else
throw(anchorString + " is incorrect.");
var focusString = "Focus (" + focusNode + ", " + focusOffset + ")";
var focusCorrect = (focusNode == elem || focusNode == elem.firstChild) && focusOffset == 0;
if (focusCorrect)
log(focusString + " is correct.");
else
throw(focusString + " is incorrect.");
}
function manualTest() {
try {
runTest();
} catch(e) {
log("Test Failed. Error was: " + e);
}
}
function automaticTest() {
try {
if (!window.layoutTestController)
throw("This test does not run interactively. It uses the layoutTestController's eventSender to do mouse clicks. To run it manually, from right to left, select 'text' in the box below, then click the 'Run Test' button.");
window.layoutTestController.dumpAsText();
var elem = document.getElementById("test");
// (x1, y) to (x2, y) should select the element.
// selects the text from right to left.
x1 = elem.offsetLeft + elem.offsetWidth;
x2 = elem.offsetLeft;
y = elem.offsetTop + elem.offsetHeight / 2;
eventSender.mouseMoveTo(x1, y);
eventSender.mouseDown();
eventSender.mouseMoveTo(x1, y);
eventSender.mouseMoveTo(x2, y);
eventSender.mouseUp();
runTest();
} catch(e) {
log("Test Failed. Error was: " + e);
}
}
</script>
</head>
<body>
<p>This tests the anchorNode, anchorOffset, focusNode and focusOffset properties of the Selection object. These properties are part of Mozilla's Selection object API, and so their values should be consistent in both browsers.</p>
<input type="button" onclick="manualTest();" value="Run Test">
<div style="border: 1px solid blue;" id="test">text</div>
<ul id="console"></ul>
<script>automaticTest();</script>
</body>
</html>
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
This tests that Selection::getRangeAt(int) returns a valid Range object.
hello
[object Range]
[object Text]
[object Text]
<html>
<head><script>
function log(str) {
if (str == null)
str = "null"
var li = document.createElement("li");
var pre = document.createElement("pre");
pre.appendChild(document.createTextNode(str));
li.appendChild(pre);
var console = document.getElementById("console");
console.appendChild(li);
}
function runTest() {
var elem = document.getElementById("test");
var sel = window.getSelection();
if (window.layoutTestController)
window.layoutTestController.dumpAsText();
try {
sel.setBaseAndExtent(elem, 0, elem, 1);
var range = sel.getRangeAt(0);
log(range);
log(range.startContainer);
log(range.endContainer);
} catch(e) {
log("Error: " + e);
}
}
</script></head>
<body onload="runTest();">
<p>This tests that Selection::getRangeAt(int) returns a valid Range object.</p>
<div id="test" style="border:1px solid black; padding:1em;">hello</div>
<ul id="console"></ul>
</body>
</html>
\ No newline at end of file
......@@ -10,4 +10,4 @@ layer at (0,0) size 820x600
text run at (74,84) width 32: "foo"
RenderText {TEXT} at (106,84) size 40x48
text run at (106,84) width 40: " baz"
caret: position 0 of child 3 {TEXT} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
caret: position 3 of child 0 {TEXT} of child 1 {SPAN} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment