1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/html/tests/test_bug289384.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=289384 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 289384</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=289384">Mozilla Bug 289384</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script class="testbody" type="text/javascript"> 1.22 +SimpleTest.waitForExplicitFinish(); 1.23 + 1.24 +addLoadEvent(function() { 1.25 + var win = window.open("data:text/html,<a href=\"data:text/html,<body contenteditable onload='opener.continueTest(window);'>foo bar</body>\">link</a>", "", "test-289384"); 1.26 + win.addEventListener("load", function onLoad() { 1.27 + win.removeEventListener("load", onLoad); 1.28 + win.document.querySelector("a").click(); 1.29 + }, false); 1.30 +}); 1.31 + 1.32 +function continueTest(win) { 1.33 + SimpleTest.waitForFocus(function() { 1.34 + var doc = win.document; 1.35 + var sel = win.getSelection(); 1.36 + doc.body.focus(); 1.37 + sel.collapse(doc.body.firstChild, 3); 1.38 + SimpleTest.executeSoon(function() { 1.39 + synthesizeKey("VK_LEFT", {accelKey: true}, win); 1.40 + ok(sel.isCollapsed, "The selection must be collapsed"); 1.41 + is(sel.anchorNode, doc.body.firstChild, "The anchor node should be the body element's text node"); 1.42 + is(sel.anchorOffset, 0, "The anchor offset should be 0"); 1.43 + win.close(); 1.44 + SimpleTest.finish(); 1.45 + }); 1.46 + }, win); 1.47 +} 1.48 + 1.49 +</script> 1.50 +</pre> 1.51 +</body> 1.52 +</html>