mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
2a40ef2903
- Bug 1169044 - Patch 1 - Refactor setting referrer and referrer policy between fetch and XHR. r=khuey (3912ebaef)
- Bug 1150771 - Let ArrayBuffer through object Xrays. r=gabor (bed760277)
- Bug 1151385 - Fail early for cross-origin sandboxPrototype. r=gabor (3b65b1561)
- Bug 1131707 - Transparently forward the construct bit for function forwarders. r=gabor (1f5792775)
- Bug 1170311 - Stop asserting non-null argument to nsIPrincipal::{subsumes,equals}{,ConsideringDomain}. r=gabor (7e36d6683)
- Bug 1171175 - Improve BasePrincipal::IsCodebasePrincipal. r=baku (0d278e8f4)
- Bug 1174731 - patch 1 - Make searchParams attribute readonly, r=smaug (11f5d6dcf)
- Bug 1174731 - patch 2 - Make searchParams attribute readonly, r=annevk (4aa7ea1e4)
- Bug 1170097 - Part 1: Move OriginAttributeDictionary. r=bholley (63a1139dd)
- Bug 1084525 - Part 1: Create initial PromisesActor skeleton r=fitzgen (2ef0ad37d)
- Bug 1131643 - Implement a Location object;r=jlong (710fb9b79)
- Bug 1129834 - Store BreakpointActors by original location;r=jlong (67d16d37a)
- Bug 1129837 - Remove generatedLocation from BreakpointActor;r=jlongster (018a60746)
- Bug 1082837 - test cases for image redirects loaded from the imagelib cache. r=smaug, ckerschb (49d216725)
- Bug 1073352, part 2 - Enable some devtools tests. r=ejpbruel (0de7cfdc0)
- Bug 1131646 - Clean up the breakpoint code;r=jlongster (7fa9c6a76)
- Bug 1136146 - Merge the latest version of the source-map library with fx-team;r=fitzgen (983f2c2e9)
- Bug 1042976 follow up - Remove getInnerId from script actors; r=Mossop (43f935298)
- Bug 837630 - Stop hiding __proto__ from O.getOwnPropertyNames. r=Waldo,peterv,past (0f321614d)
- Bug 1138975 - Refactor breakpoint sliding for non-source mapped sources;r=jlong (9fd4be4e4)
- Fix breaking on the "load" event in the debugger (bug 1054159). r=ochameau (6b6b40e78)
- Bug 983469 - Pause on breakpoint condition exception. r=fitzgen (fb6dfab57)
- Bug 1135435 - Add UI for breakpoint condition throws. r=fitzgen (b2f49cb03)
- Bug 1137384 - Rename ThreadSources as TabSources and move it up into the TabActor. r=ejpbruel (fdf1db5d9)
270 lines
8.6 KiB
HTML
270 lines
8.6 KiB
HTML
|
|
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=887836
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for URLSearchParams</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=887836">Mozilla Bug 887836</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
<iframe name="x" id="x"></iframe>
|
|
<iframe name="y" id="y"></iframe>
|
|
</div>
|
|
<pre id="test">
|
|
</pre>
|
|
<a href="http://www.example.net?a=b&c=d" id="anchor">foobar</a>
|
|
<area href="http://www.example.net?a=b&c=d" id="area">foobar</area>
|
|
<script type="application/javascript">
|
|
|
|
/** Test for Bug 887836 **/
|
|
ok("URLSearchParams" in window, "window.URLSearchParams exists");
|
|
|
|
function testSimpleURLSearchParams() {
|
|
var u = new URLSearchParams();
|
|
ok(u, "URLSearchParams created");
|
|
is(u.has('foo'), false, 'URLSearchParams.has(foo)');
|
|
is(u.get('foo'), null, 'URLSearchParams.get(foo)');
|
|
is(u.getAll('foo').length, 0, 'URLSearchParams.getAll(foo)');
|
|
|
|
u.append('foo', 'bar');
|
|
is(u.has('foo'), true, 'URLSearchParams.has(foo)');
|
|
is(u.get('foo'), 'bar', 'URLSearchParams.get(foo)');
|
|
is(u.getAll('foo').length, 1, 'URLSearchParams.getAll(foo)');
|
|
|
|
u.set('foo', 'bar2');
|
|
is(u.get('foo'), 'bar2', 'URLSearchParams.get(foo)');
|
|
is(u.getAll('foo').length, 1, 'URLSearchParams.getAll(foo)');
|
|
|
|
is(u + "", "foo=bar2", "stringifier");
|
|
|
|
u.delete('foo');
|
|
|
|
runTest();
|
|
}
|
|
|
|
function testCopyURLSearchParams() {
|
|
var u = new URLSearchParams();
|
|
ok(u, "URLSearchParams created");
|
|
u.append('foo', 'bar');
|
|
|
|
var uu = new URLSearchParams(u);
|
|
is(uu.get('foo'), 'bar', 'uu.get()');
|
|
|
|
u.append('foo', 'bar2');
|
|
is(u.getAll('foo').length, 2, "u.getAll()");
|
|
is(uu.getAll('foo').length, 1, "uu.getAll()");
|
|
|
|
runTest();
|
|
}
|
|
|
|
function testParserURLSearchParams() {
|
|
var checks = [
|
|
{ input: '', data: {} },
|
|
{ input: 'a', data: { 'a' : [''] } },
|
|
{ input: 'a=b', data: { 'a' : ['b'] } },
|
|
{ input: 'a=', data: { 'a' : [''] } },
|
|
{ input: '=b', data: { '' : ['b'] } },
|
|
{ input: '&', data: {} },
|
|
{ input: '&a', data: { 'a' : [''] } },
|
|
{ input: 'a&', data: { 'a' : [''] } },
|
|
{ input: 'a&a', data: { 'a' : ['', ''] } },
|
|
{ input: 'a&b&c', data: { 'a' : [''], 'b' : [''], 'c' : [''] } },
|
|
{ input: 'a=b&c=d', data: { 'a' : ['b'], 'c' : ['d'] } },
|
|
{ input: 'a=b&c=d&', data: { 'a' : ['b'], 'c' : ['d'] } },
|
|
{ input: '&&&a=b&&&&c=d&', data: { 'a' : ['b'], 'c' : ['d'] } },
|
|
{ input: 'a=a&a=b&a=c', data: { 'a' : ['a', 'b', 'c'] } },
|
|
{ input: 'a==a', data: { 'a' : ['=a'] } },
|
|
{ input: 'a=a+b+c+d', data: { 'a' : ['a b c d'] } },
|
|
{ input: '%=a', data: { '%' : ['a'] } },
|
|
{ input: '%a=a', data: { '%a' : ['a'] } },
|
|
{ input: '%a_=a', data: { '%a_' : ['a'] } },
|
|
{ input: '%61=a', data: { 'a' : ['a'] } },
|
|
{ input: '%=a', data: { '%' : ['a'] } },
|
|
{ input: '%a=a', data: { '%a' : ['a'] } },
|
|
{ input: '%a_=a', data: { '%a_' : ['a'] } },
|
|
{ input: '%61=a', data: { 'a' : ['a'] } },
|
|
{ input: '%61+%4d%4D=', data: { 'a MM' : [''] } },
|
|
];
|
|
|
|
for (var i = 0; i < checks.length; ++i) {
|
|
var u = new URLSearchParams(checks[i].input);
|
|
|
|
var count = 0;
|
|
for (var key in checks[i].data) {
|
|
++count;
|
|
ok(u.has(key), "key " + key + " found");
|
|
|
|
var all = u.getAll(key);
|
|
is(all.length, checks[i].data[key].length, "same number of elements");
|
|
|
|
for (var k = 0; k < all.length; ++k) {
|
|
is(all[k], checks[i].data[key][k], "value matches");
|
|
}
|
|
}
|
|
}
|
|
|
|
runTest();
|
|
}
|
|
|
|
function testURL() {
|
|
var url = new URL('http://www.example.net?a=b&c=d');
|
|
ok(url.searchParams, "URL searchParams exists!");
|
|
ok(url.searchParams.has('a'), "URL.searchParams.has('a')");
|
|
is(url.searchParams.get('a'), 'b', "URL.searchParams.get('a')");
|
|
ok(url.searchParams.has('c'), "URL.searchParams.has('c')");
|
|
is(url.searchParams.get('c'), 'd', "URL.searchParams.get('c')");
|
|
|
|
url.searchParams.set('e', 'f');
|
|
ok(url.href.indexOf('e=f') != 1, 'URL right');
|
|
|
|
runTest();
|
|
}
|
|
|
|
function testElement(e) {
|
|
ok(e, 'element exists');
|
|
ok(e.searchParams, "e.searchParams exists!");
|
|
ok(e.searchParams.has('a'), "e.searchParams.has('a')");
|
|
is(e.searchParams.get('a'), 'b', "e.searchParams.get('a')");
|
|
ok(e.searchParams.has('c'), "e.searchParams.has('c')");
|
|
is(e.searchParams.get('c'), 'd', "e.searchParams.get('c')");
|
|
|
|
e.searchParams.set('e', 'f');
|
|
ok(e.href.indexOf('e=f') != 1, 'e is right');
|
|
|
|
runTest();
|
|
}
|
|
|
|
function testEncoding() {
|
|
var encoding = [ [ '1', '1' ],
|
|
[ 'a b', 'a+b' ],
|
|
[ '<>', '%3C%3E' ],
|
|
[ '\u0541', '%D5%81'] ];
|
|
|
|
for (var i = 0; i < encoding.length; ++i) {
|
|
var url = new URL('http://www.example.net');
|
|
url.searchParams.set('a', encoding[i][0]);
|
|
is(url.href, 'http://www.example.net/?a=' + encoding[i][1]);
|
|
|
|
var url2 = new URL(url.href);
|
|
is(url2.searchParams.get('a'), encoding[i][0], 'a is still there');
|
|
}
|
|
|
|
runTest();
|
|
}
|
|
|
|
function testOrdering() {
|
|
var a = new URLSearchParams("a=1&a=2&b=3&c=4&c=5&a=6");
|
|
is(a.toString(), "a=1&a=2&b=3&c=4&c=5&a=6", "Order is correct");
|
|
is(a.getAll('a').length, 3, "Correct length of getAll()");
|
|
|
|
var b = new URLSearchParams();
|
|
b.append('a', '1');
|
|
b.append('b', '2');
|
|
b.append('a', '3');
|
|
is(b.toString(), "a=1&b=2&a=3", "Order is correct");
|
|
is(b.getAll('a').length, 2, "Correct length of getAll()");
|
|
|
|
runTest();
|
|
}
|
|
|
|
function testDelete() {
|
|
var a = new URLSearchParams("a=1&a=2&b=3&c=4&c=5&a=6");
|
|
is(a.toString(), "a=1&a=2&b=3&c=4&c=5&a=6", "Order is correct");
|
|
is(a.getAll('a').length, 3, "Correct length of getAll()");
|
|
|
|
a.delete('a');
|
|
is(a.getAll('a').length, 0, "Correct length of getAll()");
|
|
is(a.toString(), "b=3&c=4&c=5", "Order is correct");
|
|
|
|
runTest();
|
|
}
|
|
|
|
function testGetNULL() {
|
|
|
|
var u = new URLSearchParams();
|
|
is(typeof u.get(''), "object", "typeof URL.searchParams.get('')");
|
|
is(u.get(''), null, "URL.searchParams.get('') should be null");
|
|
|
|
var url = new URL('http://www.example.net?a=b');
|
|
is(url.searchParams.get('b'), null, "URL.searchParams.get('b') should be null");
|
|
is(url.searchParams.get('a'), 'b', "URL.searchParams.get('a')");
|
|
|
|
runTest();
|
|
}
|
|
|
|
function testSet() {
|
|
var u = new URLSearchParams();
|
|
u.set('a','b');
|
|
u.set('e','c');
|
|
u.set('i','d');
|
|
u.set('o','f');
|
|
u.set('u','g');
|
|
|
|
is(u.get('a'), 'b', "URL.searchParams.get('a') should return b");
|
|
is(u.getAll('a').length, 1, "URLSearchParams.getAll('a').length should be 1");
|
|
|
|
u.set('a','h1');
|
|
u.set('a','h2');
|
|
u.set('a','h3');
|
|
u.set('a','h4');
|
|
is(u.get('a'), 'h4', "URL.searchParams.get('a') should return h4");
|
|
is(u.getAll('a').length, 1, "URLSearchParams.getAll('a').length should be 1");
|
|
|
|
is(u.get('e'), 'c', "URL.searchParams.get('e') should return c");
|
|
is(u.get('i'), 'd', "URL.searchParams.get('i') should return d");
|
|
is(u.get('o'), 'f', "URL.searchParams.get('o') should return f");
|
|
is(u.get('u'), 'g', "URL.searchParams.get('u') should return g");
|
|
|
|
is(u.getAll('e').length, 1, "URLSearchParams.getAll('e').length should be 1");
|
|
is(u.getAll('i').length, 1, "URLSearchParams.getAll('i').length should be 1");
|
|
is(u.getAll('o').length, 1, "URLSearchParams.getAll('o').length should be 1");
|
|
is(u.getAll('u').length, 1, "URLSearchParams.getAll('u').length should be 1");
|
|
|
|
u = new URLSearchParams("name1=value1&name1=value2&name1=value3");
|
|
is(u.get('name1'), 'value1', "URL.searchParams.get('name1') should return value1");
|
|
is(u.getAll('name1').length, 3, "URLSearchParams.getAll('name1').length should be 3");
|
|
u.set('name1','firstPair');
|
|
is(u.get('name1'), 'firstPair', "URL.searchParams.get('name1') should return firstPair");
|
|
is(u.getAll('name1').length, 1, "URLSearchParams.getAll('name1').length should be 1");
|
|
|
|
runTest();
|
|
}
|
|
|
|
var tests = [
|
|
testSimpleURLSearchParams,
|
|
testCopyURLSearchParams,
|
|
testParserURLSearchParams,
|
|
testURL,
|
|
function() { testElement(document.getElementById('anchor')) },
|
|
function() { testElement(document.getElementById('area')) },
|
|
testEncoding,
|
|
testOrdering,
|
|
testDelete,
|
|
testGetNULL,
|
|
testSet
|
|
];
|
|
|
|
function runTest() {
|
|
if (!tests.length) {
|
|
SimpleTest.finish();
|
|
return;
|
|
}
|
|
|
|
var test = tests.shift();
|
|
test();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
runTest();
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|