Backout 89b87e96dc17 (bug 639720), b449db7a038b (bug 679689) & ef216b965a04 (bug 679671) for Mochitest oranges, on a CLOSED TREE; a=philor
authorEd Morley <bmo@edmorley.co.uk>
Thu, 01 Sep 2011 00:58:00 +0100
changeset 76362 1898a3e3a1891a5a5801fe592c752ef26403e5b4
parent 76361 0c6cbf58eaa02b2650b6173fb1c9b4838b3f2af4
child 76363 74e7ea3b71bea757c39f2b898441844bead28a53
push id21097
push userbmo@edmorley.co.uk
push dateThu, 01 Sep 2011 07:45:07 +0000
treeherdermozilla-central@7d3d1c2c75f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilor
bugs639720, 679689, 679671
milestone9.0a1
backs out89b87e96dc176cfc144d26e3140c52146e328feb
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backout 89b87e96dc17 (bug 639720), b449db7a038b (bug 679689) & ef216b965a04 (bug 679671) for Mochitest oranges, on a CLOSED TREE; a=philor
content/base/crashtests/679689-1.html
content/base/crashtests/crashtests.list
content/base/src/nsAttrValue.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfo.h
dom/tests/mochitest/dom-level0/Makefile.in
dom/tests/mochitest/dom-level0/test_location_setters.html
deleted file mode 100644
--- a/content/base/crashtests/679689-1.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<!DOCTYPE html>
-<img crossorigin>
--- a/content/base/crashtests/crashtests.list
+++ b/content/base/crashtests/crashtests.list
@@ -88,9 +88,8 @@ load 610571-1.html
 load 604262-1.html
 load 628599-1.html
 load 637214-1.svg
 load 637214-2.svg
 load 642022-1.html
 load 646184.html
 load 658845-1.svg
 load 667336-1.html
-load 679689-1.html
--- a/content/base/src/nsAttrValue.cpp
+++ b/content/base/src/nsAttrValue.cpp
@@ -1107,34 +1107,34 @@ nsAttrValue::ParseNonNegativeIntValue(co
 
   PRInt32 ec;
   PRBool strict;
   PRInt32 originalVal = StringToInteger(aString, &strict, &ec);
   if (NS_FAILED(ec) || originalVal < 0) {
     return PR_FALSE;
   }
 
-  SetIntValueAndType(originalVal, eInteger, strict ? nsnull : &aString);
+  SetIntValueAndType(originalVal, eInteger, nsnull);
 
   return PR_TRUE;
 }
 
 PRBool
 nsAttrValue::ParsePositiveIntValue(const nsAString& aString)
 {
   ResetIfSet();
 
   PRInt32 ec;
   PRBool strict;
   PRInt32 originalVal = StringToInteger(aString, &strict, &ec);
   if (NS_FAILED(ec) || originalVal <= 0) {
     return PR_FALSE;
   }
 
-  SetIntValueAndType(originalVal, eInteger, strict ? nsnull : &aString);
+  SetIntValueAndType(originalVal, eInteger, nsnull);
 
   return PR_TRUE;
 }
 
 void
 nsAttrValue::SetColorValue(nscolor aColor, const nsAString& aString)
 {
   nsStringBuffer* buf = GetStringBuffer(aString);
@@ -1245,24 +1245,20 @@ nsAttrValue::ParseIntMarginValue(const n
 void
 nsAttrValue::SetMiscAtomOrString(const nsAString* aValue)
 {
   NS_ASSERTION(GetMiscContainer(), "Must have MiscContainer!");
   NS_ASSERTION(!GetMiscContainer()->mStringBits,
                "Trying to re-set atom or string!");
   if (aValue) {
     PRUint32 len = aValue->Length();
-    // * We're allowing eCSSStyleRule attributes to store empty strings as it
-    //   can be beneficial to store an empty style attribute as a parsed rule.
-    // * We're allowing enumerated values because sometimes the empty
-    //   string corresponds to a particular enumerated value, especially
-    //   for enumerated values that are not limited enumerated.
+    // We're allowing eCSSStyleRule attributes to store empty strings as it
+    // can be beneficial to store an empty style attribute as a parsed rule.
     // Add other types as needed.
-    NS_ASSERTION(len || Type() == eCSSStyleRule || Type() == eEnum,
-                 "Empty string?");
+    NS_ASSERTION(len || Type() == eCSSStyleRule, "Empty string?");
     MiscContainer* cont = GetMiscContainer();
     if (len <= NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM) {
       nsIAtom* atom = NS_NewAtom(*aValue);
       if (atom) {
         cont->mStringBits = reinterpret_cast<PtrBits>(atom) | eAtomBase;
       }
     } else {
       nsStringBuffer* buf = GetStringBuffer(*aValue);
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -43,17 +43,16 @@
 #include "jsprvtd.h"    // we are using private JS typedefs...
 #include "jscntxt.h"
 #include "jsobj.h"
 #include "jsdbgapi.h"
 #include "WrapperFactory.h"
 #include "AccessCheck.h"
 
 #include "xpcprivate.h"
-#include "XPCWrapper.h"
 
 #include "nscore.h"
 #include "nsDOMClassInfo.h"
 #include "nsCRT.h"
 #include "nsCRTGlue.h"
 #include "nsIServiceManager.h"
 #include "nsICategoryManager.h"
 #include "nsIComponentRegistrar.h"
@@ -512,16 +511,17 @@ static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM
 static const char kDOMStringBundleURL[] =
   "chrome://global/locale/dom/dom.properties";
 
 // NOTE: DEFAULT_SCRIPTABLE_FLAGS and DOM_DEFAULT_SCRIPTABLE_FLAGS
 //       are defined in nsIDOMClassInfo.h.
 
 #define WINDOW_SCRIPTABLE_FLAGS                                               \
  (nsIXPCScriptable::WANT_GETPROPERTY |                                        \
+  nsIXPCScriptable::WANT_SETPROPERTY |                                        \
   nsIXPCScriptable::WANT_PRECREATE |                                          \
   nsIXPCScriptable::WANT_FINALIZE |                                           \
   nsIXPCScriptable::WANT_EQUALITY |                                           \
   nsIXPCScriptable::WANT_ENUMERATE |                                          \
   nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE |                               \
   nsIXPCScriptable::WANT_OUTER_OBJECT)
 
 #define NODE_SCRIPTABLE_FLAGS                                                 \
@@ -5265,16 +5265,49 @@ nsWindowSH::GetProperty(nsIXPConnectWrap
     *vp = OBJECT_TO_JSVAL(obj);
     return NS_SUCCESS_I_DID_SOMETHING;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsWindowSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
+                        JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
+{
+  if (id == sLocation_id) {
+    JSAutoRequest ar(cx);
+
+    JSString *val = ::JS_ValueToString(cx, *vp);
+    NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
+
+    nsCOMPtr<nsIDOMWindow> window = do_QueryWrappedNative(wrapper);
+    NS_ENSURE_TRUE(window, NS_ERROR_UNEXPECTED);
+
+    nsCOMPtr<nsIDOMLocation> location;
+    nsresult rv = window->GetLocation(getter_AddRefs(location));
+    NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && location, rv);
+
+    nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
+    rv = WrapNative(cx, obj, location, &NS_GET_IID(nsIDOMLocation), PR_TRUE,
+                    vp, getter_AddRefs(holder));
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    nsDependentJSString depStr;
+    NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED);
+
+    rv = location->SetHref(depStr);
+
+    return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
+  }
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsWindowSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                       JSObject *obj, PRBool *_retval)
 {
   if (!ObjectIsNativeWrapper(cx, obj)) {
     *_retval = JS_EnumerateStandardClasses(cx, obj);
   }
 
   return NS_OK;
@@ -6354,72 +6387,16 @@ ContentWindowGetter(JSContext *cx, uintN
 
   return ::JS_GetProperty(cx, obj, "content", vp);
 }
 
 static JSNewResolveOp sOtherResolveFuncs[] = {
   mozilla::dom::workers::ResolveWorkerClasses
 };
 
-template<class Interface>
-static nsresult
-LocationSetterGuts(JSContext *cx, JSObject *obj, jsval *vp)
-{
-  // This function duplicates some of the logic in XPC_WN_HelperSetProperty
-  XPCWrappedNative *wrapper =
-    XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
-
-  // The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
-  NS_ENSURE_TRUE(wrapper, NS_ERROR_XPC_BAD_OP_ON_WN_PROTO);
-  NS_ENSURE_TRUE(wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
-
-  nsresult rv = NS_OK;
-
-  nsCOMPtr<nsIDOMLocation> location;
-  nsCOMPtr<Interface> xpcomObj = do_QueryWrappedNative(wrapper);
-  NS_ENSURE_TRUE(xpcomObj, NS_ERROR_UNEXPECTED);
-
-  rv = xpcomObj->GetLocation(getter_AddRefs(location));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  JSString *val = ::JS_ValueToString(cx, *vp);
-  NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
-
-  nsDependentJSString depStr;
-  NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED);
-  
-  return location->SetHref(depStr);
-}
-
-template<class Interface>
-static JSBool
-LocationSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
-               jsval *vp)
-{
-  nsresult rv = LocationSetterGuts<Interface>(cx, obj, vp);
-  if (NS_FAILED(rv)) {
-    nsDOMClassInfo::ThrowJSException(cx, rv);
-    return JS_FALSE;
-  }
-
-  return JS_TRUE;
-}
-
-static JSBool
-LocationSetterUnwrapper(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
-                        jsval *vp)
-{
-  JSObject *wrapped = XPCWrapper::UnsafeUnwrapSecurityWrapper(obj);
-  if (wrapped) {
-    obj = wrapped;
-  }
-
-  return LocationSetter<nsIDOMWindow>(cx, obj, id, strict, vp);
-}
-
 NS_IMETHODIMP
 nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                        JSObject *obj, jsid id, PRUint32 flags,
                        JSObject **objp, PRBool *_retval)
 {
   nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
 
   if (!JSID_IS_STRING(id)) {
@@ -6562,18 +6539,17 @@ nsWindowSH::NewResolve(nsIXPConnectWrapp
 
     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
     jsval v;
     rv = WrapNative(cx, scope, location, &NS_GET_IID(nsIDOMLocation), PR_TRUE,
                     &v, getter_AddRefs(holder));
     NS_ENSURE_SUCCESS(rv, rv);
 
     JSBool ok = JS_WrapValue(cx, &v) &&
-                JS_DefinePropertyById(cx, obj, id, v, nsnull,
-                                      LocationSetterUnwrapper,
+                JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
                                       JSPROP_PERMANENT | JSPROP_ENUMERATE);
 
     if (!ok) {
       return NS_ERROR_FAILURE;
     }
 
     *objp = obj;
 
@@ -8196,18 +8172,17 @@ nsDocumentSH::NewResolve(nsIXPConnectWra
     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
     rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
                     &NS_GET_IID(nsIDOMLocation), PR_TRUE, &v,
                     getter_AddRefs(holder));
     NS_ENSURE_SUCCESS(rv, rv);
 
     JSAutoRequest ar(cx);
 
-    JSBool ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull,
-                                        LocationSetter<nsIDOMDocument>,
+    JSBool ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
                                         JSPROP_PERMANENT | JSPROP_ENUMERATE);
 
     if (!ok) {
       return NS_ERROR_FAILURE;
     }
 
     *objp = obj;
 
@@ -8242,16 +8217,44 @@ nsDocumentSH::GetProperty(nsIXPConnectWr
 
   return nsNodeSH::GetProperty(wrapper, cx, obj, id, vp, _retval);
 }
 
 NS_IMETHODIMP
 nsDocumentSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                           JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
 {
+  if (id == sLocation_id) {
+    nsCOMPtr<nsIDOMDocument> doc = do_QueryWrappedNative(wrapper);
+    NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
+
+    nsCOMPtr<nsIDOMLocation> location;
+    nsresult rv = doc->GetLocation(getter_AddRefs(location));
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    if (location) {
+      JSAutoRequest ar(cx);
+
+      JSString *val = ::JS_ValueToString(cx, *vp);
+      NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
+
+      nsDependentJSString depStr;
+      NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED);
+
+      rv = location->SetHref(depStr);
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
+      rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
+                      &NS_GET_IID(nsIDOMLocation), PR_TRUE, vp,
+                      getter_AddRefs(holder));
+      return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
+    }
+  }
+
   if (id == sDocumentURIObject_id && IsPrivilegedScript()) {
     // We don't want privileged script that can read this property to set it,
     // but _do_ want to allow everyone else to set a value they can then read.
     //
     // XXXbz Is there a better error we could use here?
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
   
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -402,16 +402,18 @@ public:
       *aFlags = flags | nsIXPCScriptable::WANT_POSTCREATE;
     }
 
     return rv;
   }
 #endif
   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                          JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
+  NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
+                         JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
   NS_IMETHOD Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                        JSObject *obj, PRBool *_retval);
   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                         JSObject *obj, jsid id, PRUint32 flags,
                         JSObject **objp, PRBool *_retval);
   NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                       JSObject *obj);
   NS_IMETHOD Equality(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
--- a/dom/tests/mochitest/dom-level0/Makefile.in
+++ b/dom/tests/mochitest/dom-level0/Makefile.in
@@ -50,13 +50,12 @@ include $(topsrcdir)/config/rules.mk
 		test_setting_document.domain_to_shortened_ipaddr.html \
 		child_ip_address.html \
 		test_setting_document.domain_idn.html \
 		idn_child.html \
 		file_location.html \
 		test_location.html \
 		test_innerWidthHeight_script.html \
 		innerWidthHeight_script.html \
-		test_location_setters.html \
 		$(NULL)
 
 libs:: 	$(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
deleted file mode 100644
--- a/dom/tests/mochitest/dom-level0/test_location_setters.html
+++ /dev/null
@@ -1,75 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=639720
--->
-<head>
-  <title>Test for Bug 639720</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=639720">Mozilla Bug 639720</a>
-<p id="display">
-  <iframe id="f"></iframe>
-</p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-/** Test for Bug 639720 **/
-SimpleTest.waitForExplicitFinish();
-
-var tests = [
- { url: "data:text/plain,1" },
- { url: "data:text/plain,2",
-   useDocument: true },
- { prepURL: "http://www.example.com",
-   url: "data:text/plain,3" }
-];
-
-var currentTest = 0;
-
-function checkTest() {
-  is($("f").contentWindow.location.href, tests[currentTest].url);
-  ++currentTest;
-  runNextTest();
-}
-
-function runCurrentTest() {
-  var test = tests[currentTest];
-  $("f").onload = checkTest;
-  if (test.useDocument) {
-    $("f").contentDocument.location = test.url;
-  } else {
-    $("f").contentWindow.location = test.url;
-  }
-}
-
-function prepComplete() {
-  runCurrentTest();
-}
-
-function runNextTest() {
-  if (currentTest == tests.length) {
-    SimpleTest.finish();
-    return;
-  }
-
-  var test = tests[currentTest];
-  if ("prepURL" in test) {
-    $("f").onload = prepComplete;
-    $("f").src = test.prepURL;
-    return;
-  }
-
-  runCurrentTest();
-}
-
-addLoadEvent(runNextTest);
-</script>
-</pre>
-</body>
-</html>