Bug 718923 - Support document.all in standards mode and remove the pref to turn it off; r=smaug
authorMs2ger <ms2ger@gmail.com>
Wed, 12 Jun 2013 08:48:38 +0200
changeset 141821 c1ed5d80b9d0ccd5b50b5a224401e22d5951f1fe
parent 141820 03c9edd7ea174b28afbfb9fb26b5767e056b62c0
child 141822 135a277d13194b78612fb30be8ee744ce749614a
push id3911
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 20:17:26 +0000
treeherdermozilla-aurora@7e26ca8db92b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs718923
milestone24.0a1
Bug 718923 - Support document.all in standards mode and remove the pref to turn it off; r=smaug
browser/devtools/webconsole/test/Makefile.in
browser/devtools/webconsole/test/browser_webconsole_bug_595934_message_categories.js
browser/devtools/webconsole/test/test-bug-595934-dom-html-external.html
browser/devtools/webconsole/test/test-bug-595934-dom-html-external.js
browser/devtools/webconsole/test/test-bug-595934-dom-html.html
content/html/document/src/nsHTMLDocument.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfo.h
dom/locales/en-US/chrome/dom/dom.properties
--- a/browser/devtools/webconsole/test/Makefile.in
+++ b/browser/devtools/webconsole/test/Makefile.in
@@ -168,25 +168,22 @@ MOCHITEST_BROWSER_FILES += \
 	test-encoding-ISO-8859-1.html \
 	test-bug-593003-iframe-wrong-hud.html \
 	test-bug-593003-iframe-wrong-hud-iframe.html \
 	test-console-replaced-api.html \
 	test-own-console.html \
 	test-bug-595934-css-loader.html \
 	test-bug-595934-css-loader.css \
 	test-bug-595934-css-loader.css^headers^ \
-	test-bug-595934-dom-html.html \
 	test-bug-595934-imagemap.html \
 	test-bug-595934-html.html \
 	test-bug-595934-malformedxml.xhtml \
 	test-bug-595934-svg.xhtml \
 	test-bug-595934-workers.html \
 	test-bug-595934-workers.js \
-	test-bug-595934-dom-html-external.html \
-	test-bug-595934-dom-html-external.js \
 	test-bug-595934-canvas.html \
 	test-bug-595934-canvas.js \
 	test-bug-595934-css-parser.html \
 	test-bug-595934-css-parser.css \
 	test-bug-595934-canvas-css.html \
 	test-bug-595934-canvas-css.js \
 	test-bug-595934-malformedxml-external.html \
 	test-bug-595934-malformedxml-external.xml \
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_595934_message_categories.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_595934_message_categories.js
@@ -11,81 +11,71 @@
 const TESTS_PATH = "http://example.com/browser/browser/devtools/webconsole/test/";
 const TESTS = [
   { // #0
     file: "test-bug-595934-css-loader.html",
     category: "CSS Loader",
     matchString: "text/css",
   },
   { // #1
-    file: "test-bug-595934-dom-html.html",
-    category: "DOM:HTML",
-    matchString: "getElementById",
-  },
-  { // #2
     file: "test-bug-595934-imagemap.html",
     category: "ImageMap",
     matchString: "shape=\"rect\"",
   },
-  { // #3
+  { // #2
     file: "test-bug-595934-html.html",
     category: "HTML",
     matchString: "multipart/form-data",
     onload: function() {
       let form = content.document.querySelector("form");
       form.submit();
     },
   },
-  { // #4
+  { // #3
     file: "test-bug-595934-workers.html",
     category: "Web Worker",
     matchString: "fooBarWorker",
     expectError: true,
   },
-  { // #5
+  { // #4
     file: "test-bug-595934-malformedxml.xhtml",
     category: "malformed-xml",
     matchString: "no element found",
   },
-  { // #6
+  { // #5
     file: "test-bug-595934-svg.xhtml",
     category: "SVG",
     matchString: "fooBarSVG",
   },
-  { // #7
-    file: "test-bug-595934-dom-html-external.html",
-    category: "DOM:HTML",
-    matchString: "document.all",
-  },
-  { // #8
+  { // #6
     file: "test-bug-595934-canvas.html",
     category: "Canvas",
     matchString: "strokeStyle",
   },
-  { // #9
+  { // #7
     file: "test-bug-595934-css-parser.html",
     category: "CSS Parser",
     matchString: "foobarCssParser",
   },
-  { // #10
+  { // #8
     file: "test-bug-595934-malformedxml-external.html",
     category: "malformed-xml",
     matchString: "</html>",
   },
-  { // #11
+  { // #9
     file: "test-bug-595934-empty-getelementbyid.html",
     category: "DOM",
     matchString: "getElementById",
   },
-  { // #12
+  { // #10
     file: "test-bug-595934-canvas-css.html",
     category: "CSS Parser",
     matchString: "foobarCanvasCssParser",
   },
-  { // #13
+  { // #11
     file: "test-bug-595934-image.html",
     category: "Image",
     matchString: "corrupt",
   },
 ];
 
 let pos = -1;
 
deleted file mode 100644
--- a/browser/devtools/webconsole/test/test-bug-595934-dom-html-external.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <title>Web Console test for bug 595934 - category: DOM:HTML
-      (external script)</title>
-<!-- Any copyright is dedicated to the Public Domain.
-     http://creativecommons.org/publicdomain/zero/1.0/ -->
-    <script type="text/javascript" src="test-bug-595934-dom-html-external.js"></script>
-  </head>
-  <body>
-    <p id="foobar">Web Console test for bug 595934 - category "DOM:HTML" 
-    (external script).</p>
-  </body>
-</html>
deleted file mode 100644
--- a/browser/devtools/webconsole/test/test-bug-595934-dom-html-external.js
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-window.addEventListener("load", function() {
-  document.all.foobar.style.color = "#00f";
-}, false);
-
deleted file mode 100644
--- a/browser/devtools/webconsole/test/test-bug-595934-dom-html.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <title>Web Console test for bug 595934 - category: DOM:HTML</title>
-<!-- Any copyright is dedicated to the Public Domain.
-     http://creativecommons.org/publicdomain/zero/1.0/ -->
-    <script type="text/javascript"><!--
-      window.addEventListener("load", function() {
-        document.all.foobar.style.color = "#00f";
-      }, false);
-    // --></script>
-  </head>
-  <body>
-    <p id="foobar">Web Console test for bug 595934 - category "DOM:HTML".</p>
-  </body>
-</html>
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -2305,18 +2305,17 @@ nsHTMLDocument::ResolveName(const nsAStr
 JSObject*
 nsHTMLDocument::NamedGetter(JSContext* cx, const nsAString& aName, bool& aFound,
                             ErrorResult& rv)
 {
   nsWrapperCache* cache;
   nsISupports* supp = ResolveName(aName, &cache);
   if (!supp) {
     aFound = false;
-    if (GetCompatibilityMode() == eCompatibility_NavQuirks &&
-        aName.EqualsLiteral("all")) {
+    if (aName.EqualsLiteral("all")) {
       JS::Rooted<JSObject*> obj(cx, GetWrapper());
       rv = nsHTMLDocumentSH::TryResolveAll(cx, this, obj);
     }
     return nullptr;
   }
 
   JS::Rooted<JS::Value> val(cx);
   { // Scope for auto-compartment
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -860,17 +860,16 @@ static const nsConstructorFuncMapData kC
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XSLTProcessor, XSLTProcessorCtor)
 };
 #undef NS_DEFINE_CONSTRUCTOR_FUNC_DATA
 #undef NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA
 
 nsIXPConnect *nsDOMClassInfo::sXPConnect = nullptr;
 nsIScriptSecurityManager *nsDOMClassInfo::sSecMan = nullptr;
 bool nsDOMClassInfo::sIsInitialized = false;
-bool nsDOMClassInfo::sDisableDocumentAllSupport = false;
 
 
 jsid nsDOMClassInfo::sParent_id          = JSID_VOID;
 jsid nsDOMClassInfo::sScrollbars_id      = JSID_VOID;
 jsid nsDOMClassInfo::sLocation_id        = JSID_VOID;
 jsid nsDOMClassInfo::sConstructor_id     = JSID_VOID;
 jsid nsDOMClassInfo::s_content_id        = JSID_VOID;
 jsid nsDOMClassInfo::sContent_id         = JSID_VOID;
@@ -913,76 +912,16 @@ FindObjectClass(JSContext* cx, JSObject*
   do {
     obj = proto;
     js::GetObjectProto(cx, obj, &proto);
   } while (proto);
 
   sObjectClass = js::GetObjectJSClass(obj);
 }
 
-static void
-PrintWarningOnConsole(JSContext *cx, const char *stringBundleProperty)
-{
-  nsCOMPtr<nsIStringBundleService> stringService =
-    mozilla::services::GetStringBundleService();
-  if (!stringService) {
-    return;
-  }
-
-  nsCOMPtr<nsIStringBundle> bundle;
-  stringService->CreateBundle(kDOMStringBundleURL, getter_AddRefs(bundle));
-  if (!bundle) {
-    return;
-  }
-
-  nsXPIDLString msg;
-  bundle->GetStringFromName(NS_ConvertASCIItoUTF16(stringBundleProperty).get(),
-                            getter_Copies(msg));
-
-  if (msg.IsEmpty()) {
-    NS_ERROR("Failed to get strings from dom.properties!");
-    return;
-  }
-
-  nsCOMPtr<nsIConsoleService> consoleService
-    (do_GetService(NS_CONSOLESERVICE_CONTRACTID));
-  if (!consoleService) {
-    return;
-  }
-
-  nsCOMPtr<nsIScriptError> scriptError =
-    do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
-  if (!scriptError) {
-    return;
-  }
-
-  unsigned lineno = 0;
-  JSScript *script;
-  nsAutoString sourcefile;
-
-  if (JS_DescribeScriptedCaller(cx, &script, &lineno)) {
-    if (const char *filename = ::JS_GetScriptFilename(cx, script)) {
-      CopyUTF8toUTF16(nsDependentCString(filename), sourcefile);
-    }
-  }
-
-  nsresult rv = scriptError->InitWithWindowID(msg,
-                                              sourcefile,
-                                              EmptyString(),
-                                              lineno,
-                                              0, // column for error is not available
-                                              nsIScriptError::warningFlag,
-                                              "DOM:HTML",
-                                              nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx));
-
-  if (NS_SUCCEEDED(rv)) {
-    consoleService->LogMessage(scriptError);
-  }
-}
-
 static inline JSString *
 IdToString(JSContext *cx, jsid id)
 {
   if (JSID_IS_STRING(id))
     return JSID_TO_STRING(id);
   jsval idval;
   if (!::JS_IdToValue(cx, id, &idval))
     return nullptr;
@@ -2031,19 +1970,16 @@ nsDOMClassInfo::Init()
   }
 
   for (i = 0; i < eDOMClassInfoIDCount; ++i) {
     RegisterClassProtos(i);
   }
 
   RegisterExternalClasses();
 
-  sDisableDocumentAllSupport =
-    Preferences::GetBool("browser.dom.document.all.disabled");
-
   // Register new DOM bindings
   mozilla::dom::Register(nameSpaceManager);
 
   sIsInitialized = true;
 
   return NS_OK;
 }
 
@@ -6094,19 +6030,16 @@ ResolveAll(JSContext* cx, nsIDocument* d
     } while (tmpProto != helper);
 
     ::JS_SetPrototype(cx, tmp, proto);
   }
 
   // If we don't already have a helper and "all" isn't already defined on
   // our prototype, create a helper.
   if (!helper && !hasAll) {
-    // Print a warning so developers can stop using document.all
-    PrintWarningOnConsole(cx, "DocumentAllUsed");
-
     if (!::JS_GetPrototype(cx, obj, proto.address())) {
       return NS_ERROR_UNEXPECTED;
     }
     helper = ::JS_NewObject(cx, &sHTMLDocumentAllHelperClass,
                             proto,
                             ::JS_GetGlobalForObject(cx, obj));
 
     if (!helper) {
@@ -6123,19 +6056,16 @@ ResolveAll(JSContext* cx, nsIDocument* d
 
   return NS_OK;
 }
 
 nsresult
 nsHTMLDocumentSH::TryResolveAll(JSContext* cx, nsHTMLDocument* doc,
                                 JS::Handle<JSObject*> obj)
 {
-  if (nsDOMClassInfo::sDisableDocumentAllSupport) {
-    return NS_OK;
-  }
   JSAutoCompartment ac(cx, obj);
   return ResolveAll(cx, doc, obj);
 }
 
 // HTMLFormElement helper
 
 NS_IMETHODIMP
 nsHTMLFormElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -184,17 +184,16 @@ protected:
 
   static nsIXPConnect *sXPConnect;
   static nsIScriptSecurityManager *sSecMan;
 
   // nsIXPCScriptable code
   static nsresult DefineStaticJSVals(JSContext *cx);
 
   static bool sIsInitialized;
-  static bool sDisableDocumentAllSupport;
 
 public:
   static jsid sParent_id;
   static jsid sScrollbars_id;
   static jsid sLocation_id;
   static jsid sConstructor_id;
   static jsid s_content_id;
   static jsid sContent_id;
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -11,17 +11,16 @@ DebugScriptButton=Debug script
 WaitForScriptButton=Continue
 DontAskAgain=&Don't ask me again
 JSURLLoadBlockedWarning=Attempt to load a javascript: URL from one host\nin a window displaying content from another host\nwas blocked by the security manager.
 WindowCloseBlockedWarning=Scripts may not close windows that were not opened by script.
 OnBeforeUnloadTitle=Are you sure?
 OnBeforeUnloadMessage=This page is asking you to confirm that you want to leave - data you have entered may not be saved.
 OnBeforeUnloadStayButton=Stay on Page
 OnBeforeUnloadLeaveButton=Leave Page
-DocumentAllUsed=Non-standard document.all property was used. Use W3C standard document.getElementById() instead.
 UseOfDOM3LoadMethodWarning=Use of Document.load() is deprecated. To upgrade your code, use the DOM XMLHttpRequest object. For more help https://developer.mozilla.org/en/XMLHttpRequest
 UnexpectedCanvasVariantStyle=canvas: an attempt to set strokeStyle or fillStyle to a value that is neither a string, a CanvasGradient, or a CanvasPattern was ignored.
 EmptyGetElementByIdParam=Empty string passed to getElementById().
 LowMemoryTitle=Warning: Low memory
 LowMemoryMessage=A script on this page has been stopped due to a low memory condition.
 SpeculationFailed=An unbalanced tree was written using document.write() causing data from the network to be reparsed. For more information https://developer.mozilla.org/en/Optimizing_Your_Pages_for_Speculative_Parsing
 DocumentWriteIgnored=A call to document.write() from an asynchronously-loaded external script was ignored.
 FormValidationTextTooLong=Please shorten this text to %S characters or less (you are currently using %S characters).