Bug 778420 - Initial stab at the tests. v2 r=bholley

--HG--
extra : rebase_source : e014ba90baa75ba3146f4e3fb5c447b87a8e83c0
This commit is contained in:
William Chen 2012-08-06 22:15:49 +02:00
Родитель 3ec06da029
Коммит 710c56850a
18 изменённых файлов: 77 добавлений и 119 удалений

Просмотреть файл

@ -26,6 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=462856
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
const Cc = SpecialPowers.wrap(Components).classes;
var numFinished = 0; var numFinished = 0;
@ -34,18 +35,17 @@ window.addEventListener("message", function(event) {
if (++numFinished == 3) { if (++numFinished == 3) {
// Clean up after ourself // Clean up after ourself
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var pm = Cc["@mozilla.org/permissionmanager;1"].
var pm = Components.classes["@mozilla.org/permissionmanager;1"].
getService(Components.interfaces.nsIPermissionManager); getService(Components.interfaces.nsIPermissionManager);
var ioService = Components.classes["@mozilla.org/network/io-service;1"] var ioService = Cc["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService); .getService(Components.interfaces.nsIIOService);
var uri1 = ioService.newURI(frames.testFrame.location, null, null); var uri1 = ioService.newURI(frames.testFrame.location, null, null);
var uri2 = ioService.newURI(frames.testFrame3.location, null, null); var uri2 = ioService.newURI(frames.testFrame3.location, null, null);
var principal1 = Components.classes["@mozilla.org/scriptsecuritymanager;1"] var principal1 = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager) .getService(Components.interfaces.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri1); .getNoAppCodebasePrincipal(uri1);
var principal2 = Components.classes["@mozilla.org/scriptsecuritymanager;1"] var principal2 = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager) .getService(Components.interfaces.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri2); .getNoAppCodebasePrincipal(uri2);
@ -108,8 +108,7 @@ function loaded() {
// Click the notification bar's "Allow" button. This should kick // Click the notification bar's "Allow" button. This should kick
// off updates, which will eventually lead to getting messages from // off updates, which will eventually lead to getting messages from
// the children. // the children.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var wm = SpecialPowers.wrap(Components).classes["@mozilla.org/appshell/window-mediator;1"].
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
getService(Components.interfaces.nsIWindowMediator); getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser"); var win = wm.getMostRecentWindow("navigator:browser");
var notificationBox = win.gBrowser.getNotificationBox(); var notificationBox = win.gBrowser.getNotificationBox();
@ -117,7 +116,7 @@ function loaded() {
var notification = notificationBox.getNotificationWithValue("offline-app-requested-mochi.test"); var notification = notificationBox.getNotificationWithValue("offline-app-requested-mochi.test");
notification.childNodes[0].click(); notification.childNodes[0].click();
notification = notificationBox.getNotificationWithValue("offline-app-requested-example.com"); notification = SpecialPowers.wrap(notificationBox).getNotificationWithValue("offline-app-requested-example.com");
notification.childNodes[0].click(); notification.childNodes[0].click();
} }

Просмотреть файл

@ -32,15 +32,13 @@ SimpleTest.waitForExplicitFinish();
function finishTest() { function finishTest() {
// Clean up after ourselves. // Clean up after ourselves.
netscape.security.PrivilegeManager var Cc = SpecialPowers.wrap(Components).classes;
.enablePrivilege("UniversalXPConnect"); var pm = Cc["@mozilla.org/permissionmanager;1"].
var pm = Components.classes["@mozilla.org/permissionmanager;1"].
getService(Components.interfaces.nsIPermissionManager); getService(Components.interfaces.nsIPermissionManager);
var uri = Components.classes["@mozilla.org/network/io-service;1"] var uri = Cc["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService)
.getService(Components.interfaces.nsIIOService)
.newURI(window.frames[0].location, null, null); .newURI(window.frames[0].location, null, null);
var principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] var principal = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager) .getService(Components.interfaces.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri); .getNoAppCodebasePrincipal(uri);
@ -70,8 +68,6 @@ function handleMessageEvents(event) {
// successfully reloaded), or the string "error" appears // successfully reloaded), or the string "error" appears
// in the iframe, as in the case of bug 501422. // in the iframe, as in the case of bug 501422.
intervalID = setInterval(function() { intervalID = setInterval(function() {
netscape.security.PrivilegeManager
.enablePrivilege("UniversalXPConnect");
// Sometimes document.body may not exist, and trying to access // Sometimes document.body may not exist, and trying to access
// it will throw an exception, so handle this case. // it will throw an exception, so handle this case.
try { try {
@ -103,8 +99,7 @@ function loaded() {
// Click the notification bar's "Allow" button. This should kick // Click the notification bar's "Allow" button. This should kick
// off updates, which will eventually lead to getting messages from // off updates, which will eventually lead to getting messages from
// the iframe. // the iframe.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var wm = SpecialPowers.wrap(Components).classes["@mozilla.org/appshell/window-mediator;1"].
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
getService(Components.interfaces.nsIWindowMediator); getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser"); var win = wm.getMostRecentWindow("navigator:browser");
var notificationBox = win.gBrowser.getNotificationBox(); var notificationBox = win.gBrowser.getNotificationBox();

Просмотреть файл

@ -20,8 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=589543
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
addLoadEvent(function() { addLoadEvent(function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var doc = SpecialPowers.wrap($("testFrame").contentDocument);
var doc = $("testFrame").contentDocument;
var daddy = doc.getElementById("feedSubscribeLine"); var daddy = doc.getElementById("feedSubscribeLine");
var popup = doc.getAnonymousElementByAttribute(daddy, "anonid", "handlersMenuPopup"); var popup = doc.getAnonymousElementByAttribute(daddy, "anonid", "handlersMenuPopup");
isnot(popup, null, "Feed preview should have a handlers popup"); isnot(popup, null, "Feed preview should have a handlers popup");

Просмотреть файл

@ -22,14 +22,13 @@
request.send(null); request.send(null);
// Try reading headers in privileged context // Try reading headers in privileged context
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); is(SpecialPowers.wrap(request).getResponseHeader("Set-Cookie"), "test", "Reading Set-Cookie response header in privileged context");
is(request.getResponseHeader("Set-Cookie"), "test", "Reading Set-Cookie response header in privileged context"); is(SpecialPowers.wrap(request).getResponseHeader("Set-Cookie2"), "test2", "Reading Set-Cookie2 response header in privileged context");
is(request.getResponseHeader("Set-Cookie2"), "test2", "Reading Set-Cookie2 response header in privileged context"); is(SpecialPowers.wrap(request).getResponseHeader("X-Dummy"), "test", "Reading X-Dummy response header in privileged context");
is(request.getResponseHeader("X-Dummy"), "test", "Reading X-Dummy response header in privileged context");
ok(/\bSet-Cookie:/i.test(request.getAllResponseHeaders()), "Looking for Set-Cookie in all response headers in privileged context"); ok(/\bSet-Cookie:/i.test(SpecialPowers.wrap(request).getAllResponseHeaders()), "Looking for Set-Cookie in all response headers in privileged context");
ok(/\bSet-Cookie2:/i.test(request.getAllResponseHeaders()), "Looking for Set-Cookie2 in all response headers in privileged context"); ok(/\bSet-Cookie2:/i.test(SpecialPowers.wrap(request).getAllResponseHeaders()), "Looking for Set-Cookie2 in all response headers in privileged context");
ok(/\bX-Dummy:/i.test(request.getAllResponseHeaders()), "Looking for X-Dummy in all response headers in privileged context"); ok(/\bX-Dummy:/i.test(SpecialPowers.wrap(request).getAllResponseHeaders()), "Looking for X-Dummy in all response headers in privileged context");
// Try reading headers in unprivileged context // Try reading headers in unprivileged context
setTimeout(function() { setTimeout(function() {

Просмотреть файл

@ -32,24 +32,23 @@ var input2Files =
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
function setFileInputs () { function setFileInputs () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
f = createFileWithData(input1File.name, input1File.body); f = createFileWithData(input1File.name, input1File.body);
singleFileInput.mozSetFileNameArray([f.path], 1); SpecialPowers.wrap(singleFileInput).mozSetFileNameArray([f.path], 1);
var input2FileNames = []; var input2FileNames = [];
for each (file in input2Files) { for each (file in input2Files) {
f = createFileWithData(file.name, file.body); f = createFileWithData(file.name, file.body);
input2FileNames.push(f.path); input2FileNames.push(f.path);
} }
multiFileInput.mozSetFileNameArray(input2FileNames, input2FileNames.length); SpecialPowers.wrap(multiFileInput).mozSetFileNameArray(input2FileNames, input2FileNames.length);
} }
function createFileWithData(fileName, fileData) { function createFileWithData(fileName, fileData) {
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"] var dirSvc = SpecialPowers.wrap(Components).classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties); .getService(Components.interfaces.nsIProperties);
var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile); var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
testFile.append(fileName); testFile.append(fileName);
var outStream = Components. var outStream = SpecialPowers.wrap(Components).
classes["@mozilla.org/network/file-output-stream;1"]. classes["@mozilla.org/network/file-output-stream;1"].
createInstance(Components.interfaces.nsIFileOutputStream); createInstance(Components.interfaces.nsIFileOutputStream);
outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate

Просмотреть файл

@ -55,9 +55,7 @@ function checkURI(uri, name, type) {
function checkFrame(num) { function checkFrame(num) {
// Just snarf our data // Just snarf our data
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var outer = SpecialPowers.wrap(window.frames[num]);
var outer = window.frames[num]
name = outer.name; name = outer.name;
is(outer.document.baseURI, is(outer.document.baseURI,

Просмотреть файл

@ -24,10 +24,9 @@ var frame = document.getElementById("i");
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
addLoadEvent(function() { addLoadEvent(function() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var viewer = var viewer =
frame.contentWindow SpecialPowers.wrap(frame.contentWindow
.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .QueryInterface(Components.interfaces.nsIInterfaceRequestor))
.getInterface(Components.interfaces.nsIWebNavigation) .getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell) .QueryInterface(Components.interfaces.nsIDocShell)
.contentViewer .contentViewer
@ -38,7 +37,6 @@ addLoadEvent(function() {
setTimeout(function() { setTimeout(function() {
synthesizeMouse(frame, 30, 30, {}); synthesizeMouse(frame, 30, 30, {});
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
is(viewer.fullZoom, 1.5, "Zoom in the image frame should not have been reset"); is(viewer.fullZoom, 1.5, "Zoom in the image frame should not have been reset");
SimpleTest.finish(); SimpleTest.finish();

Просмотреть файл

@ -116,9 +116,8 @@ function test5()
SimpleTest.executeSoon(function() { SimpleTest.executeSoon(function() {
// We have to focus back the originating window but we can't do that with // We have to focus back the originating window but we can't do that with
// .focus() or .blur() anymore. // .focus() or .blur() anymore.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var fm = SpecialPowers.wrap(Components).classes["@mozilla.org/focus-manager;1"]
var fm = Components.classes["@mozilla.org/focus-manager;1"]. .getService(Components.interfaces.nsIFocusManager);
getService(Components.interfaces.nsIFocusManager);
fm.focusedWindow = window; fm.focusedWindow = window;
}); });
}, w, true); }, w, true);
@ -126,8 +125,7 @@ function test5()
function finished() function finished()
{ {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); SpecialPowers.wrap(Components).classes["@mozilla.org/preferences-service;1"]
Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch) .getService(Components.interfaces.nsIPrefBranch)
.setBoolPref("dom.disable_window_flip", gOldPrefValue); .setBoolPref("dom.disable_window_flip", gOldPrefValue);
SimpleTest.finish(); SimpleTest.finish();
@ -137,8 +135,7 @@ SimpleTest.waitForExplicitFinish();
// dom.disable_window_flip has to be set to true for this test. // dom.disable_window_flip has to be set to true for this test.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var prefs = SpecialPowers.wrap(Components).classes["@mozilla.org/preferences-service;1"]
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch); .getService(Components.interfaces.nsIPrefBranch);
gOldPrefValue = prefs.getBoolPref("dom.disable_window_flip"); gOldPrefValue = prefs.getBoolPref("dom.disable_window_flip");
prefs.setBoolPref("dom.disable_window_flip", true); prefs.setBoolPref("dom.disable_window_flip", true);

Просмотреть файл

@ -153,8 +153,7 @@ function popstateExpected(msg) {
} }
function getColor(elem) { function getColor(elem) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var utils = SpecialPowers.wrap(document).defaultView.
var utils = document.defaultView.
QueryInterface(Components.interfaces.nsIInterfaceRequestor). QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils); getInterface(Components.interfaces.nsIDOMWindowUtils);
return utils.getVisitedDependentComputedStyle(elem, "", "color"); return utils.getVisitedDependentComputedStyle(elem, "", "color");
@ -162,10 +161,8 @@ function getColor(elem) {
function getSHistory(theWindow) function getSHistory(theWindow)
{ {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const Ci = Components.interfaces; const Ci = Components.interfaces;
var sh = theWindow.QueryInterface(Ci.nsIInterfaceRequestor) var sh = SpecialPowers.wrap(theWindow.QueryInterface(Ci.nsIInterfaceRequestor))
.getInterface(Ci.nsIWebNavigation) .getInterface(Ci.nsIWebNavigation)
.sessionHistory; .sessionHistory;
if (!sh || sh == null) if (!sh || sh == null)
@ -176,8 +173,6 @@ function getSHistory(theWindow)
function getSHTitle(sh, offset) function getSHTitle(sh, offset)
{ {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
if (!offset) if (!offset)
offset = 0; offset = 0;

Просмотреть файл

@ -22,8 +22,7 @@ var iframe = document.getElementById("load-frame");
function enableJS() allowJS(true, iframe); function enableJS() allowJS(true, iframe);
function disableJS() allowJS(false, iframe); function disableJS() allowJS(false, iframe);
function allowJS(allow, frame) { function allowJS(allow, frame) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); SpecialPowers.wrap(frame.contentWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor))
frame.contentWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation) .getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell) .QueryInterface(Components.interfaces.nsIDocShell)
.allowJavascript = allow; .allowJavascript = allow;

Просмотреть файл

@ -36,7 +36,7 @@ function editDoc() {
function getSpellCheckSelection() { function getSpellCheckSelection() {
var Ci = Components.interfaces; var Ci = Components.interfaces;
var win = editDoc().defaultView; var win = editDoc().defaultView;
var editingSession = win.QueryInterface(Ci.nsIInterfaceRequestor) var editingSession = SpecialPowers.wrap(win.QueryInterface(Ci.nsIInterfaceRequestor))
.getInterface(Ci.nsIWebNavigation) .getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIEditingSession); .getInterface(Ci.nsIEditingSession);
@ -51,7 +51,6 @@ function runTest() {
} }
function addWords(aLimit) { function addWords(aLimit) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
if (aLimit == 0) { if (aLimit == 0) {
is(isSpellingCheckOk(), true, "All misspellings accounted for."); is(isSpellingCheckOk(), true, "All misspellings accounted for.");
SimpleTest.finish(); SimpleTest.finish();

Просмотреть файл

@ -20,8 +20,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=468353
var styleSheets = null; var styleSheets = null;
function checkStylesheets() { function checkStylesheets() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
// Evidently RemoveStyleSheet is the only method in nsIEditorStyleSheets // Evidently RemoveStyleSheet is the only method in nsIEditorStyleSheets
// that would throw. RemoveOverrideStyleSheet returns NS_OK even if the // that would throw. RemoveOverrideStyleSheet returns NS_OK even if the
// sheet is not there // sheet is not there
@ -43,8 +41,6 @@ function checkStylesheets() {
} }
function runTest() { function runTest() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const Ci = Components.interfaces; const Ci = Components.interfaces;
const Cc = Components.classes; const Cc = Components.classes;
@ -58,7 +54,7 @@ function runTest() {
editdoc.designMode='on'; editdoc.designMode='on';
// Hold the reference to the editor // Hold the reference to the editor
editor = editframe.QueryInterface(Ci.nsIInterfaceRequestor) editor = SpecialPowers.wrap(editframe.QueryInterface(Ci.nsIInterfaceRequestor))
.getInterface(Ci.nsIWebNavigation) .getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIEditingSession) .getInterface(Ci.nsIEditingSession)
@ -77,7 +73,7 @@ function runTest() {
editdoc.body.contentEditable = true; editdoc.body.contentEditable = true;
// Hold the reference to the editor // Hold the reference to the editor
editor = editframe.QueryInterface(Ci.nsIInterfaceRequestor) editor = SpecialPowers.wrap(editframe.QueryInterface(Ci.nsIInterfaceRequestor))
.getInterface(Ci.nsIWebNavigation) .getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIEditingSession) .getInterface(Ci.nsIEditingSession)
@ -94,7 +90,7 @@ function runTest() {
editdoc.designMode = "off"; editdoc.designMode = "off";
// Hold the reference to the editor // Hold the reference to the editor
editor = editframe.QueryInterface(Ci.nsIInterfaceRequestor) editor = SpecialPowers.wrap(editframe.QueryInterface(Ci.nsIInterfaceRequestor))
.getInterface(Ci.nsIWebNavigation) .getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIEditingSession) .getInterface(Ci.nsIEditingSession)

Просмотреть файл

@ -8,8 +8,6 @@
<script class="testbody" type="application/javascript"> <script class="testbody" type="application/javascript">
function runTest() { function runTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
function verifyContent(s) { function verifyContent(s) {
var e = document.getElementById('i1'); var e = document.getElementById('i1');
var doc = e.contentDocument; var doc = e.contentDocument;
@ -27,7 +25,7 @@ function runTest() {
selection.removeAllRanges(); selection.removeAllRanges();
selection.selectAllChildren(e); selection.selectAllChildren(e);
selection.collapseToEnd(); selection.collapseToEnd();
doc.execCommand("paste", false, null); SpecialPowers.wrap(doc).execCommand("paste", false, null);
return e; return e;
} }
@ -51,7 +49,7 @@ function runTest() {
range.selectNode(doc.getElementById(target_id)); range.selectNode(doc.getElementById(target_id));
selection.addRange(range); selection.addRange(range);
} }
doc.execCommand("copy", false, null); SpecialPowers.wrap(doc).execCommand("copy", false, null);
return e; return e;
} }

Просмотреть файл

@ -8,8 +8,6 @@
<script class="testbody" type="application/javascript"> <script class="testbody" type="application/javascript">
function runTest() { function runTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
function verifyContent(s) { function verifyContent(s) {
var e = document.getElementById('i1'); var e = document.getElementById('i1');
var doc = e.contentDocument; var doc = e.contentDocument;
@ -30,7 +28,7 @@ function runTest() {
selection.removeAllRanges(); selection.removeAllRanges();
selection.selectAllChildren(e); selection.selectAllChildren(e);
selection.collapseToEnd(); selection.collapseToEnd();
doc.execCommand("paste", false, null); SpecialPowers.wrap(doc).execCommand("paste", false, null);
return e; return e;
} }
@ -54,7 +52,7 @@ function runTest() {
range.selectNode(doc.getElementById(target_id)); range.selectNode(doc.getElementById(target_id));
selection.addRange(range); selection.addRange(range);
} }
doc.execCommand("copy", false, null); SpecialPowers.wrap(doc).execCommand("copy", false, null);
return e; return e;
} }

Просмотреть файл

@ -563,12 +563,10 @@ function runTest(test) {
} else } else
elem.focus(); elem.focus();
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var trans = SpecialPowers.wrap(Components).classes["@mozilla.org/widget/transferable;1"]
var trans = Components.classes["@mozilla.org/widget/transferable;1"]
.createInstance(Components.interfaces.nsITransferable); .createInstance(Components.interfaces.nsITransferable);
trans.init(getLoadContext()); trans.init(getLoadContext());
var data = Components.classes["@mozilla.org/supports-string;1"] var data = SpecialPowers.wrap(Components).classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString); .createInstance(Components.interfaces.nsISupportsString);
data.data = test.payload; data.data = test.payload;
trans.addDataFlavor("text/html"); trans.addDataFlavor("text/html");
@ -582,13 +580,13 @@ function runTest(test) {
getSelection().collapse(elem, 0); getSelection().collapse(elem, 0);
win = window; win = window;
} }
editor = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor) editor = SpecialPowers.wrap(win).QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation) .getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIEditorDocShell) .QueryInterface(Components.interfaces.nsIEditorDocShell)
.editor; .editor;
editor.pasteTransferable(trans); editor.pasteTransferable(trans);
} else { } else {
var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"] var clipboard = SpecialPowers.wrap(Components).classes["@mozilla.org/widget/clipboard;1"]
.getService(Components.interfaces.nsIClipboard); .getService(Components.interfaces.nsIClipboard);
clipboard.setData(trans, null, Components.interfaces.nsIClipboard.kGlobalClipboard); clipboard.setData(trans, null, Components.interfaces.nsIClipboard.kGlobalClipboard);

Просмотреть файл

@ -7,13 +7,14 @@
<script class="testbody" type="application/javascript"> <script class="testbody" type="application/javascript">
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var utils = SpecialPowers.wrap(window)
var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils); .QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils);
var Cc = Components.classes; var Cc = SpecialPowers.wrap(Components).classes;
var Ci = Components.interfaces; var Ci = Components.interfaces;
function getLoadContext() { function getLoadContext() {
return window.QueryInterface(Ci.nsIInterfaceRequestor) return SpecialPowers.wrap(window)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation) .getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsILoadContext); .QueryInterface(Ci.nsILoadContext);
} }
@ -29,7 +30,6 @@ function runTest() {
} }
function pasteInto(trans, html, target_id) { function pasteInto(trans, html, target_id) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var e = document.getElementById('i1'); var e = document.getElementById('i1');
var doc = e.contentDocument; var doc = e.contentDocument;
doc.designMode = "on"; doc.designMode = "on";
@ -53,7 +53,6 @@ function runTest() {
} }
function getTransferableFromClipboard(asHTML) { function getTransferableFromClipboard(asHTML) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable); var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
trans.init(getLoadContext()); trans.init(getLoadContext());
if (asHTML) { if (asHTML) {
@ -67,8 +66,6 @@ function runTest() {
} }
function makeTransferable(s,asHTML,target_id) { function makeTransferable(s,asHTML,target_id) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var e = document.getElementById('i2'); var e = document.getElementById('i2');
var doc = e.contentDocument; var doc = e.contentDocument;
if (asHTML) { if (asHTML) {
@ -112,7 +109,6 @@ function runTest() {
} }
function copyToClipBoard(s,asHTML,target_id) { function copyToClipBoard(s,asHTML,target_id) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var e = document.getElementById('i2'); var e = document.getElementById('i2');
var doc = e.contentDocument; var doc = e.contentDocument;
if (asHTML) { if (asHTML) {
@ -132,7 +128,7 @@ function runTest() {
range.selectNode(doc.getElementById(target_id)); range.selectNode(doc.getElementById(target_id));
selection.addRange(range); selection.addRange(range);
} }
doc.execCommand("copy", false, null); SpecialPowers.wrap(doc).execCommand("copy", false, null);
return e; return e;
} }

Просмотреть файл

@ -22,8 +22,6 @@
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTest); SimpleTest.waitForFocus(runTest);
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
function runDesignModeTest(aDoc, aFocus, aNewSource) function runDesignModeTest(aDoc, aFocus, aNewSource)
{ {
aDoc.designMode = "on"; aDoc.designMode = "on";
@ -83,11 +81,9 @@ var gSetFocusToIFrame = false;
function onLoadIFrame() function onLoadIFrame()
{ {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var frameDoc = gIFrame.contentWindow.document; var frameDoc = gIFrame.contentWindow.document;
var selCon = gIFrame.contentWindow. var selCon = SpecialPowers.wrap(gIFrame).contentWindow.
QueryInterface(Components.interfaces.nsIInterfaceRequestor). QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIWebNavigation). getInterface(Components.interfaces.nsIWebNavigation).
QueryInterface(Components.interfaces.nsIInterfaceRequestor). QueryInterface(Components.interfaces.nsIInterfaceRequestor).

Просмотреть файл

@ -36,9 +36,8 @@ addLoadEvent(function() {
ok(equal, "Show/hide should have no effect", ok(equal, "Show/hide should have no effect",
"got " + str1 + " but expected " + str2); "got " + str1 + " but expected " + str2);
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var viewer = var viewer =
$("ourFrame").contentWindow SpecialPowers.wrap($("ourFrame")).contentWindow
.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation) .getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell) .QueryInterface(Components.interfaces.nsIDocShell)