editor/reftests/388980-1.html
author Chris Peterson <cpeterson@mozilla.com>
Sun, 03 Sep 2017 22:14:11 -0700
changeset 382613 c81b52d58ea4df9c46c0bf46a89e9f1dbb532fe5
parent 92937 42c372c2f7493b79f79c58150b5531d23e74ca61
permissions -rw-r--r--
Bug 870698 - Part 2: Replace Append("") with AppendLiteral(""). r=erahm MozReview-Commit-ID: CrkIP4iHP1U

<html>
<head>
<title>Reftest for bug 388980</title></html>
<script type="text/javascript">

var text = '<html><head></head><body style="font-size:16px;">'
	+ '<p id="redpar">This paragraph should be red</p>'
	+ '<p id="bluepar">This paragraph should be blue</p>'
	+ '<p>This paragraph should not be colored</p>'
	+'</body></html>';


function colorPar(par, color) {
	var doc = document.getElementById('theIFrame').contentDocument;
	var win = document.getElementById('theIFrame').contentWindow;
	win.getSelection().selectAllChildren(doc.getElementById(par));
	doc.execCommand("hilitecolor", false, color);
	win.getSelection().removeAllRanges();
}	
	
function initIFrame() {
	var doc = document.getElementById('theIFrame').contentDocument;
	doc.designMode = 'on';
	doc.open('text/html');
	doc.write(text);
	doc.close();
	
	// Test hilighting with styleWithCSS, should hilight the text...
	doc.execCommand("styleWithCSS", false, true);
	colorPar("redpar", "red");

	// Test highlighting without styleWithCSS, should also work.
	doc.execCommand("styleWithCSS", false, false);
	colorPar("bluepar", "blue");

}
</script>
</head>
<body>
<iframe id="theIFrame" onload="initIFrame()">
</iframe>
</body>
</html>