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

83 lines
3.0 KiB
HTML

<!DOCTYPE html>
<html class="reftest-wait">
<head>
<title>Bug 263683 Layout Reftest</title>
<script type="text/javascript">
var userSetBG = false;
var userValueBG = null;
var prefNameBG = "ui.textHighlightBackground";
var userSetFG = false;
var userValueFG = null;
var prefNameFG = "ui.textHighlightForeground";
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
userSetFG = prefs.prefHasUserValue(prefNameFG);
userSetBG = prefs.prefHasUserValue(prefNameBG);
if (userSetFG)
userValueFG = prefs.getCharPref(prefNameFG);
if (userSetBG)
userValueBG = prefs.getCharPref(prefNameBG);
// Set pref to test colour used in reference file
prefs.setCharPref(prefNameBG, "#f0e020");
prefs.setCharPref(prefNameFG, "#000000");
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(prefNameFG);
prefs.clearUserPref(prefNameBG);
if (userSetFG)
prefs.setCharPref(prefNameFG, userValueFG);
if (userSetBG)
prefs.setCharPref(prefNameBG, userValueBG);
}
</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>