Changeset 64303 in webkit


Ignore:
Timestamp:
Jul 29, 2010 1:16:52 PM (14 years ago)
Author:
ojan@chromium.org
Message:

2010-07-27 Ojan Vafai <ojan@chromium.org>

Reviewed by Adam Barth.

dump-as-markup should have better output
https://bugs.webkit.org/show_bug.cgi?id=43015

-Merge dom2string into dump-as-markup and pull over all dom2string features (e.g. indent).
-#-prefix selection markers

  • editing/deleting/delete-br-in-last-table-cell-expected.txt:
  • editing/execCommand/crash-indenting-list-item-expected.txt:
  • editing/execCommand/crash-on-enter-in-contentEditable-list-expected.txt:
  • editing/execCommand/create-list-from-range-selection-expected.txt:
  • editing/execCommand/hilitecolor-expected.txt:
  • editing/execCommand/indent-pre-expected.txt:
  • editing/execCommand/insert-list-empty-div-expected.txt:
  • editing/selection/dump-as-markup-expected.txt:
  • editing/selection/dump-as-markup.html:
  • editing/selection/home-inside-noneditable-table-expected.txt:
  • editing/style/remove-underline-from-stylesheet-expected.txt:
  • editing/style/style-text-node-without-editable-parent-expected.txt:
  • editing/undo/redo-split-text-node-expected.txt:
  • editing/undo/redo-split-text-with-removal-expected.txt:
  • html5lib/resources/dom2string.js: Removed.
  • html5lib/resources/tests4.dat:
  • html5lib/resources/tests6.dat:
  • html5lib/runner-expected.txt:
  • html5lib/runner.html:
  • html5lib/webkit-resumer.html:
  • resources/dump-as-markup.js: (Markup.notifyDone): (Markup._get): (Markup._namespace): (Markup._dumpCalls.0.Markup._indent): (Markup._toAsciiLowerCase): (Markup._getMarkupForTextNode): (Markup._getSelectionMarker):
Location:
trunk/LayoutTests
Files:
1 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r64301 r64303  
     12010-07-27  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        dump-as-markup should have better output
     6        https://bugs.webkit.org/show_bug.cgi?id=43015
     7
     8        -Merge dom2string into dump-as-markup and pull over all dom2string features (e.g. indent).
     9        -#-prefix selection markers
     10
     11        * editing/deleting/delete-br-in-last-table-cell-expected.txt:
     12        * editing/execCommand/crash-indenting-list-item-expected.txt:
     13        * editing/execCommand/crash-on-enter-in-contentEditable-list-expected.txt:
     14        * editing/execCommand/create-list-from-range-selection-expected.txt:
     15        * editing/execCommand/hilitecolor-expected.txt:
     16        * editing/execCommand/indent-pre-expected.txt:
     17        * editing/execCommand/insert-list-empty-div-expected.txt:
     18        * editing/selection/dump-as-markup-expected.txt:
     19        * editing/selection/dump-as-markup.html:
     20        * editing/selection/home-inside-noneditable-table-expected.txt:
     21        * editing/style/remove-underline-from-stylesheet-expected.txt:
     22        * editing/style/style-text-node-without-editable-parent-expected.txt:
     23        * editing/undo/redo-split-text-node-expected.txt:
     24        * editing/undo/redo-split-text-with-removal-expected.txt:
     25        * html5lib/resources/dom2string.js: Removed.
     26        * html5lib/resources/tests4.dat:
     27        * html5lib/resources/tests6.dat:
     28        * html5lib/runner-expected.txt:
     29        * html5lib/runner.html:
     30        * html5lib/webkit-resumer.html:
     31        * resources/dump-as-markup.js:
     32        (Markup.notifyDone):
     33        (Markup._get):
     34        (Markup._namespace):
     35        (Markup._dumpCalls.0.Markup._indent):
     36        (Markup._toAsciiLowerCase):
     37        (Markup._getMarkupForTextNode):
     38        (Markup._getSelectionMarker):
     39
    1402010-07-29  Victor Wang  <victorw@chromium.org>
    241
  • trunk/LayoutTests/editing/deleting/delete-br-in-last-table-cell-expected.txt

    r63517 r64303  
    1 
    2 <HTML>
    3 <HEAD>
    4 <#text>
    5 </#text>
    6 <SCRIPT src="../../resources/dump-as-markup.js" type="text/JavaScript"></SCRIPT>
    7 <#text>
    8 </#text>
    9 <SCRIPT src="../editing.js" type="text/JavaScript"></SCRIPT>
    10 <#text>
    11 </#text>
    12 <SCRIPT>
     1| <html>
     2|   <head>
     3|     "
     4"
     5|     <script>
     6|       language="JavaScript"
     7|       src="../../resources/dump-as-markup.js"
     8|       type="text/JavaScript"
     9|     "
     10"
     11|     <script>
     12|       language="JavaScript"
     13|       src="../editing.js"
     14|       type="text/JavaScript"
     15|     "
     16"
     17|     <script>
     18|       "
    1319function runTest()
    1420{
    15 br = document.getElementById("lastBR");
    16 sel = window.getSelection();
    17 sel.setBaseAndExtent(br, 0, br, 0);
    18 deleteCommand();
     21    br = document.getElementById("lastBR");
     22    sel = window.getSelection();
     23    sel.setBaseAndExtent(br, 0, br, 0);
     24    deleteCommand();
    1925}
    20 </SCRIPT>
    21 <#text>
    22 </#text>
    23 </HEAD>
    24 <#text>
     26"
     27|     "
     28"
     29|   "
    2530
    26 </#text>
    27 <BODY>
    28 <#text>
    29 </#text>
    30 <P>
    31 <A href="https://bugs.webkit.org/show_bug.cgi?id=35369">
    32 <#text>Bug 35369</#text>
    33 </A>
    34 <#text> and </#text>
    35 <A href="https://bugs.webkit.org/show_bug.cgi?id=35632">
    36 <#text>Bug 35632</#text>
    37 </A>
    38 </P>
    39 <#text>
    40 </#text>
    41 <P>
    42 <#text>Executing a delete command when positioned before a BR in a table cell (esp. the last)</#text>
    43 </P>
    44 <#text>
    45 </#text>
    46 <DIV contentEditable="">
    47 <#text>
    48 </#text>
    49 <TABLE id="table">
    50 <TBODY>
    51 <TR>
    52 <TD>
    53 <#text>1</#text>
    54 </TD>
    55 <TD>
    56 <#text>2</#text>
    57 </TD>
    58 </TR>
    59 <TR>
    60 <TD>
    61 <#text>3</#text>
    62 </TD>
    63 <TD>
    64 <#text>4<selection-caret></#text>
    65 <BR id="lastBR">
    66 </TD>
    67 </TR>
    68 </TBODY>
    69 </TABLE>
    70 <#text>
    71 </#text>
    72 </DIV>
    73 <#text>
    74 </#text>
    75 <SCRIPT>
     31"
     32|   <body>
     33|     "
     34"
     35|     <p>
     36|       <a>
     37|         href="https://bugs.webkit.org/show_bug.cgi?id=35369"
     38|         "Bug 35369"
     39|       " and "
     40|       <a>
     41|         href="https://bugs.webkit.org/show_bug.cgi?id=35632"
     42|         "Bug 35632"
     43|     "
     44"
     45|     <p>
     46|       "Executing a delete command when positioned before a BR in a table cell (esp. the last)"
     47|     "
     48"
     49|     <div>
     50|       contenteditable=""
     51|       "
     52"
     53|       <table>
     54|         id="table"
     55|         <tbody>
     56|           <tr>
     57|             <td>
     58|               "1"
     59|             <td>
     60|               "2"
     61|           <tr>
     62|             <td>
     63|               "3"
     64|             <td>
     65|               "4<#selection-caret>"
     66|               <br>
     67|                 id="lastBR"
     68|       "
     69"
     70|     "
     71"
     72|     <script>
     73|       "
    7674runTest();
    77 </SCRIPT>
    78 <#text>
     75"
     76|     "
    7977
    8078
    81 </#text>
    82 </BODY>
    83 </HTML>
     79"
  • trunk/LayoutTests/editing/execCommand/crash-indenting-list-item-expected.txt

    r59739 r64303  
    1 
    2 <HTML>
    3 <HEAD>
    4 </HEAD>
    5 <BODY>
    6 <DIV contentEditable="">
    7 <UL>
    8 <UL>
    9 <LI id="foo">
    10 <#text>PASSED</#text>
    11 </LI>
    12 </UL>
    13 </UL>
    14 </DIV>
    15 <#text>
    16 </#text>
    17 <SCRIPT src="../../resources/dump-as-markup.js"></SCRIPT>
    18 <#text>
    19 </#text>
    20 <SCRIPT>
     1| <html>
     2|   <head>
     3|   <body>
     4|     <div>
     5|       contenteditable=""
     6|       <ul>
     7|         <ul>
     8|           <li>
     9|             id="foo"
     10|             "PASSED"
     11|     "
     12"
     13|     <script>
     14|       src="../../resources/dump-as-markup.js"
     15|     "
     16"
     17|     <script>
     18|       "
    2119window.getSelection().setBaseAndExtent(foo, 0, foo, 0);
    2220// This test passes if it does not crash.
    2321document.execCommand('indent', false, null);
    2422document.getElementById("foo").innerText = "PASSED";
    25 </SCRIPT>
    26 <#text>
    27 </#text>
    28 </BODY>
    29 </HTML>
     23"
     24|     "
     25"
  • trunk/LayoutTests/editing/execCommand/crash-on-enter-in-contentEditable-list-expected.txt

    r64056 r64303  
    1 
    2 <HTML>
    3 <HEAD>
    4 <SCRIPT src="../../resources/dump-as-markup.js"></SCRIPT>
    5 <#text>
    6 </#text>
    7 </HEAD>
    8 <BODY>
    9 <DIV>
    10 <#text>This test passes if it doesn't crash.</#text>
    11 </DIV>
    12 <#text>
    13 </#text>
    14 <UL contentEditable="">
    15 <#text>
    16 </#text>
    17 <LI id="foo">
    18 </LI>
    19 <LI id="foo"><selection-caret>
    20 <BR>
    21 </LI>
    22 <#text>
    23 </#text>
    24 </UL>
    25 <#text>
    26 </#text>
    27 <SCRIPT>
     1| <html>
     2|   <head>
     3|     <script>
     4|       src="../../resources/dump-as-markup.js"
     5|     "
     6"
     7|   <body>
     8|     <div>
     9|       "This test passes if it doesn't crash."
     10|     "
     11"
     12|     <ul>
     13|       contenteditable=""
     14|       "
     15    "
     16|       <li>
     17|         id="foo"
     18|       <li>
     19|         id="foo"
     20|         <#selection-caret>
     21|         <br>
     22|       "
     23"
     24|     "
     25"
     26|     <script>
     27|       "
    2828window.getSelection().selectAllChildren(foo);
    2929document.execCommand('insertParagraph');
    30 </SCRIPT>
    31 <#text>
    32 </#text>
    33 </BODY>
    34 </HTML>
     30"
     31|     "
     32"
  • trunk/LayoutTests/editing/execCommand/create-list-from-range-selection-expected.txt

    r63873 r64303  
    1 
    2 <DIV id="test" contentEditable="true">
    3 <OL>
    4 <LI>
    5 <#text>asd</#text>
    6 <SPAN id="start">
    7 <#text>fo<selection-anchor>o</#text>
    8 </SPAN>
    9 </LI>
    10 <LI>
    11 <#text>bar</#text>
    12 </LI>
    13 <LI>
    14 <#text>baz</#text>
    15 </LI>
    16 <LI>
    17 <#text>foo</#text>
    18 </LI>
    19 <LI>
    20 <#text>bar</#text>
    21 </LI>
    22 <LI>
    23 <#text>ba<selection-focus>z</#text>
    24 </LI>
    25 </OL>
    26 </DIV>
     1| <ol>
     2|   <li>
     3|     "asd"
     4|     <span>
     5|       id="start"
     6|       "fo<#selection-anchor>o"
     7|   <li>
     8|     "bar"
     9|   <li>
     10|     "baz"
     11|   <li>
     12|     "foo"
     13|   <li>
     14|     "bar"
     15|   <li>
     16|     "ba<#selection-focus>z"
  • trunk/LayoutTests/editing/execCommand/hilitecolor-expected.txt

    r64083 r64303  
    1111EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1212EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
    13 
    14 <DIV id="test" contentEditable="true">
    15 <#text><selection-caret>The </#text>
    16 <SPAN style="background-color: red;" class="Apple-style-span">
    17 <#text>second</#text>
    18 </SPAN>
    19 <#text> word, and only the second word of this sentence should have a red background color.</#text>
    20 </DIV>
     13| "<#selection-caret>The "
     14| <span>
     15|   class="Apple-style-span"
     16|   style="background-color: red;"
     17|   "second"
     18| " word, and only the second word of this sentence should have a red background color."
  • trunk/LayoutTests/editing/execCommand/indent-pre-expected.txt

    r63039 r64303  
    11CONSOLE MESSAGE: line 44: Wrong node selected.
    22CONSOLE MESSAGE: line 46: Wrong anchor offset: 8 instead of 0
     3| <html>
     4|   <head>
     5|   <body>
     6|     <p>
     7|       "This test tries to indent lines within pre tags.  This test passes if it
     8does not crash."
     9|     "
     10"
     11|     <div>
     12|       contenteditable=""
     13|       "
     14"
     15|       <blockquote>
     16|         class="webkit-indent-blockquote"
     17|         style="margin: 0 0 0 40px; border: none; padding: 0px;"
     18|         <pre>
     19|           id="pre-basic"
     20|           "line one
     21"
     22|       <pre>
     23|         id="pre-basic"
     24|         "line two
     25"
     26|       <blockquote>
     27|         class="webkit-indent-blockquote"
     28|         style="margin: 0 0 0 40px; border: none; padding: 0px;"
     29|         <pre>
     30|           id="pre-basic"
     31|           "line three
     32"
     33|         <pre>
     34|           id="pre-basic"
     35|           "line four"
     36|       "
    337
    4 <HTML>
    5 <HEAD>
    6 </HEAD>
    7 <BODY>
    8 <P>
    9 <#text>This test tries to indent lines within pre tags. This test passes if it
    10 does not crash.</#text>
    11 </P>
    12 <#text>
    13 </#text>
    14 <DIV contentEditable="">
    15 <#text>
    16 </#text>
    17 <BLOCKQUOTE style="margin: 0 0 0 40px; border: none; padding: 0px;" class="webkit-indent-blockquote">
    18 <PRE id="pre-basic">
    19 <#text>line one
    20 </#text>
    21 </PRE>
    22 </BLOCKQUOTE>
    23 <PRE id="pre-basic">
    24 <#text>line two
    25 </#text>
    26 </PRE>
    27 <BLOCKQUOTE style="margin: 0 0 0 40px; border: none; padding: 0px;" class="webkit-indent-blockquote">
    28 <PRE id="pre-basic">
    29 <#text>line three
    30 </#text>
    31 </PRE>
    32 <PRE id="pre-basic">
    33 <#text>line four</#text>
    34 </PRE>
    35 </BLOCKQUOTE>
    36 <#text>
     38"
     39|       <ul>
     40|         <li>
     41|           <pre>
     42|             id="pre-list"
     43|             "list one
     44"
     45|             <blockquote>
     46|               class="webkit-indent-blockquote"
     47|               style="margin: 0 0 0 40px; border: none; padding: 0px;"
     48|               "list two
     49"
     50|               "list three
     51"
     52|             "list four
     53"
     54|       "
    3755
    38 </#text>
    39 <UL>
    40 <LI>
    41 <PRE id="pre-list">
    42 <#text>list one
    43 </#text>
    44 <BLOCKQUOTE style="margin: 0 0 0 40px; border: none; padding: 0px;" class="webkit-indent-blockquote">
    45 <#text>list two
    46 </#text>
    47 <#text>list three
    48 </#text>
    49 </BLOCKQUOTE>
    50 <#text>list four
    51 </#text>
    52 </PRE>
    53 </LI>
    54 </UL>
    55 <#text>
     56"
     57|       <table>
     58|         "
     59"
     60|         <tbody>
     61|           <tr>
     62|             <td>
     63|               <pre>
     64|                 id="pre-table"
     65|                 "table one<#selection-anchor>
     66"
     67|               <blockquote>
     68|                 class="webkit-indent-blockquote"
     69|                 style="margin: 0 0 0 40px; border: none; padding: 0px;"
     70|                 <pre>
     71|                   id="pre-table"
     72|                   "table two
     73"
     74|                 <pre>
     75|                   id="pre-table"
     76|                   "table three<#selection-focus>"
     77|             <td>
     78|               "right cell"
     79|       "
    5680
    57 </#text>
    58 <TABLE>
    59 <#text>
    60 </#text>
    61 <TBODY>
    62 <TR>
    63 <TD>
    64 <PRE id="pre-table">
    65 <#text>table one<selection-anchor>
    66 </#text>
    67 </PRE>
    68 <BLOCKQUOTE style="margin: 0 0 0 40px; border: none; padding: 0px;" class="webkit-indent-blockquote">
    69 <PRE id="pre-table">
    70 <#text>table two
    71 </#text>
    72 </PRE>
    73 <PRE id="pre-table">
    74 <#text>table three<selection-focus></#text>
    75 </PRE>
    76 </BLOCKQUOTE>
    77 </TD>
    78 <TD>
    79 <#text>right cell</#text>
    80 </TD>
    81 </TR>
    82 </TBODY>
    83 </TABLE>
    84 <#text>
     81"
     82|       <div>
     83|         id="results"
     84|         "PASSED (did not crash)"
     85|       "
     86"
     87|     "
    8588
    86 </#text>
    87 <DIV id="results">
    88 <#text>PASSED (did not crash)</#text>
    89 </DIV>
    90 <#text>
    91 </#text>
    92 </DIV>
    93 <#text>
    94 
    95 </#text>
    96 <A href="javascript:document.execCommand('indent')">
    97 <#text>indent</#text>
    98 </A>
    99 <#text>
    100 </#text>
    101 <A href="javascript:document.execCommand('outdent')">
    102 <#text>outdent</#text>
    103 </A>
    104 <#text>
    105 </#text>
    106 <SCRIPT src="../../resources/dump-as-markup.js"></SCRIPT>
    107 <#text>
    108 </#text>
    109 <SCRIPT src="../editing.js"></SCRIPT>
    110 <#text>
    111 </#text>
    112 <SCRIPT>
     89"
     90|     <a>
     91|       href="javascript:document.execCommand('indent')"
     92|       "indent"
     93|     "
     94"
     95|     <a>
     96|       href="javascript:document.execCommand('outdent')"
     97|       "outdent"
     98|     "
     99"
     100|     <script>
     101|       src="../../resources/dump-as-markup.js"
     102|     "
     103"
     104|     <script>
     105|       src="../editing.js"
     106|     "
     107"
     108|     <script>
     109|       "
    113110function setSelection(node)
    114111{
    115 var textNode = node.firstChild;
    116 if (textNode.nodeType != Node.TEXT_NODE)
    117 throw "Wrong node type: " + textNode;
    118 execSetSelectionCommand(textNode, 0, 0);
     112    var textNode = node.firstChild;
     113    if (textNode.nodeType != Node.TEXT_NODE)
     114        throw "Wrong node type: " + textNode;
     115    execSetSelectionCommand(textNode, 0, 0);
    119116}
    120117
    121118function verifyTextSelection(startNode, startOffset, endNode, endOffset)
    122119{
    123 if (startNode.nodeType != Node.TEXT_NODE)
    124 console.log("Wrong start node type: " + startNode);
    125 if (endNode.nodeType != Node.TEXT_NODE)
    126 console.log("Wrong end node type: " + endNode);
    127 var sel = window.getSelection();
    128 if (sel.anchorNode != startNode || sel.focusNode != endNode)
    129 console.log("Wrong node selected.");
    130 if (sel.anchorOffset != startOffset)
    131 console.log("Wrong anchor offset: " + sel.anchorOffset + " instead of " + startOffset);
    132 if (sel.focusOffset != endOffset)
    133 console.log("Wrong focus offset: " + sel.focusOffset + " instead of " + endOffset);
     120    if (startNode.nodeType != Node.TEXT_NODE)
     121        console.log("Wrong start node type: " + startNode);
     122    if (endNode.nodeType != Node.TEXT_NODE)
     123        console.log("Wrong end node type: " + endNode);
     124    var sel = window.getSelection();
     125    if (sel.anchorNode != startNode || sel.focusNode != endNode)
     126        console.log("Wrong node selected.");
     127    if (sel.anchorOffset != startOffset)
     128        console.log("Wrong anchor offset: " + sel.anchorOffset + " instead of " + startOffset);
     129    if (sel.focusOffset != endOffset)
     130        console.log("Wrong focus offset: " + sel.focusOffset + " instead of " + endOffset);
    134131}
    135132
     
    141138document.execCommand("indent");
    142139verifyTextSelection(document.getElementsByTagName("pre")[0].firstChild, 1,
    143 document.getElementsByTagName("pre")[0].firstChild, 4);
     140                    document.getElementsByTagName("pre")[0].firstChild, 4);
    144141
    145142// Indent 2 lines.
     
    150147document.execCommand("indent");
    151148if (document.getElementsByTagName("pre").length > 3) {
    152 // FIXME: The selection for the anchorNode is wrong. It should stay at
    153 // the beginning of "line three", but it moves to the end of "line 2".
    154 verifyTextSelection(document.getElementsByTagName("pre")[2].firstChild, 0,
    155 document.getElementsByTagName("pre")[3].firstChild, 4);
     149    // FIXME: The selection for the anchorNode is wrong. It should stay at
     150    // the beginning of "line three", but it moves to the end of "line 2".
     151    verifyTextSelection(document.getElementsByTagName("pre")[2].firstChild, 0,
     152                        document.getElementsByTagName("pre")[3].firstChild, 4);
    156153} else {
    157 console.log("Wrong number of pre nodes.");
     154    console.log("Wrong number of pre nodes.");
    158155}
    159156
     
    166163document.execCommand("indent");
    167164verifyTextSelection(document.getElementsByTagName("blockquote")[2].firstChild, 0,
    168 document.getElementsByTagName("blockquote")[2].firstChild.nextSibling, 10);
     165                    document.getElementsByTagName("blockquote")[2].firstChild.nextSibling, 10);
    169166// Indenting <pre> lines in a table.
    170167pre = document.getElementById("pre-table");
     
    173170execExtendSelectionForwardByLineCommand();
    174171execExtendSelectionForwardByLineCommand();
    175 // FIXME: This is wrong. The pre tags get copied when they shouldn't be.
     172// FIXME: This is wrong.  The pre tags get copied when they shouldn't be.
    176173// See https://bugs.webkit.org/show_bug.cgi?id=42009
    177174document.execCommand("indent");
    178175document.getElementById("results").innerText = "PASSED (did not crash)";
    179 </SCRIPT>
    180 <#text>
    181 </#text>
    182 </BODY>
    183 </HTML>
     176"
     177|     "
     178"
  • trunk/LayoutTests/editing/execCommand/insert-list-empty-div-expected.txt

    r63873 r64303  
    1 
    2 <DIV id="div" contentEditable="true">
    3 <UL>
    4 <LI><selection-caret>
    5 <BR>
    6 </LI>
    7 </UL>
    8 </DIV>
     1| <ul>
     2|   <li>
     3|     <#selection-caret>
     4|     <br>
  • trunk/LayoutTests/editing/selection/dump-as-markup-expected.txt

    r63781 r64303  
    11Tests basic dump-as-markup functionality.
     2| <!DOCTYPE html>
     3| <html>
     4|   <head>
     5|     <script>
     6|       src="../../resources/dump-as-markup.js"
     7|     "
    28
    3 <HTML>
    4 <HEAD>
    5 <SCRIPT src="../../resources/dump-as-markup.js"></SCRIPT>
    6 <#text>
     9"
     10|   <body>
     11|     <div>
     12|       id="bar"
     13|       "<#selection-anchor>foo"
     14|       <hr>
     15|       <#selection-focus>
     16|     "
     17"
     18|     <input>
     19|       type="text"
     20|     "
     21"
     22|     <div>
     23|       contenteditable=""
     24|       id="foo"
     25|       "
     26  foo"
     27|       "   bar
     28"
     29|     "
     30"
     31|     <script>
     32|       "foo.firstChild.splitText(6);"
     33|     "
     34"
     35|     <span>
     36|       "foo"
     37|     <span>
     38|       "bar"
     39|     "
     40"
     41|     <div>
     42|       <div>
     43|         <b>
     44|           "sdf"
     45|         <i>
     46|           "sdf"
     47|         "sdf"
     48|     "
     49"
     50|     <iframe>
     51|       src="data:text/html;charset=utf-8,<!DOCTYPE%20HTML%20PUBLIC%20"-//W3C//DTD%20HTML%204.0//EN">%0D%0A<html%20lang%3D"en">%0D%0A%20<head>%0D%0A%20%20<title>Test</title>%0D%0A%20%20<style%20type%3D"text/css">%0D%0A%20%20</style>%0D%0A%20</head>%0D%0A%20<body>%0D%0A%20%20<p></p>%0D%0A%20</body>%0D%0A</html>%0D%0A"
     52|     "
    753
    8 </#text>
    9 </HEAD>
    10 <BODY>
    11 <DIV id="bar">
    12 <#text><selection-anchor>foo</#text>
    13 <HR><selection-focus>
    14 </DIV>
    15 <#text>
    16 </#text>
    17 <INPUT type="text">
    18 <#text>
    19 </#text>
    20 <DIV id="foo" contentEditable="">
    21 <#text>
    22 foo</#text>
    23 <#text> bar
    24 </#text>
    25 </DIV>
    26 <#text>
    27 </#text>
    28 <SCRIPT>foo.firstChild.splitText(6);</SCRIPT>
    29 <#text>
    30 </#text>
    31 <SPAN>
    32 <#text>foo</#text>
    33 </SPAN>
    34 <SPAN>
    35 <#text>bar</#text>
    36 </SPAN>
    37 <#text>
    38 </#text>
    39 <DIV>
    40 <DIV>
    41 <B>
    42 <#text>sdf</#text>
    43 </B>
    44 <I>
    45 <#text>sdf</#text>
    46 </I>
    47 <#text>sdf</#text>
    48 </DIV>
    49 </DIV>
    50 <#text>
    51 </#text>
    52 <IFRAME src="data:text/html;charset=utf-8,<!DOCTYPE%20HTML%20PUBLIC%20"-//W3C//DTD%20HTML%204.0//EN">%0D%0A<html%20lang%3D"en">%0D%0A%20<head>%0D%0A%20%20<title>Test</title>%0D%0A%20%20<style%20type%3D"text/css">%0D%0A%20%20</style>%0D%0A%20</head>%0D%0A%20<body>%0D%0A%20%20<p></p>%0D%0A%20</body>%0D%0A</html>%0D%0A"></IFRAME>
    53 <#text>
    54 
    55 </#text>
    56 <SCRIPT>
     54"
     55|     <script>
     56|       "
    5757Markup.description("Tests basic dump-as-markup functionality.");
    5858window.getSelection().selectAllChildren(bar)
    59 </SCRIPT>
    60 <#text>
    61 </#text>
    62 </BODY>
    63 </HTML>
     59"
     60|     "
     61"
    6462
    6563FRAME 0:
     64| <head>
     65|   "
     66  "
     67|   <title>
     68|     "Test"
     69|   "
     70  "
     71|   <style>
     72|     type="text/css"
     73|     "
     74  "
     75|   "
     76 "
     77| "
     78 "
     79| <body>
     80|   "
     81  "
     82|   <p>
     83|   "
     84 
    6685
    67 <HTML>
    68 <HEAD>
    69 <#text>
    70 </#text>
    71 <TITLE>
    72 <#text>Test</#text>
    73 </TITLE>
    74 <#text>
    75 </#text>
    76 <STYLE type="text/css">
    77 </STYLE>
    78 <#text>
    79 </#text>
    80 </HEAD>
    81 <#text>
    82 </#text>
    83 <BODY>
    84 <#text>
    85 </#text>
    86 <P>
    87 </P>
    88 <#text>
    89 
    90 
    91 </#text>
    92 </BODY>
    93 </HTML>
     86"
  • trunk/LayoutTests/editing/selection/dump-as-markup.html

    r63781 r64303  
     1<!DocType html>
    12<script src="../../resources/dump-as-markup.js"></script>
    23
  • trunk/LayoutTests/editing/selection/home-inside-noneditable-table-expected.txt

    r63918 r64303  
    22
    33Dump of markup 1:
    4 <DIV id="test" contentEditable="true">
    5 <#text>
    6 </#text>
    7 <DIV id="l1">
    8 <#text>The caret is initially <selection-caret>here but should move to the beginning of the line.</#text>
    9 </DIV>
    10 <#text>
    11 </#text>
    12 <DIV>
    13 <#text>dummy text</#text>
    14 </DIV>
    15 <#text>
    16 </#text>
    17 </DIV>
     4| "
     5      "
     6| <div>
     7|   id="l1"
     8|   "The caret is initially <#selection-caret>here but should move to the beginning of the line."
     9| "
     10      "
     11| <div>
     12|   "dummy text"
     13| "
     14    "
    1815
    1916Dump of markup 2:
    20 <DIV id="test" contentEditable="true">
    21 <#text>
    22 </#text>
    23 <DIV id="l1">
    24 <#text><selection-caret>The caret is initially here but should move to the beginning of the line.</#text>
    25 </DIV>
    26 <#text>
    27 </#text>
    28 <DIV>
    29 <#text>dummy text</#text>
    30 </DIV>
    31 <#text>
    32 </#text>
    33 </DIV>
     17| "
     18      "
     19| <div>
     20|   id="l1"
     21|   "<#selection-caret>The caret is initially here but should move to the beginning of the line."
     22| "
     23      "
     24| <div>
     25|   "dummy text"
     26| "
     27    "
  • trunk/LayoutTests/editing/style/remove-underline-from-stylesheet-expected.txt

    r64083 r64303  
    7171EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
    7272This tests removing underline from stylesheet (.editing has underline). Because text-decoration that comes from a style rule cannot be pushed down, the underline should stay. (see bug 27809).
    73 
    74 <DIV class="editing" id="root" contentEditable="">
    75 <#text>xxxxxx </#text>
    76 <#text><selection-anchor>xxxxxx<selection-focus></#text>
    77 <#text> xxxxxx</#text>
    78 <SPAN id="test">
    79 </SPAN>
    80 </DIV>
     73| "xxxxxx "
     74| "<#selection-anchor>xxxxxx<#selection-focus>"
     75| " xxxxxx"
     76| <span>
     77|   id="test"
  • trunk/LayoutTests/editing/style/style-text-node-without-editable-parent-expected.txt

    r64083 r64303  
    22
    33bold first:
    4 <SPAN contentEditable="">
    5 <B>
    6 <#text><selection-anchor>hello, <selection-focus></#text>
    7 </B>
    8 <#text>world WebKit</#text>
    9 </SPAN>
     4| <b>
     5|   "<#selection-anchor>hello, <#selection-focus>"
     6| "world WebKit"
    107
    118bold middle:
    12 <SPAN contentEditable="">
    13 <#text>hello, </#text>
    14 <B>
    15 <#text><selection-anchor>world<selection-focus></#text>
    16 </B>
    17 <#text> WebKit</#text>
    18 </SPAN>
     9| "hello, "
     10| <b>
     11|   "<#selection-anchor>world<#selection-focus>"
     12| " WebKit"
    1913
    2014bold last:
    21 <SPAN contentEditable="">
    22 <#text>hello, world</#text>
    23 <B>
    24 <#text><selection-anchor> WebKit<selection-focus></#text>
    25 </B>
    26 </SPAN>
     15| "hello, world"
     16| <b>
     17|   "<#selection-anchor> WebKit<#selection-focus>"
    2718
    2819bold all:
    29 <SPAN contentEditable="">
    30 <B>
    31 <#text><selection-anchor>hello, world WebKit<selection-focus></#text>
    32 </B>
    33 </SPAN>
     20| <b>
     21|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
    3422
    3523italic first:
    36 <SPAN contentEditable="">
    37 <I>
    38 <#text><selection-anchor>hello, <selection-focus></#text>
    39 </I>
    40 <#text>world WebKit</#text>
    41 </SPAN>
     24| <i>
     25|   "<#selection-anchor>hello, <#selection-focus>"
     26| "world WebKit"
    4227
    4328italic middle:
    44 <SPAN contentEditable="">
    45 <#text>hello, </#text>
    46 <I>
    47 <#text><selection-anchor>world<selection-focus></#text>
    48 </I>
    49 <#text> WebKit</#text>
    50 </SPAN>
     29| "hello, "
     30| <i>
     31|   "<#selection-anchor>world<#selection-focus>"
     32| " WebKit"
    5133
    5234italic last:
    53 <SPAN contentEditable="">
    54 <#text>hello, world</#text>
    55 <I>
    56 <#text><selection-anchor> WebKit<selection-focus></#text>
    57 </I>
    58 </SPAN>
     35| "hello, world"
     36| <i>
     37|   "<#selection-anchor> WebKit<#selection-focus>"
    5938
    6039italic all:
    61 <SPAN contentEditable="">
    62 <I>
    63 <#text><selection-anchor>hello, world WebKit<selection-focus></#text>
    64 </I>
    65 </SPAN>
     40| <i>
     41|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
    6642
    6743underline first:
    68 <SPAN contentEditable="">
    69 <U>
    70 <#text><selection-anchor>hello, <selection-focus></#text>
    71 </U>
    72 <#text>world WebKit</#text>
    73 </SPAN>
     44| <u>
     45|   "<#selection-anchor>hello, <#selection-focus>"
     46| "world WebKit"
    7447
    7548underline middle:
    76 <SPAN contentEditable="">
    77 <#text>hello, </#text>
    78 <U>
    79 <#text><selection-anchor>world<selection-focus></#text>
    80 </U>
    81 <#text> WebKit</#text>
    82 </SPAN>
     49| "hello, "
     50| <u>
     51|   "<#selection-anchor>world<#selection-focus>"
     52| " WebKit"
    8353
    8454underline last:
    85 <SPAN contentEditable="">
    86 <#text>hello, world</#text>
    87 <U>
    88 <#text><selection-anchor> WebKit<selection-focus></#text>
    89 </U>
    90 </SPAN>
     55| "hello, world"
     56| <u>
     57|   "<#selection-anchor> WebKit<#selection-focus>"
    9158
    9259underline all:
    93 <SPAN contentEditable="">
    94 <U>
    95 <#text><selection-anchor>hello, world WebKit<selection-focus></#text>
    96 </U>
    97 </SPAN>
     60| <u>
     61|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
    9862
    9963strikeThrough first:
    100 <SPAN contentEditable="">
    101 <S>
    102 <#text><selection-anchor>hello, <selection-focus></#text>
    103 </S>
    104 <#text>world WebKit</#text>
    105 </SPAN>
     64| <s>
     65|   "<#selection-anchor>hello, <#selection-focus>"
     66| "world WebKit"
    10667
    10768strikeThrough middle:
    108 <SPAN contentEditable="">
    109 <#text>hello, </#text>
    110 <S>
    111 <#text><selection-anchor>world<selection-focus></#text>
    112 </S>
    113 <#text> WebKit</#text>
    114 </SPAN>
     69| "hello, "
     70| <s>
     71|   "<#selection-anchor>world<#selection-focus>"
     72| " WebKit"
    11573
    11674strikeThrough last:
    117 <SPAN contentEditable="">
    118 <#text>hello, world</#text>
    119 <S>
    120 <#text><selection-anchor> WebKit<selection-focus></#text>
    121 </S>
    122 </SPAN>
     75| "hello, world"
     76| <s>
     77|   "<#selection-anchor> WebKit<#selection-focus>"
    12378
    12479strikeThrough all:
    125 <SPAN contentEditable="">
    126 <S>
    127 <#text><selection-anchor>hello, world WebKit<selection-focus></#text>
    128 </S>
    129 </SPAN>
     80| <s>
     81|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
    13082
    13183foreColor first:
    132 <SPAN contentEditable="">
    133 <FONT class="Apple-style-span" color="#0000FF">
    134 <#text><selection-anchor>hello, <selection-focus></#text>
    135 </FONT>
    136 <#text>world WebKit</#text>
    137 </SPAN>
     84| <font>
     85|   class="Apple-style-span"
     86|   color="#0000FF"
     87|   "<#selection-anchor>hello, <#selection-focus>"
     88| "world WebKit"
    13889
    13990foreColor middle:
    140 <SPAN contentEditable="">
    141 <#text>hello, </#text>
    142 <FONT class="Apple-style-span" color="#0000FF">
    143 <#text><selection-anchor>world<selection-focus></#text>
    144 </FONT>
    145 <#text> WebKit</#text>
    146 </SPAN>
     91| "hello, "
     92| <font>
     93|   class="Apple-style-span"
     94|   color="#0000FF"
     95|   "<#selection-anchor>world<#selection-focus>"
     96| " WebKit"
    14797
    14898foreColor last:
    149 <SPAN contentEditable="">
    150 <#text>hello, world</#text>
    151 <FONT class="Apple-style-span" color="#0000FF">
    152 <#text><selection-anchor> WebKit<selection-focus></#text>
    153 </FONT>
    154 </SPAN>
     99| "hello, world"
     100| <font>
     101|   class="Apple-style-span"
     102|   color="#0000FF"
     103|   "<#selection-anchor> WebKit<#selection-focus>"
    155104
    156105foreColor all:
    157 <SPAN contentEditable="">
    158 <FONT class="Apple-style-span" color="#0000FF">
    159 <#text><selection-anchor>hello, world WebKit<selection-focus></#text>
    160 </FONT>
    161 </SPAN>
     106| <font>
     107|   class="Apple-style-span"
     108|   color="#0000FF"
     109|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
    162110
    163111hiliteColor first:
    164 <SPAN contentEditable="">
    165 <SPAN style="background-color: blue;" class="Apple-style-span">
    166 <#text><selection-anchor>hello, <selection-focus></#text>
    167 </SPAN>
    168 <#text>world WebKit</#text>
    169 </SPAN>
     112| <span>
     113|   class="Apple-style-span"
     114|   style="background-color: blue;"
     115|   "<#selection-anchor>hello, <#selection-focus>"
     116| "world WebKit"
    170117
    171118hiliteColor middle:
    172 <SPAN contentEditable="">
    173 <#text>hello, </#text>
    174 <SPAN style="background-color: blue;" class="Apple-style-span">
    175 <#text><selection-anchor>world<selection-focus></#text>
    176 </SPAN>
    177 <#text> WebKit</#text>
    178 </SPAN>
     119| "hello, "
     120| <span>
     121|   class="Apple-style-span"
     122|   style="background-color: blue;"
     123|   "<#selection-anchor>world<#selection-focus>"
     124| " WebKit"
    179125
    180126hiliteColor last:
    181 <SPAN contentEditable="">
    182 <#text>hello, world</#text>
    183 <SPAN style="background-color: blue;" class="Apple-style-span">
    184 <#text><selection-anchor> WebKit<selection-focus></#text>
    185 </SPAN>
    186 </SPAN>
     127| "hello, world"
     128| <span>
     129|   class="Apple-style-span"
     130|   style="background-color: blue;"
     131|   "<#selection-anchor> WebKit<#selection-focus>"
    187132
    188133hiliteColor all:
    189 <SPAN contentEditable="">
    190 <SPAN style="background-color: blue;" class="Apple-style-span">
    191 <#text><selection-anchor>hello, world WebKit<selection-focus></#text>
    192 </SPAN>
    193 </SPAN>
     134| <span>
     135|   class="Apple-style-span"
     136|   style="background-color: blue;"
     137|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
    194138
    195139subscript first:
    196 <SPAN contentEditable="">
    197 <SUB>
    198 <#text><selection-anchor>hello, <selection-focus></#text>
    199 </SUB>
    200 <#text>world WebKit</#text>
    201 </SPAN>
     140| <sub>
     141|   "<#selection-anchor>hello, <#selection-focus>"
     142| "world WebKit"
    202143
    203144subscript middle:
    204 <SPAN contentEditable="">
    205 <#text>hello, </#text>
    206 <SUB>
    207 <#text><selection-anchor>world<selection-focus></#text>
    208 </SUB>
    209 <#text> WebKit</#text>
    210 </SPAN>
     145| "hello, "
     146| <sub>
     147|   "<#selection-anchor>world<#selection-focus>"
     148| " WebKit"
    211149
    212150subscript last:
    213 <SPAN contentEditable="">
    214 <#text>hello, world</#text>
    215 <SUB>
    216 <#text><selection-anchor> WebKit<selection-focus></#text>
    217 </SUB>
    218 </SPAN>
     151| "hello, world"
     152| <sub>
     153|   "<#selection-anchor> WebKit<#selection-focus>"
    219154
    220155subscript all:
    221 <SPAN contentEditable="">
    222 <SUB>
    223 <#text><selection-anchor>hello, world WebKit<selection-focus></#text>
    224 </SUB>
    225 </SPAN>
     156| <sub>
     157|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
    226158
    227159superscript first:
    228 <SPAN contentEditable="">
    229 <SUP>
    230 <#text><selection-anchor>hello, <selection-focus></#text>
    231 </SUP>
    232 <#text>world WebKit</#text>
    233 </SPAN>
     160| <sup>
     161|   "<#selection-anchor>hello, <#selection-focus>"
     162| "world WebKit"
    234163
    235164superscript middle:
    236 <SPAN contentEditable="">
    237 <#text>hello, </#text>
    238 <SUP>
    239 <#text><selection-anchor>world<selection-focus></#text>
    240 </SUP>
    241 <#text> WebKit</#text>
    242 </SPAN>
     165| "hello, "
     166| <sup>
     167|   "<#selection-anchor>world<#selection-focus>"
     168| " WebKit"
    243169
    244170superscript last:
    245 <SPAN contentEditable="">
    246 <#text>hello, world</#text>
    247 <SUP>
    248 <#text><selection-anchor> WebKit<selection-focus></#text>
    249 </SUP>
    250 </SPAN>
     171| "hello, world"
     172| <sup>
     173|   "<#selection-anchor> WebKit<#selection-focus>"
    251174
    252175superscript all:
    253 <SPAN contentEditable="">
    254 <SUP>
    255 <#text><selection-anchor>hello, world WebKit<selection-focus></#text>
    256 </SUP>
    257 </SPAN>
     176| <sup>
     177|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
    258178
    259179createLink first:
    260 <SPAN contentEditable="">
    261 <A href="http://webkit.org/">
    262 <#text><selection-anchor>hello, <selection-focus></#text>
    263 </A>
    264 <#text>world WebKit</#text>
    265 </SPAN>
     180| <a>
     181|   href="http://webkit.org/"
     182|   "<#selection-anchor>hello, <#selection-focus>"
     183| "world WebKit"
    266184
    267185createLink middle:
    268 <SPAN contentEditable="">
    269 <#text>hello, </#text>
    270 <A href="http://webkit.org/">
    271 <#text><selection-anchor>world<selection-focus></#text>
    272 </A>
    273 <#text> WebKit</#text>
    274 </SPAN>
     186| "hello, "
     187| <a>
     188|   href="http://webkit.org/"
     189|   "<#selection-anchor>world<#selection-focus>"
     190| " WebKit"
    275191
    276192createLink last:
    277 <SPAN contentEditable="">
    278 <#text>hello, world</#text>
    279 <A href="http://webkit.org/">
    280 <#text><selection-anchor> WebKit<selection-focus></#text>
    281 </A>
    282 </SPAN>
     193| "hello, world"
     194| <a>
     195|   href="http://webkit.org/"
     196|   "<#selection-anchor> WebKit<#selection-focus>"
    283197
    284198createLink all:
    285 <SPAN contentEditable="">
    286 <A href="http://webkit.org/">
    287 <#text><selection-anchor>hello, world WebKit<selection-focus></#text>
    288 </A>
    289 </SPAN>
     199| <a>
     200|   href="http://webkit.org/"
     201|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
  • trunk/LayoutTests/editing/undo/redo-split-text-node-expected.txt

    r64034 r64303  
    33
    44before undo:
    5 <DIV id="test" contentEditable="">
    6 <B>
    7 <#text><selection-anchor>he<selection-focus></#text>
    8 </B>
    9 <DIV>
    10 <#text>llo</#text>
    11 </DIV>
    12 </DIV>
     5| <b>
     6|   "<#selection-anchor>he<#selection-focus>"
     7| <div>
     8|   "llo"
    139
    1410after undo:
    15 <DIV id="test" contentEditable="">
    16 <#text>he<selection-caret>llo</#text>
    17 </DIV>
     11| "he<#selection-caret>llo"
    1812
    1913after redo:
    20 <DIV id="test" contentEditable="">
    21 <B>
    22 <#text><selection-anchor>he<selection-focus></#text>
    23 </B>
    24 <DIV>
    25 <#text>llo</#text>
    26 </DIV>
    27 </DIV>
     14| <b>
     15|   "<#selection-anchor>he<#selection-focus>"
     16| <div>
     17|   "llo"
  • trunk/LayoutTests/editing/undo/redo-split-text-with-removal-expected.txt

    r64034 r64303  
    33
    44before undo:
    5 <DIV id="test" contentEditable="">
    6 <B>
    7 <#text><selection-anchor>he<selection-focus></#text>
    8 </B>
    9 <DIV>
    10 <#text>llo</#text>
    11 </DIV>
    12 </DIV>
     5| <b>
     6|   "<#selection-anchor>he<#selection-focus>"
     7| <div>
     8|   "llo"
    139
    1410after undo:
    15 <DIV id="test" contentEditable="">
    16 <#text>he<selection-caret>llo</#text>
    17 </DIV>
     11| "he<#selection-caret>llo"
    1812
    1913after node removal:
    20 <DIV id="test" contentEditable="">
    21 </DIV>
     14|
    2215
    2316after redo:
    24 <DIV id="test" contentEditable="">
    25 <DIV>
    26 <#text>hello</#text>
    27 </DIV>
    28 </DIV>
     17| <div>
     18|   "hello"
  • trunk/LayoutTests/html5lib/runner.html

    r63872 r64303  
    2222-->
    2323<title>html5lib test runner</title>
    24 <script src=resources/dom2string.js></script>
    25 <script>
    26 if (window.layoutTestController)
    27     layoutTestController.dumpAsText();
    28 </script>
     24<script src=../resources/dump-as-markup.js></script>
    2925<style>
    3026.overview:hover {
     
    3834<iframe></iframe>
    3935<script>
     36Markup.noAutoDump();
     37
    4038var test_files = [
    4139        'resources/tests1.dat',
     
    229227function process_result(input, result, expected)
    230228{
    231     result = dom2string(result);
     229    result = Markup.get(result);
    232230    if (result !== expected)
    233231    {
  • trunk/LayoutTests/html5lib/webkit-resumer.html

    r60253 r64303  
    2121// THE SOFTWARE.
    2222</script>
    23 <script>
    24 String.prototype.toAsciiLowerCase = function () {
    25   var output = "";
    26   for (var i = 0, len = this.length; i < len; ++i) {
    27     if (this.charCodeAt(i) >= 0x41 && this.charCodeAt(i) <= 0x5A) {
    28       output += String.fromCharCode(this.charCodeAt(i) + 0x20)
    29     } else {
    30       output += this.charAt(i);
    31     }
    32   }
    33   return output;
    34 }
    35 
    36 function indent(ancestors) {
    37   var str = "";
    38   if (ancestors > 0) {
    39     while (ancestors--)
    40       str += "  ";
    41   }
    42   return str;
    43 }
    44 
    45 function dom2string(node, ancestors) {
    46   var str = "";
    47   if (typeof ancestors == "undefined")
    48     var ancestors = 0;
    49   if (!node.firstChild)
    50     return "| ";
    51   var parent = node;
    52   var current = node.firstChild;
    53   var next = null;
    54   var misnested = null;
    55   for (;;) {
    56     str += "\n| " + indent(ancestors);
    57     switch (current.nodeType) {
    58       case 10:
    59         str += '<!DOCTYPE ' + current.nodeName + '>';
    60         break;
    61       case 8:
    62         try {
    63           str += '<!-- ' + current.nodeValue + ' -->';
    64         } catch (e) {
    65           str += '<!--  -->';
    66         }
    67         if (parent != current.parentNode) {
    68           return str += ' (misnested... aborting)';
    69         }
    70         break;
    71       case 7:
    72         str += '<?' + current.nodeName + current.nodeValue + '>';
    73         break;
    74       case 4:
    75         str += '<![CDATA[ ' + current.nodeValue + ' ]]>';
    76         break;
    77       case 3:
    78         str += '"' + current.nodeValue + '"';
    79         if (parent != current.parentNode) {
    80           return str += ' (misnested... aborting)';
    81         }
    82         break;
    83       case 1:
    84         str += "<";
    85         switch (current.namespaceURI) {
    86           case "http://www.w3.org/2000/svg":
    87             str += "svg ";
    88             break;
    89           case "http://www.w3.org/1998/Math/MathML":
    90             str += "math ";
    91             break;
    92         }
    93         if (current.localName && current.namespaceURI && current.namespaceURI != null) {
    94           str += current.localName;
    95         } else {
    96           str += current.nodeName.toAsciiLowerCase();
    97         }
    98         str += '>';
    99         if (parent != current.parentNode) {
    100           return str += ' (misnested... aborting)';
    101         } else {
    102           if (current.attributes) {
    103             var attrNames = [];
    104             var attrPos = {};
    105             for (var j = 0; j < current.attributes.length; j += 1) {
    106               if (current.attributes[j].specified) {
    107                 var name = "";
    108                 switch (current.attributes[j].namespaceURI) {
    109                   case "http://www.w3.org/XML/1998/namespace":
    110                     name += "xml ";
    111                     break;
    112                   case "http://www.w3.org/2000/xmlns/":
    113                     name += "xmlns ";
    114                     break;
    115                   case "http://www.w3.org/1999/xlink":
    116                     name += "xlink ";
    117                     break;
    118                 }
    119                 if (current.attributes[j].localName) {
    120                   name += current.attributes[j].localName;
    121                 } else {
    122                   name += current.attributes[j].nodeName;
    123                 }
    124                 attrNames.push(name);
    125                 attrPos[name] = j;
    126               }
    127             }
    128             if (attrNames.length > 0) {
    129               attrNames.sort();
    130               for (var j = 0; j < attrNames.length; j += 1) {
    131                 str += "\n| " + indent(1 + ancestors) + attrNames[j];
    132                 str += '="' + current.attributes[attrPos[attrNames[j]]].nodeValue + '"';
    133               }
    134             }
    135           }
    136           if (next = current.firstChild) {
    137             parent = current;
    138             current = next;
    139             ancestors++;
    140             continue;
    141           }
    142         }
    143         break;
    144     }
    145     for (;;) {
    146       if (next = current.nextSibling) {
    147         current = next;
    148         break;
    149       }
    150       current = current.parentNode;
    151       parent = parent.parentNode;
    152       ancestors--;
    153       if (current == node) {
    154         return str.substring(1);
    155       }
    156     }
    157   }
    158 }
    159 </script>
    160 <script>
    161 if (window.layoutTestController)
    162     layoutTestController.dumpAsText();
    163 </script>
     23<script src=../resources/dump-as-markup.js></script>
    16424<style>
    16525.overview:hover {
     
    17333<iframe></iframe>
    17434<script>
     35Markup.noAutoDump();
     36
    17537var test_files = [
    17638        // 'resources/tests1.dat',
     
    358220function process_result(input, result, expected, async)
    359221{
    360     result = dom2string(result);
     222    result = Markup.get(result);
    361223    if (result !== expected)
    362224    {
  • trunk/LayoutTests/resources/dump-as-markup.js

    r64083 r64303  
    1515 */
    1616
    17 if (window.layoutTestController) {
     17if (window.layoutTestController)
    1818    layoutTestController.dumpAsText();
    19     layoutTestController.waitUntilDone();
    20 }
    2119
    2220// Namespace
     21// FIXME: Rename dump-as-markup.js to dump-dom.js and Markup to DOM.
    2322var Markup = {};
    2423
     
    3736        opt_node = document.getElementById(opt_node);
    3837
    39     var node = opt_node || Markup._node || document.body.parentElement
     38    var node = opt_node || Markup._node || document
    4039    var markup = "";
    4140
     
    5251        if (Markup._dumpCalls > 1)
    5352            markup += '\n';
    54         markup += '\n' + opt_description + ':';
     53        markup += '\n' + opt_description + ':\n';
    5554    }
    5655
     
    6059        Markup._container = document.createElement('pre');
    6160        Markup._container.style.width = '100%';
    62         document.body.appendChild(Markup._container);
    6361    }
    6462
     
    7573    }
    7674
    77     Markup._container.innerText += markup;
     75    Markup._container.appendChild(document.createTextNode(markup));
     76}
     77
     78Markup.noAutoDump = function()
     79{
     80    window.removeEventListener('load', Markup.notifyDone, false);
    7881}
    7982
    8083Markup.waitUntilDone = function()
    8184{
    82     window.removeEventListener('load', Markup.notifyDone, false);
     85    layoutTestController.waitUntilDone();
     86    Markup.noAutoDump();
    8387}
    8488
    8589Markup.notifyDone = function()
    8690{
     91    // Need to waitUntilDone or some tests won't finish appending the markup before the text is dumped.
     92    layoutTestController.waitUntilDone();
    8793    Markup._done = true;
    8894
     
    94100    // clobber the test itself. But when in layout test mode, we don't want
    95101    // side effects from the test to be included in the results.
    96     if (window.layoutTestController)
    97         document.body.innerText = Markup._container.innerText;
     102    if (window.layoutTestController) {
     103        document.body.innerHTML = '';
     104        document.body.appendChild(Markup._container);
     105    }
    98106
    99107    if (window.layoutTestController)
     
    108116}
    109117
     118Markup.get = function(node)
     119{
     120    if (!node.firstChild)
     121        return '| ';
     122
     123    // Don't print any markup for the root node.
     124    var markup = '';
     125    for (var i = 0, len = node.childNodes.length; i < len; i++) {
     126        markup += Markup._get(node.childNodes[i], 0);
     127    }
     128    return markup.substring(1);
     129}
     130
    110131// Returns the markup for the given node. To be used for cases where a test needs
    111132// to get the markup but not clobber the whole page.
    112 Markup.get = function(node, opt_depth)
    113 {
    114     var depth = opt_depth || 0;
    115 
    116     var attrs = Markup._getAttributes(node);
    117     var attrsString = attrs.length ? ' ' + attrs.join(' ') : '';
    118 
    119     var nodeName = node.nodeName;
    120     var markup = '<' + nodeName + attrsString + '>';
    121 
    122     var isSpecialNode = Markup._FORBIDS_END_TAG[nodeName];
    123     var innerMarkup = '';
    124     switch (nodeName) {
    125         case '#text':
    126         case 'STYLE':
    127         case 'SCRIPT':
    128         case 'IFRAME':
    129         case 'TEXTAREA':
    130         case 'XMP':
    131             innerMarkup = nodeName == '#text' ? Markup._getMarkupForTextNode(node) : node.innerText;
    132             innerMarkup = innerMarkup.replace(/\n/g, '\n' + Markup._spaces(depth))
    133             isSpecialNode = true;
    134             break;
    135        
    136         default:
    137             for (var i = 0, len = node.childNodes.length; i < len; i++) {
    138                 innerMarkup += Markup._getSelectionMarker(node, i);
    139                 innerMarkup += Markup.get(node.childNodes[i], depth + 1);
     133Markup._get = function(node, depth)
     134{
     135    var str = Markup._indent(depth);
     136
     137    switch (node.nodeType) {
     138    case 10:
     139        str += '<!DOCTYPE ' + node.nodeName;
     140        if (node.publicId || node.systemId) {
     141            str += ' "' + node.publicId + '"';
     142            str += ' "' + node.systemId + '"';
     143        }
     144        str += '>';
     145        break;
     146
     147    case 8:
     148        try {
     149            str += '<!-- ' + node.nodeValue + ' -->';
     150        } catch (e) {
     151            str += '<!--  -->';
     152        }
     153        break;
     154
     155    case 7:
     156        str += '<?' + node.nodeName + node.nodeValue + '>';
     157        break;
     158
     159    case 4:
     160        str += '<![CDATA[ ' + node.nodeValue + ' ]]>';
     161        break;
     162
     163    case 3:
     164        str += '"' + Markup._getMarkupForTextNode(node) + '"';
     165        break;
     166
     167    case 1:
     168        str += "<";
     169        str += Markup._namespace(node)
     170
     171        if (node.localName && node.namespaceURI && node.namespaceURI != null)
     172            str += node.localName;
     173        else
     174            str += Markup._toAsciiLowerCase(node.nodeName);
     175
     176        str += '>';
     177
     178        if (node.attributes) {
     179            var attrNames = [];
     180            var attrPos = {};
     181            for (var j = 0; j < node.attributes.length; j += 1) {
     182                if (node.attributes[j].specified) {
     183                    var name = Markup._namespace(node.attributes[j])
     184                    name += node.attributes[j].localName || node.attributes[j].nodeName;
     185                    attrNames.push(name);
     186                    attrPos[name] = j;
     187                }
    140188            }
    141             innerMarkup += Markup._getSelectionMarker(node, i);
    142     }
    143 
    144     markup = '\n' + Markup._spaces(depth) + markup
    145     if (!isSpecialNode)
    146         innerMarkup += '\n' + Markup._spaces(depth);
    147 
    148     markup += innerMarkup;
     189            if (attrNames.length > 0) {
     190              attrNames.sort();
     191              for (var j = 0; j < attrNames.length; j += 1) {
     192                str += Markup._indent(depth + 1) + attrNames[j];
     193                str += '="' + node.attributes[attrPos[attrNames[j]]].nodeValue + '"';
     194              }
     195            }
     196        }
     197        break;
     198    }
     199
     200    for (var i = 0, len = node.childNodes.length; i < len; i++) {
     201        var selection = Markup._getSelectionMarker(node, i);
     202        if (selection)
     203            str += Markup._indent(depth + 1) + selection;
     204
     205        str += Markup._get(node.childNodes[i], depth + 1);
     206    }
    149207   
    150     if (!Markup._FORBIDS_END_TAG[nodeName])
    151         markup += '</' + nodeName + '>';
    152 
    153     return markup;
     208    var selection = Markup._getSelectionMarker(node, i);
     209    if (selection)
     210        str += Markup._indent(depth + 1) + selection;
     211
     212    return str;
     213}
     214
     215Markup._namespace = function(node)
     216{
     217    if (Markup._NAMESPACE_URI_MAP[node.namespaceURI])
     218        return Markup._NAMESPACE_URI_MAP[node.namespaceURI] + ' ';
     219    return '';
    154220}
    155221
    156222Markup._dumpCalls = 0
    157223
    158 Markup._spaces = function(multiplier)
    159 {
    160     return new Array(multiplier * 4 + 1).join(' ');
    161 }
    162 
    163 // FIXME: Is there a better way to do this than a hard coded list?
    164 Markup._DUMP_AS_MARKUP_PROPERTIES = ['src', 'type', 'href', 'style', 'class', 'id', 'color', 'bgcolor', 'contentEditable'];
    165 
    166 Markup._getAttributes = function(node)
    167 {
    168     var props = [];
    169     if (!node.hasAttribute)
    170         return props;
    171 
    172     for (var i = 0; i < Markup._DUMP_AS_MARKUP_PROPERTIES.length; i++) {
    173         var attr = Markup._DUMP_AS_MARKUP_PROPERTIES[i];
    174         if (node.hasAttribute(attr)) {
    175             props.push(attr + '="' + node.getAttribute(attr) + '"');
    176         }
    177     }
    178     return props;
    179 }
    180 
    181 // This list should match all HTML elements that return TagStatusForbidden for endTagRequirement().
    182 Markup._FORBIDS_END_TAG = {
    183     'META': 1,
    184     'HR': 1,
    185     'AREA': 1,
    186     'LINK': 1,
    187     'WBR': 1,
    188     'BR': 1,
    189     'BASE': 1,
    190     'TABLECOL': 1,
    191     'SOURCE': 1,
    192     'INPUT': 1,
    193     'PARAM': 1,
    194     'EMBED': 1,
    195     'FRAME': 1,
    196     'CANVAS': 1,
    197     'IMG': 1,
    198     'ISINDEX': 1,
    199     'BASEFONT': 1,
    200     'DATAGRIDCELL': 1,
    201     'DATAGRIDCOL': 1
     224Markup._indent = function(depth)
     225{
     226    return "\n| " + new Array(depth * 2 + 1).join(' ');
     227}
     228
     229Markup._toAsciiLowerCase = function (str) {
     230  var output = "";
     231  for (var i = 0, len = this.length; i < len; ++i) {
     232    if (str.charCodeAt(i) >= 0x41 && str.charCodeAt(i) <= 0x5A)
     233      output += String.fromCharCode(str.charCodeAt(i) + 0x20)
     234    else
     235      output += str.charAt(i);
     236  }
     237  return output;
     238}
     239
     240Markup._NAMESPACE_URI_MAP = {
     241    "http://www.w3.org/2000/svg": "svg",
     242    "http://www.w3.org/1998/Math/MathML": "math",
     243    "http://www.w3.org/XML/1998/namespace": "xml",
     244    "http://www.w3.org/2000/xmlns/": "xmlns",
     245    "http://www.w3.org/1999/xlink": "xlink"
    202246}
    203247
     
    206250    return node.ownerDocument.defaultView.getSelection();
    207251}
     252
     253Markup._SELECTION_FOCUS = '<#selection-focus>';
     254Markup._SELECTION_ANCHOR = '<#selection-anchor>';
     255Markup._SELECTION_CARET = '<#selection-caret>';
    208256
    209257Markup._getMarkupForTextNode = function(node)
     
    216264        if (sel.isCollapsed) {
    217265            startOffset = sel.anchorOffset;
    218             startText = '<selection-caret>';
     266            startText = Markup._SELECTION_CARET;
    219267        } else {
    220268            if (sel.focusOffset > sel.anchorOffset) {
    221269                startOffset = sel.anchorOffset;
    222270                endOffset = sel.focusOffset;
    223                 startText = '<selection-anchor>';
    224                 endText = '<selection-focus>';
     271                startText = Markup._SELECTION_ANCHOR;
     272                endText = Markup._SELECTION_FOCUS;
    225273            } else {
    226274                startOffset = sel.focusOffset;
    227275                endOffset = sel.anchorOffset;
    228                 startText = '<selection-focus>';
    229                 endText = '<selection-anchor>';                       
     276                startText = Markup._SELECTION_FOCUS;
     277                endText = Markup._SELECTION_ANCHOR;
    230278            }
    231279        }
    232280    } else if (node == sel.focusNode) {
    233281        startOffset = sel.focusOffset;
    234         startText = '<selection-focus>';
     282        startText = Markup._SELECTION_FOCUS;
    235283    } else if (node == sel.anchorNode) {
    236284        startOffset = sel.anchorOffset;
    237         startText = '<selection-anchor>';
     285        startText = Markup._SELECTION_ANCHOR;
    238286    }
    239287   
     
    248296Markup._getSelectionMarker = function(node, index)
    249297{
     298    if (node.nodeType != 1)
     299        return '';
     300
    250301    var sel = Markup._getSelectionFromNode(node);;
    251302    if (index == sel.anchorOffset && node == sel.anchorNode) {
    252303        if (sel.isCollapsed)
    253             return '<selection-caret>';
     304            return Markup._SELECTION_CARET;
    254305        else
    255             return '<selection-anchor>';
     306            return Markup._SELECTION_ANCHOR;
    256307    } else if (index == sel.focusOffset && node == sel.focusNode)
    257         return '<selection-focus>';
     308        return Markup._SELECTION_FOCUS;
    258309
    259310    return '';
Note: See TracChangeset for help on using the changeset viewer.