Bug 969030 - Remove support for calling document.all; r=bz
authorMs2ger <ms2ger@gmail.com>
Sun, 09 Feb 2014 09:04:40 +0100
changeset 167748 c8cd1f6b6d2d20642b17df6de1e9bcf7923ce722
parent 167747 d30a9c28e77e00a08b862afcc0516cc2b817f1fc
child 167760 8d405618dc9865157144964fa4dec61d5f24bb71
push id39533
push userMs2ger@gmail.com
push dateSun, 09 Feb 2014 09:32:46 +0000
treeherdermozilla-inbound@7133bb431eba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs969030
milestone30.0a1
first release with
nightly linux32
c8cd1f6b6d2d / 30.0a1 / 20140209030203 / files
nightly linux64
c8cd1f6b6d2d / 30.0a1 / 20140209030203 / files
nightly mac
c8cd1f6b6d2d / 30.0a1 / 20140209030203 / files
nightly win32
c8cd1f6b6d2d / 30.0a1 / 20140209030203 / files
nightly win64
c8cd1f6b6d2d / 30.0a1 / 20140209030203 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 969030 - Remove support for calling document.all; r=bz
content/html/document/src/HTMLAllCollection.cpp
dom/base/test/test_nondomexception.html
--- a/content/html/document/src/HTMLAllCollection.cpp
+++ b/content/html/document/src/HTMLAllCollection.cpp
@@ -32,21 +32,20 @@ public:
 const JSClass sHTMLDocumentAllClass = {
   "HTML document.all class",
   JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_NEW_RESOLVE |
   JSCLASS_EMULATES_UNDEFINED,
   JS_PropertyStub,                                         /* addProperty */
   JS_DeletePropertyStub,                                   /* delProperty */
   nsHTMLDocumentSH::DocumentAllGetProperty,                /* getProperty */
   JS_StrictPropertyStub,                                   /* setProperty */
-  JS_EnumerateStub,
-  (JSResolveOp)nsHTMLDocumentSH::DocumentAllNewResolve,
-  JS_ConvertStub,
-  nsHTMLDocumentSH::ReleaseDocument,
-  nsHTMLDocumentSH::CallToGetPropMapper
+  JS_EnumerateStub,                                        /* enumerate */
+  (JSResolveOp)nsHTMLDocumentSH::DocumentAllNewResolve,    /* resolve */
+  JS_ConvertStub,                                          /* convert */
+  nsHTMLDocumentSH::ReleaseDocument                        /* finalize */
 };
 
 namespace mozilla {
 namespace dom {
 
 HTMLAllCollection::HTMLAllCollection(nsHTMLDocument* aDocument)
   : mDocument(aDocument)
 {
@@ -367,43 +366,34 @@ nsHTMLDocumentSH::ReleaseDocument(JSFree
     nsContentUtils::DeferredFinalize(doc);
   }
 }
 
 bool
 nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp)
 {
   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
-  // Handle document.all("foo") style access to document.all.
 
   if (args.length() != 1) {
     // XXX: Should throw NS_ERROR_XPC_NOT_ENOUGH_ARGS for argc < 1,
     // and create a new NS_ERROR_XPC_TOO_MANY_ARGS for argc > 1? IE
     // accepts nothing other than one arg.
     xpc::Throw(cx, NS_ERROR_INVALID_ARG);
-
     return false;
   }
 
   // Convert all types to string.
   JS::Rooted<JSString*> str(cx, JS::ToString(cx, args[0]));
   if (!str) {
     return false;
   }
 
-  // If we are called via document.all(id) instead of document.all.item(i) or
-  // another method, use the document.all callee object as self.
-  JS::Rooted<JSObject*> self(cx);
-  if (args.calleev().isObject() &&
-      JS_GetClass(&args.calleev().toObject()) == &sHTMLDocumentAllClass) {
-    self = &args.calleev().toObject();
-  } else {
-    self = JS_THIS_OBJECT(cx, vp);
-    if (!self)
-      return false;
+  JS::Rooted<JSObject*> self(cx, JS_THIS_OBJECT(cx, vp));
+  if (!self) {
+    return false;
   }
 
   size_t length;
   JS::Anchor<JSString *> anchor(str);
   const jschar *chars = ::JS_GetStringCharsAndLength(cx, str, &length);
   if (!chars) {
     return false;
   }
--- a/dom/base/test/test_nondomexception.html
+++ b/dom/base/test/test_nondomexception.html
@@ -10,17 +10,17 @@
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 <script class="testbody" type="application/javascript;version=1.7">
 "use strict";
 
 try {
-  document.all();
+  document.all.item();
 } catch (e) {
   is(typeof e, "object");
   is(e.filename, location);
   is(e.lineNumber, 18);
 }
 
 </script>
 </pre>