Bug 26361

Summary: editing/deleting/5156801.html doesn't test what it claims to test
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Critical CC: jparent, justin.garcia
Priority: P5    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
This patch fixes the bug, and converts the text from a pixel test to a dumpAsText test.
justin.garcia: review+
fixes the bug. The previous patch had wrong relative path with "WebKit5/" at the beginning mjs: review+

Description Ryosuke Niwa 2009-06-12 16:27:30 PDT
The explanation and code in
LayoutTests\editing\deleting\5156801.html
does not match.

In fact, the test seems to be missing some code.

The following is the original code:
<p>This tests for a bug where delete would crash if a node just after the selection to delete is removed in a DOMNodeRemoved event handler for the last node in the selection to delete.</p> 
<div contenteditable="true">foo<span id="foo">x</span><span id="removeme">y</span></div> 
 
<script> 
function removeHandler() {
    var removeme = document.getElementById("removeme");
    removeme.parentNode.removeChild(removeme);
}
 
document.getElementById("foo").addEventListener("DOMNodeRemoved", removeHandler);
</script>
Comment 1 Ryosuke Niwa 2009-06-12 16:28:56 PDT
My guess is that the test should look something like this:

<p>This tests for a bug where delete would crash if a node just after the selection to delete is removed in a DOMNodeRemoved event handler for the last node in the selection to delete.</p>
<div id="div" contenteditable="true">foo<span id="foo">x</span><span id="removeme">y</span></div>
<p id="console"></p>

<script>

if (window.layoutTestController)
    window.layoutTestController.dumpAsText();

function log(message) {
    var console = document.getElementById("console");
    var text = document.createTextNode(message);
    console.appendChild(text);
}

function removeHandler() {
    var removeme = document.getElementById("removeme");
    removeme.parentNode.removeChild(removeme);
}

document.getElementById("foo").addEventListener("DOMNodeRemoved", removeHandler);
var sel = window.getSelection();
sel.setBaseAndExtent( document.getElementById('foo'), 0, document.getElementById('foo'), 1 );
document.execCommand("Delete");

log(document.getElementById('div');

</script>
Comment 2 Justin Garcia 2009-06-12 19:11:46 PDT
> My guess is that the test should look something like this:

Looks right.
Comment 3 Ryosuke Niwa 2009-06-12 23:41:33 PDT
Thanks, Justin.  I'll make a patch for it since I've been already rewriting a lot of test cases in editing\deleting.
Comment 4 Ryosuke Niwa 2009-06-17 11:48:49 PDT
Created attachment 31428 [details]
This patch fixes the bug, and converts the text from a pixel test to a dumpAsText test.
Comment 5 Ryosuke Niwa 2009-06-17 14:53:54 PDT
Created attachment 31442 [details]
fixes the bug.  The previous patch had wrong relative path with "WebKit5/" at the beginning

Sorry Justin, I didn't know that I had to svn-create-patch on src/.  I had "WebKit5/" all over the patch.
Comment 6 Maciej Stachowiak 2009-06-18 09:01:42 PDT
Comment on attachment 31442 [details]
fixes the bug.  The previous patch had wrong relative path with "WebKit5/" at the beginning

r=me

This might be a good candidate for a dumpAsMarkup() text if we add that mode.
Comment 7 Ryosuke Niwa 2009-06-18 11:17:46 PDT
(In reply to comment #6)
> (From update of attachment 31442 [details] [review])
> r=me
> 
> This might be a good candidate for a dumpAsMarkup() text if we add that mode.
> 

I agree.
Comment 8 Brent Fulgham 2009-06-19 17:00:41 PDT
Assign for landing.
Comment 9 Brent Fulgham 2009-06-19 17:30:34 PDT
Landed in http://trac.webkit.org/changeset/44882.