From 05be75444032c0479f352552496228f3ee188c81 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Fri, 30 Mar 2012 09:38:19 -0700 Subject: [PATCH] Fix for bug 740855 (Make tests that try to get XHR.channel use SpecialPowers). r=bz, bent. --HG-- extra : rebase_source : 1278ff2158cd8138ebe3570a2d8f45cec8233d1c --- content/base/test/test_bug383430.html | 2 +- content/base/test/test_bug393968.html | 3 +-- content/base/test/test_bug397234.html | 3 +-- content/base/test/test_bug413974.html | 3 +-- content/base/test/test_bug422537.html | 2 +- content/base/test/test_bug431701.html | 3 +-- content/base/test/test_bug475156.html | 3 +-- content/base/test/test_xhr_forbidden_headers.html | 6 +++--- 8 files changed, 10 insertions(+), 15 deletions(-) diff --git a/content/base/test/test_bug383430.html b/content/base/test/test_bug383430.html index e855f7ffe56..7ce99717523 100644 --- a/content/base/test/test_bug383430.html +++ b/content/base/test/test_bug383430.html @@ -25,7 +25,7 @@ req.mozBackgroundRequest = true; req.open("GET", window.location.href); req.send(null); -ok(req.channel.loadGroup == null, "loadGroup is null"); +ok(SpecialPowers.wrap(req).channel.loadGroup == null, "loadGroup is null"); diff --git a/content/base/test/test_bug393968.html b/content/base/test/test_bug393968.html index 57038b9fb40..cbc49b6e7fc 100644 --- a/content/base/test/test_bug393968.html +++ b/content/base/test/test_bug393968.html @@ -23,8 +23,7 @@ req.open("POST", window.location.href); req.setRequestHeader("Content-Type", "text/plain; charset=us-ascii; boundary=01234567890"); req.send("Some text"); -netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); -is(req.channel +is(SpecialPowers.wrap(req).channel .QueryInterface(Components.interfaces.nsIHttpChannel) .getRequestHeader("Content-Type"), "text/plain; charset=UTF-8; boundary=01234567890", diff --git a/content/base/test/test_bug397234.html b/content/base/test/test_bug397234.html index ab122eb6dc3..8893e17d325 100644 --- a/content/base/test/test_bug397234.html +++ b/content/base/test/test_bug397234.html @@ -24,8 +24,7 @@ req.open("POST", window.location.href); req.setRequestHeader("Content-Type", "text/plain; charset='uTf-8'"); req.send("Some text"); -netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); -is(req.channel +is(SpecialPowers.wrap(req).channel .QueryInterface(Components.interfaces.nsIHttpChannel) .getRequestHeader("Content-Type"), "text/plain; charset='uTf-8'", diff --git a/content/base/test/test_bug413974.html b/content/base/test/test_bug413974.html index b1431808984..d03eb08b5ce 100644 --- a/content/base/test/test_bug413974.html +++ b/content/base/test/test_bug413974.html @@ -23,8 +23,7 @@ req.open("POST", window.location.href); req.setRequestHeader("Content-Type", "text/plain; boundary=01234567890"); req.send("Some text"); -netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); -is(req.channel +is(SpecialPowers.wrap(req).channel .QueryInterface(Components.interfaces.nsIHttpChannel) .getRequestHeader("Content-Type"), "text/plain; charset=UTF-8; boundary=01234567890", diff --git a/content/base/test/test_bug422537.html b/content/base/test/test_bug422537.html index c4411c2de1a..37ae3cd0e1a 100644 --- a/content/base/test/test_bug422537.html +++ b/content/base/test/test_bug422537.html @@ -36,7 +36,7 @@ for each (var i in body) { var xhr = new XMLHttpRequest(); xhr.open("POST", url, true); xhr.send(i); - var chan = xhr.channel; + var chan = SpecialPowers.unwrap(SpecialPowers.wrap(xhr).channel); if (!(chan instanceof Components.interfaces.nsIUploadChannel)) throw "Must be an upload channel"; var stream = chan.uploadStream; diff --git a/content/base/test/test_bug431701.html b/content/base/test/test_bug431701.html index 16ad7805f8f..bc99acd20f5 100644 --- a/content/base/test/test_bug431701.html +++ b/content/base/test/test_bug431701.html @@ -98,8 +98,7 @@ addLoadEvent(function() { var xhr = new XMLHttpRequest(); xhr.open("POST", document.location.href); xhr.send(createDoc()); - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - is(xhr.channel.QueryInterface(Components.interfaces.nsIHttpChannel) + is(SpecialPowers.wrap(xhr).channel.QueryInterface(Components.interfaces.nsIHttpChannel) .getRequestHeader("Content-Type"), "application/xml; charset=UTF-8", "Testing correct type on the wire"); xhr.abort(); diff --git a/content/base/test/test_bug475156.html b/content/base/test/test_bug475156.html index 04a1b7e8482..3184b55dc73 100644 --- a/content/base/test/test_bug475156.html +++ b/content/base/test/test_bug475156.html @@ -17,8 +17,7 @@ var path = "http://mochi.test:8888/tests/content/base/test/"; function fromCache(xhr) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var ch = xhr.channel.QueryInterface(Components.interfaces.nsICachingChannel); + var ch = SpecialPowers.wrap(xhr).channel.QueryInterface(Components.interfaces.nsICachingChannel); return ch.isFromCache(); } diff --git a/content/base/test/test_xhr_forbidden_headers.html b/content/base/test/test_xhr_forbidden_headers.html index c4cb6f4a788..5f66dd18f6a 100644 --- a/content/base/test/test_xhr_forbidden_headers.html +++ b/content/base/test/test_xhr_forbidden_headers.html @@ -55,8 +55,7 @@ for (i = 0; i < headers.length; i++) request.setRequestHeader(headers[i], "test" + i); // Read out headers -netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); -var channel = request.channel.QueryInterface(Components.interfaces.nsIHttpChannel); +var channel = SpecialPowers.wrap(request).channel.QueryInterface(Components.interfaces.nsIHttpChannel); for (i = 0; i < headers.length; i++) { // Retrieving Content-Length will throw an exception var value = null; @@ -69,13 +68,14 @@ for (i = 0; i < headers.length; i++) { } // Try setting headers in privileged context +netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); request = new XMLHttpRequest(); request.open("GET", window.location.href); for (i = 0; i < headers.length; i++) request.setRequestHeader(headers[i], "test" + i); // Read out headers -var channel = request.channel.QueryInterface(Components.interfaces.nsIHttpChannel); +var channel = SpecialPowers.wrap(request).channel.QueryInterface(Components.interfaces.nsIHttpChannel); for (i = 0; i < headers.length; i++) { var value = channel.getRequestHeader(headers[i]); is(value, "test" + i, "Setting " + headers[i] + " header in privileged context");