зеркало из https://github.com/mozilla/pjs.git
Fix for bug 740855 (Make tests that try to get XHR.channel use SpecialPowers). r=bz, bent.
--HG-- extra : rebase_source : 1278ff2158cd8138ebe3570a2d8f45cec8233d1c
This commit is contained in:
Родитель
c8f6e7a27a
Коммит
05be754440
|
@ -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");
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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'",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
Загрузка…
Ссылка в новой задаче