Skip to content

Commit

Permalink
Bug 1224580. Copy of URLSearchParams should not copy its observer poi…
Browse files Browse the repository at this point in the history
…nter. r=baku
  • Loading branch information
bzbarsky committed Nov 16, 2015
1 parent f4152a3 commit b9ac672
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dom/base/URLSearchParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ URLSearchParams::URLSearchParams(nsISupports* aParent,
const URLSearchParams& aOther)
: mParams(new URLParams(*aOther.mParams.get()))
, mParent(aParent)
, mObserver(aOther.mObserver)
, mObserver(nullptr)
{
}

Expand Down
15 changes: 15 additions & 0 deletions dom/base/test/test_urlSearchParams.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,20 @@
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,
Expand All @@ -314,6 +328,7 @@
testSet,
testIterable,
testZeroHandling,
testCopyConstructor,
];

function runTest() {
Expand Down

0 comments on commit b9ac672

Please sign in to comment.