gecko/layout/reftests/bugs/263683-1.html

73 lines
2.6 KiB
HTML

<!DOCTYPE html>
<html class="reftest-wait">
<head>
<title>Bug 263683 Layout Reftest</title>
<script type="text/javascript">
var userSet = false;
var userValue = null;
var prefName = "ui.textHighlightBackground";
function onLoad() {
// Request security privileges
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Get pref branch.
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
// Check to see if this pref has a user-set value. If so, store it
userSet = prefs.prefHasUserValue(prefName);
if (userSet)
userValue = prefs.getCharPref(prefName);
// Set pref to test colour used in reference file
prefs.setCharPref(prefName, "#f0e020");
var textToSelect = document.getElementById("selecttext");
// Get docshell
var docShell = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell);
// Get selection controller from docshell
var controller = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsISelectionDisplay)
.QueryInterface(Components.interfaces.nsISelectionController);
// Get selection
var findSelection = controller.getSelection(controller.SELECTION_FIND);
// Lastly add range
var range = document.createRange();
range.selectNodeContents(textToSelect);
findSelection.addRange(range);
document.documentElement.removeAttribute("class");
}
function onUnload() {
// Request security privileges
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Get the pref branch
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefs.clearUserPref(prefName);
if (!userSet)
return;
prefs.setCharPref(prefName, userValue);
}
</script>
</head>
<body style="color: #000000; background-color: #ffffff" onload="onLoad();" onunload="onUnload();">
<p>
The last word in this text should be <span id="selecttext">selected</span>
</p>
</body>
</html>