Changeset 63781 in webkit


Ignore:
Timestamp:
Jul 20, 2010 3:39:24 PM (14 years ago)
Author:
ojan@chromium.org
Message:

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

Reviewed by Darin Adler.

make dump-as-markup work better on subframes and allow dumping a subtree
https://bugs.webkit.org/show_bug.cgi?id=42673

  • editing/selection/dump-as-markup-expected.txt:
  • editing/selection/dump-as-markup.html:
  • resources/dump-as-markup.js: (Markup.description): (Markup._getSelectionFromNode): (Markup._getMarkupForTextNode): (Markup._getSelectionMarker):
Location:
trunk/LayoutTests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r63780 r63781  
     12010-07-20  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        make dump-as-markup work better on subframes and allow dumping a subtree
     6        https://bugs.webkit.org/show_bug.cgi?id=42673
     7
     8        * editing/selection/dump-as-markup-expected.txt:
     9        * editing/selection/dump-as-markup.html:
     10        * resources/dump-as-markup.js:
     11        (Markup.description):
     12        (Markup._getSelectionFromNode):
     13        (Markup._getMarkupForTextNode):
     14        (Markup._getSelectionMarker):
     15
    1162010-07-20  Daniel Erat  <derat@chromium.org>
    217
  • trunk/LayoutTests/editing/selection/dump-as-markup-expected.txt

    r58335 r63781  
     1Tests basic dump-as-markup functionality.
    12
    23<HTML>
     
    5455</#text>
    5556<SCRIPT>
     57Markup.description("Tests basic dump-as-markup functionality.");
    5658window.getSelection().selectAllChildren(bar)
    5759</SCRIPT>
     
    6264
    6365FRAME 0:
    64 FIXME: Add method to layout test controller to get access to cross-origin frames.
     66
     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>
  • trunk/LayoutTests/editing/selection/dump-as-markup.html

    r58331 r63781  
    1212
    1313<script>
     14Markup.description("Tests basic dump-as-markup functionality.");
    1415window.getSelection().selectAllChildren(bar)
    1516</script>
  • trunk/LayoutTests/resources/dump-as-markup.js

    r58331 r63781  
    77var Markup = {};
    88
    9 /**
    10  * Dumps the markup for the given node (HTML element if no node is given).
    11  * Over-writes the body's content with the markup in layout test mode. Appends
    12  * a pre element when loaded manually, in order to aid debugging.
    13  */
     9// The description of what this test is testing. Gets prepended to the dumped markup.
     10Markup.description = function(description)
     11{
     12    Markup._description = description;
     13}
     14
     15// Dumps the markup for the given node (HTML element if no node is given).
     16// Over-writes the body's content with the markup in layout test mode. Appends
     17// a pre element when loaded manually, in order to aid debugging.
    1418Markup.dump = function(opt_node)
    1519{
     
    1822        opt_node = undefined;
    1923
    20     var markup = Markup.get(opt_node);
     24    var node = opt_node || document.body.parentElement
     25
     26    var markup = Markup._description ? Markup._description + '\n' : "";
     27    markup += Markup.get(node);
     28
    2129    var container;
    2230    if (window.layoutTestController)
     
    3240
    3341    // FIXME: Have this respect layoutTestController.dumpChildFramesAsText?
    34     for (var i = 0; i < window.frames.length; i++) {
     42    // FIXME: Should we care about framesets?
     43    var iframes = node.getElementsByTagName('iframe');
     44    for (var i = 0; i < iframes.length; i++) {
    3545        markup += '\n\nFRAME ' + i + ':\n'
    3646        try {
    37             markup += Markup.get(window.frames[i].contentDocument.body.parentElement);
     47            markup += Markup.get(iframes[i].contentDocument.body.parentElement);
    3848        } catch (e) {
    3949            markup += 'FIXME: Add method to layout test controller to get access to cross-origin frames.';
     
    5767}
    5868
    59 /**
    60  * Returns the markup for the given node. To be used for cases where a test needs
    61  * to get the markup but not clobber the whole page.
    62  */
    63 Markup.get = function(opt_node, opt_depth)
    64 {
    65     var node = opt_node || document.body.parentElement
     69// Returns the markup for the given node. To be used for cases where a test needs
     70// to get the markup but not clobber the whole page.
     71Markup.get = function(node, opt_depth)
     72{
    6673    var depth = opt_depth || 0;
    6774
     
    152159}
    153160
     161Markup._getSelectionFromNode = function(node)
     162{
     163    return node.ownerDocument.defaultView.getSelection();
     164}
     165
    154166Markup._getMarkupForTextNode = function(node)
    155167{
     
    157169    var startOffset, endOffset, startText, endText;
    158170
    159     var sel = window.getSelection();
     171    var sel = Markup._getSelectionFromNode(node);
    160172    if (node == sel.anchorNode && node == sel.focusNode) {
    161173        if (sel.isCollapsed) {
     
    193205Markup._getSelectionMarker = function(node, index)
    194206{
    195     var sel = window.getSelection();
     207    var sel = Markup._getSelectionFromNode(node);;
    196208    if (index == sel.anchorOffset && node == sel.anchorNode) {
    197209        if (sel.isCollapsed)
Note: See TracChangeset for help on using the changeset viewer.