dom/base/test/test_bug366946.html
author Nicholas Nethercote <nnethercote@mozilla.com>
Mon, 05 Oct 2015 16:59:32 -0700
changeset 301715 3897da20e42dec0bcf73987af1eaac4f8ce950b8
parent 238779 2db29c0ae60b6eb0e196165631127d195fe2ef0b
child 531525 ba6f655fd68963530c866d0d4a48c3db3d307777
permissions -rw-r--r--
Bug 1211324 (part 3) - Remove GraphicsFilter::FILTER_FAST and replace it with FILTER_BEST. r=mattwoodrow. This may sound like an odd change but it's what the current code effectively already does due to the way ToFilter() and ThebesFilter() are defined.

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=366946
-->
<head>
  <title>Test for Bug 366946</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=366946">Mozilla Bug 366946</a>
<p id="display"></p>
<div id="content" style="display: none">
  <div id="1"></div>
  <div id="2"></div>
  <div id="3"></div>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
  /** Test for Bug 366946 **/
  SimpleTest.waitForExplicitFinish();

  addLoadEvent(function() {
    var doc1 = document;

    // Set up a new document.
    var doc2 = document.implementation.createDocument('', '', null);

    // Copy some nodes into doc2
    var node1 = doc2.importNode(doc1.getElementById('1'), false);
    var node2 = doc2.importNode(doc1.getElementById('1'), false);
    node1.appendChild(node2);
    doc2.appendChild(node1);

    // Create two ranges in doc1 to compare.
    var range1 = doc1.createRange();
    range1.setStart(doc1.getElementById('1'), 0);
    range1.setEnd(doc1.getElementById('2'), 0);
    
    var range2 = doc1.createRange();
    range2.setStart(doc1.getElementById('2'), 0);
    range2.setEnd(doc1.getElementById('3'), 0);

    // Create a range in doc2.
    var range3 = doc2.createRange();
    range3.setStart(node1, 0);
    range3.setEnd(node2, 0);

    // Compare range1 and range2: Should return 1.
    try {
      var result1 = range2.compareBoundaryPoints(Range.START_TO_START, range1);
    }
    catch (ex) {
    }
    ok(result1 ===  1, "range1 and range2 are compared correctly.");

    // Compare range1 and range3: Should throw DOMException WRONG_DOCUMENT_ERR.
    try {
      var result2 = range3.compareBoundaryPoints(Range.START_TO_START, range1);
    }
    catch (ex) {
      var error = ex.name;
      var errorCode = ex.code;
    }

    ok(error == "WrongDocumentError",
      "The WrongDocumentError exception thrown when comparing ranges from " +
      "different documents ");
    ok(errorCode == DOMException.WRONG_DOCUMENT_ERR,
      "The exception thrown when comparing ranges from different documents " +
      "has the code DOMException.WRONG_DOCUMENT_ERR");
    ok(result2 === undefined, "range1 and range3 couldn't be compared as expected.");
    SimpleTest.finish();
  });
</script>
</pre>
</body>
</html>