Bug 1224580. Copy of URLSearchParams should not copy its observer pointer. r=baku

This commit is contained in:
Boris Zbarsky 2015-11-16 13:29:57 -05:00
parent f4152a3bed
commit b9ac672526
2 changed files with 16 additions and 1 deletions

View File

@ -315,7 +315,7 @@ URLSearchParams::URLSearchParams(nsISupports* aParent,
const URLSearchParams& aOther)
: mParams(new URLParams(*aOther.mParams.get()))
, mParent(aParent)
, mObserver(aOther.mObserver)
, mObserver(nullptr)
{
}

View File

@ -300,6 +300,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
runTest();
}
function testCopyConstructor() {
var url = new URL("http://example.com/");
var p = url.searchParams;
var q = new URLSearchParams(p);
q.set("a", "b");
is(url.href, "http://example.com/",
"Messing with copy of URLSearchParams should not affect URL");
p.set("c", "d");
is(url.href, "http://example.com/?c=d",
"Messing with URLSearchParams should affect URL");
runTest();
}
var tests = [
testSimpleURLSearchParams,
testCopyURLSearchParams,
@ -314,6 +328,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
testSet,
testIterable,
testZeroHandling,
testCopyConstructor,
];
function runTest() {