From 047d41c0d3f22e3d2306dfc078880536255184a3 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Mon, 11 Feb 2013 00:05:17 +0100 Subject: [PATCH] Bug 839867 - Align gecko with the spec on cross-origin access to Location.hash. r=bz We update the tests to cover this case. There was also a bug in the tests where we were accidentally testing non-writable Location properties against window rather than window.location. :-( --- content/base/test/file_bug326337_inner.html | 4 ++-- js/xpconnect/tests/mochitest/test_sameOriginPolicy.html | 4 ++-- js/xpconnect/wrappers/AccessCheck.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/content/base/test/file_bug326337_inner.html b/content/base/test/file_bug326337_inner.html index deb92d335742..996bc034f824 100644 --- a/content/base/test/file_bug326337_inner.html +++ b/content/base/test/file_bug326337_inner.html @@ -36,7 +36,7 @@ function runTest2() { if (xhr.readyState == 4) { check(xhr.responseXML.documentElement.getAttribute("root")); if (secondDoc) { - parent.location.hash = "#done"; + SpecialPowers.wrap(parent).location.hash = "#done"; } else { secondDoc = true; @@ -48,7 +48,7 @@ function runTest2() { function check(attr) { if (attr != "yes") { - parent.location.hash = "#fail"; + SpeciaPowers.wrap(parent).location.hash = "#fail"; throw 1; } } diff --git a/js/xpconnect/tests/mochitest/test_sameOriginPolicy.html b/js/xpconnect/tests/mochitest/test_sameOriginPolicy.html index 0fb10512a3a2..51e6158b3a0e 100644 --- a/js/xpconnect/tests/mochitest/test_sameOriginPolicy.html +++ b/js/xpconnect/tests/mochitest/test_sameOriginPolicy.html @@ -54,7 +54,7 @@ function isCrossOriginWritable(obj, prop) { if (obj == "Window") return prop == 'location'; if (obj == "Location") - return prop == 'hash' || prop == 'href'; + return prop == 'href'; } // NB: we don't want to succeed with writes, so we only check them when it should be denied. @@ -72,7 +72,7 @@ function testAll(sameOrigin) { for (var prop in window.location) { check(win.location, prop, sameOrigin || isCrossOriginReadable('Location', prop)); if (!sameOrigin && !isCrossOriginWritable('Location', prop)) - check(win, prop, false, /* write = */ true); + check(win.location, prop, false, /* write = */ true); } } diff --git a/js/xpconnect/wrappers/AccessCheck.cpp b/js/xpconnect/wrappers/AccessCheck.cpp index 1232868aa7c6..d5072d874990 100644 --- a/js/xpconnect/wrappers/AccessCheck.cpp +++ b/js/xpconnect/wrappers/AccessCheck.cpp @@ -142,7 +142,7 @@ IsPermitted(const char *name, JSFlatString *prop, bool set) return false; switch (name[0]) { NAME('L', "Location", - PROP('h', W("hash") W("href")) + PROP('h', W("href")) PROP('r', R("replace"))) NAME('W', "Window", PROP('b', R("blur"))