mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Bug 976105 - Remove test-suite dependency on unprivileged calls to constructor-as-function. r=bz
This commit is contained in:
parent
fb3ec81132
commit
2bbdf9b30b
@ -590,7 +590,7 @@ exports["test XMLHttpRequest"] = createProxyTest("", function (helper) {
|
||||
'new ' + function ContentScriptScope() {
|
||||
// XMLHttpRequest doesn't support XMLHttpRequest.apply,
|
||||
// that may break our proxy code
|
||||
assert(window.XMLHttpRequest(), "we are able to instantiate XMLHttpRequest object");
|
||||
assert(new window.XMLHttpRequest(), "we are able to instantiate XMLHttpRequest object");
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
@ -11,9 +11,9 @@
|
||||
var iframe = document.createElementNS("http://www.w3.org/1999/xhtml", "iframe");
|
||||
document.body.appendChild(iframe);
|
||||
var frameWin = iframe.contentWindow;
|
||||
frameWin.AudioContext();
|
||||
new frameWin.AudioContext();
|
||||
document.body.removeChild(iframe);
|
||||
frameWin.AudioContext();
|
||||
new frameWin.AudioContext();
|
||||
|
||||
ok(true, "This test should not leak");
|
||||
</script>
|
||||
|
@ -9,7 +9,7 @@
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
AudioContext().destination.expando = null;
|
||||
(new AudioContext()).destination.expando = null;
|
||||
ok(true, "The test should not trigger wrapper cache assertions");
|
||||
|
||||
</script>
|
||||
|
@ -9,7 +9,7 @@
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
AudioContext().foo = null;
|
||||
(new AudioContext()).foo = null;
|
||||
ok(true, "The test should not fatally assert");
|
||||
|
||||
</script>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<body>
|
||||
<script>
|
||||
|
||||
var ac = AudioContext();
|
||||
var ac = new AudioContext();
|
||||
ac.createPanner();
|
||||
var listener = ac.listener;
|
||||
SpecialPowers.forceGC();
|
||||
|
@ -55,7 +55,7 @@ function runTest() {
|
||||
// We assume here that iframe is completely blank, and spin until popup's
|
||||
// screenshot is not the same as iframe.
|
||||
iframe.getScreenshot(1000, 1000).onsuccess = function(e) {
|
||||
var fr = FileReader();
|
||||
var fr = new FileReader();
|
||||
fr.onloadend = function() { test2(popup, fr.result); };
|
||||
fr.readAsArrayBuffer(e.target.result);
|
||||
};
|
||||
|
@ -116,8 +116,8 @@ function testBOMCharset(test)
|
||||
var outText;
|
||||
try {
|
||||
var decoder = 'fatal' in test ?
|
||||
TextDecoder(test.encoding, {fatal: test.fatal}) :
|
||||
TextDecoder(test.encoding);
|
||||
new TextDecoder(test.encoding, {fatal: test.fatal}) :
|
||||
new TextDecoder(test.encoding);
|
||||
outText = decoder.decode(new Uint8Array(test.data));
|
||||
} catch (e) {
|
||||
assert_equals(e.name, test.error, test.msg);
|
||||
|
@ -358,7 +358,7 @@ function testDecoderGetEncoding()
|
||||
for (var le of labelEncodings) {
|
||||
for (var label of le.labels) {
|
||||
try {
|
||||
var decoder = TextDecoder(label);
|
||||
var decoder = new TextDecoder(label);
|
||||
} catch (e) {
|
||||
assert_true(!!le.error, label + " shoud not throw " + e.name);
|
||||
assert_equals(e.name, le.error, label + " label encoding unsupported test.");
|
||||
@ -374,7 +374,7 @@ function testCharset(test)
|
||||
{
|
||||
try {
|
||||
var fatal = test.fatal ? {fatal: test.fatal} : null;
|
||||
var decoder = TextDecoder(test.encoding, fatal);
|
||||
var decoder = new TextDecoder(test.encoding, fatal);
|
||||
} catch (e) {
|
||||
assert_equals(e.name, test.error, test.msg + " error thrown from the constructor.");
|
||||
return;
|
||||
@ -438,7 +438,7 @@ function testInvalid2022JP()
|
||||
inputs.forEach(function(input) {
|
||||
try {
|
||||
// decode() should never throw unless {fatal: true} is specified
|
||||
new TextDecoder("iso-2022-jp").decode(new Uint8Array(input));
|
||||
(new TextDecoder("iso-2022-jp")).decode(new Uint8Array(input));
|
||||
} catch (e) {
|
||||
if (e.name !== "EncodingError") {
|
||||
throw e;
|
||||
|
@ -134,7 +134,7 @@ function testSingleString(test)
|
||||
var outText;
|
||||
try {
|
||||
var stream = test.stream ? {stream: true} : null;
|
||||
outText = TextEncoder(test.encoding).encode(test.input, stream);
|
||||
outText = (new TextEncoder(test.encoding)).encode(test.input, stream);
|
||||
} catch (e) {
|
||||
assert_equals(e.name, test.error, test.msg);
|
||||
return;
|
||||
@ -237,7 +237,7 @@ function testArrayOfStrings(test)
|
||||
{
|
||||
var encoder;
|
||||
try {
|
||||
encoder = TextEncoder(test.encoding);
|
||||
encoder = new TextEncoder(test.encoding);
|
||||
} catch (e) {
|
||||
assert_equals(e.name, test.error, test.msg);
|
||||
return;
|
||||
@ -270,7 +270,7 @@ function testEncoderGetEncoding()
|
||||
|
||||
for (var le of labelEncodings) {
|
||||
for (var label of le.labels) {
|
||||
var encoder = TextEncoder(label);
|
||||
var encoder = new TextEncoder(label);
|
||||
assert_equals(encoder.encoding, le.encoding, label + " label encoding test.");
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ test(function() {
|
||||
assert_true("initEvent" in ev)
|
||||
})
|
||||
test(function() {
|
||||
var ev = Event("test")
|
||||
var ev = new Event("test")
|
||||
assert_equals(ev.type, "test")
|
||||
assert_equals(ev.target, null)
|
||||
assert_equals(ev.currentTarget, null)
|
||||
|
@ -10,8 +10,4 @@ test(function() {
|
||||
var x = new XPathEvaluator();
|
||||
assert_true(x instanceof XPathEvaluator);
|
||||
}, "Constructor with 'new'");
|
||||
test(function() {
|
||||
var x = XPathEvaluator();
|
||||
assert_true(x instanceof XPathEvaluator);
|
||||
}, "Constructor without 'new'");
|
||||
</script>
|
||||
|
@ -12,7 +12,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=791330
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
var pc = mozRTCPeerConnection();
|
||||
var pc = new mozRTCPeerConnection();
|
||||
pc.close();
|
||||
|
||||
navigator.mozGetUserMedia({audio: true, fake: true}, function (stream) {
|
||||
|
@ -12,8 +12,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=799419
|
||||
}
|
||||
|
||||
function boom() {
|
||||
var v0 = mozRTCPeerConnection();
|
||||
var v1 = mozRTCPeerConnection();
|
||||
var v0 = new mozRTCPeerConnection();
|
||||
var v1 = new mozRTCPeerConnection();
|
||||
var v2 = document.getElementById("pc1video");
|
||||
var v3 = document.getElementById("pc2video");
|
||||
navigator.mozGetUserMedia({video:true, fake: true},
|
||||
|
@ -12,7 +12,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=837324
|
||||
}
|
||||
|
||||
function start() {
|
||||
var o0 = mozRTCPeerConnection();
|
||||
var o0 = new mozRTCPeerConnection();
|
||||
var o1 = new mozRTCIceCandidate({"candidate":"0 -65535 IP 0 stun.sipgate.net 3227326073 type ::ffff:192.0.2.128 host 2302600701","sdpMid":"video 3907077665 RTP/SAVPF 5000","sdpMLineIndex":7});
|
||||
try {o0.addIceCandidate(o1);} catch(e) {} // bug 842075 - remove try when fixed
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
"PC_LOCAL_ADD_CANDIDATE",
|
||||
function (test) {
|
||||
test.pcLocal.addIceCandidateAndFail(
|
||||
mozRTCIceCandidate(
|
||||
new mozRTCIceCandidate(
|
||||
{candidate:"1 1 UDP 2130706431 192.168.2.1 50005 typ host",
|
||||
sdpMLineIndex: 1}),
|
||||
function(err) {
|
||||
|
@ -24,7 +24,10 @@ function test_constructor(dom_proto, shouldthrow) {
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
is(threw, shouldthrow, "Calling |" + dom_proto + "()| should" + (shouldthrow ? " " : " not ") + "throw");
|
||||
if (shouldthrow)
|
||||
ok(threw, "Calling |" + dom_proto + "()| should throw");
|
||||
else
|
||||
todo(threw, "Calling |" + dom_proto + "()| should throw");
|
||||
|
||||
threw = false;
|
||||
try {
|
||||
|
@ -107,16 +107,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=741267
|
||||
ok(false, "'XMLHttpRequest' shouldn't throw in a sandbox");
|
||||
}
|
||||
try {
|
||||
var xhr = Components.utils.evalInSandbox("XMLHttpRequest()", sandbox);
|
||||
var xhr = Components.utils.evalInSandbox("new XMLHttpRequest()", sandbox);
|
||||
is("" + xhr, "[object XrayWrapper " + XMLHttpRequest() + "]", "'XMLHttpRequest()' in a sandbox should create an XMLHttpRequest object");
|
||||
} catch (e) {
|
||||
ok(false, "'XMLHttpRequest()' shouldn't throw in a sandbox");
|
||||
ok(false, "'new XMLHttpRequest()' shouldn't throw in a sandbox (1)");
|
||||
}
|
||||
try {
|
||||
var xhr = Components.utils.evalInSandbox("XMLHttpRequest.prototype.toString = function () { return 'Failed'; }; XMLHttpRequest();", sandbox);
|
||||
var xhr = Components.utils.evalInSandbox("XMLHttpRequest.prototype.toString = function () { return 'Failed'; }; new XMLHttpRequest();", sandbox);
|
||||
is(xhr.toString(), "[object XrayWrapper " + XMLHttpRequest() + "]", "XMLHttpRequest.prototype.toString in the sandbox should not override the native toString behaviour");
|
||||
} catch (e) {
|
||||
ok(false, "'new XMLHttpRequest()' shouldn't throw in a sandbox");
|
||||
ok(false, "'new XMLHttpRequest()' shouldn't throw in a sandbox (2)");
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -330,7 +330,7 @@ function runTest() {
|
||||
// down and push enter. Value should be the on from the new suggestion.
|
||||
doKey("down");
|
||||
var datalist = document.getElementById('suggest');
|
||||
var added = Option("Foo");
|
||||
var added = new Option("Foo");
|
||||
datalist.insertBefore(added, datalist.children[1]);
|
||||
|
||||
SimpleTest.executeSoon(function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user