Test LayoutTests/fast/dom/Range/acid3-surround-contents.html Detail

id
LayoutTests/fast/dom/Range/acid3-surround-contents.html
type
layouttest
version
0
enabled
1
tags
flags
sections
url
http://localhost:8888/LayoutTests/fast/dom/Range/acid3-surround-contents.html
file
LayoutTests/fast/dom/Range/acid3-surround-contents.html

results
Firefox 2 Win (2.0.0.20) Firefox 2 Lin (2.0.0.20) Firefox 3 Win (3.0.6) Firefox 3 Lin (3.0.6) Firefox 3.1 Win (3.1b2) Firefox 3.1 Lin (3.1b2) Firefox trunk Win (2009 02 22) Firefox trunk Lin (2009 02 22) Safari 3 Win (3.2) Safari trunk Win (41121) Opera 9 Win (9.62) Opera 9 Lin (9.62) IE 6 Win (6) IE 7 Win (7) IE 8 Win (8rc1)
FAIL FAIL FAIL FAIL PASS PASS PASS PASS FAIL PASS FAIL FAIL FAIL FAIL FAIL

Layouttest detail

expected:
The test below should report no failures, and should say PASS at the end.

PASS

file:
<iframe src="empty.html" id="selectors" width=0 height=0 frameborder=0></iframe>
<p>The test below should report no failures, and should say PASS at the end.</p>
<script>
if (window.layoutTestController) {
    layoutTestController.dumpAsText();
}
</script>
<script>

  function getTestDocument() {
    var iframe = document.getElementById("selectors");
    var doc = iframe.contentDocument;
    for (var i = doc.documentElement.childNodes.length-1; i >= 0; i -= 1)
      doc.documentElement.removeChild(doc.documentElement.childNodes[i]);
    doc.documentElement.appendChild(doc.createElement('head'));
    doc.documentElement.firstChild.appendChild(doc.createElement('title'));
    doc.documentElement.appendChild(doc.createElement('body'));
    return doc;
  }

var failCount = 0;

  function fail(message) {
    document.write(message.replace("&", "&amp;").replace("<", "&lt;") + "<br>");
    ++failCount;
  }

  function assert(condition, message) {
    if (!condition)
      fail(message);
  }

  function assertEquals(expression, value, message) {
    if (expression != value) {
      expression = (""+expression).replace(/[\r\n]+/g, "\\n");
      value = (""+value).replace(/\r?\n/g, "\\n");
      fail("expected '" + value + "' but got '" + expression + "' - " + message);
    }
  }

      // test 11: Ranges and Comments
      var msg;
      var doc = getTestDocument();
      var c1 = doc.createComment("11111");
      doc.appendChild(c1);
      var r = doc.createRange();
      r.selectNode(c1);
      msg = 'wrong exception raised';
      try {
        r.surroundContents(doc.createElement('a'));
        msg = 'no exception raised';
      } catch (e) {
        if ('code' in e)
          msg += '; code = ' + e.code;
        if (e.code == 3)
          msg = '';
      }
      assert(msg == '', "when inserting <a> into Document with another child: " + msg);
      var c2 = doc.createComment("22222");
      doc.body.appendChild(c2);
      var c3 = doc.createComment("33333");
      doc.body.appendChild(c3);
      r.setStart(c2, 2);
      r.setEnd(c3, 3);
      var msg = 'wrong exception raised';
      try {
        r.surroundContents(doc.createElement('a'));
        msg = 'no exception raised';
      } catch (e) {
        if ('code' in e)
          msg += '; code = ' + e.code;
        if (e.code == 1)
          msg = '';
      }
      assert(msg == '', "when trying to surround two halves of comment: " + msg);
      assertEquals(r.toString(), "", "comments returned text");

if (failCount == 0)
  document.write("PASS<br>");
</script>

file frame show/hide: