Bug 1453869 part 1. Remove the unused 3-arg constructor from DOMParser. r=mrbkap
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Apr 2018 23:01:24 -0400
changeset 468451 2bf23b953d5bbb0f3b7dc440906a50955fc429f8
parent 468450 65f8a6ed6a18d23415eac3c714a3482499f80fbc
child 468452 5576b25f547b61d27ac42c3bdba683a013a57d72
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1453869
milestone61.0a1
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
Bug 1453869 part 1. Remove the unused 3-arg constructor from DOMParser. r=mrbkap MozReview-Commit-ID: 1fWzq6rMWf1
dom/base/DOMParser.cpp
dom/base/DOMParser.h
dom/base/test/chrome/test_domparsing.xul
dom/webidl/DOMParser.webidl
--- a/dom/base/DOMParser.cpp
+++ b/dom/base/DOMParser.cpp
@@ -359,34 +359,16 @@ DOMParser::Init(nsIPrincipal* principal,
 
   MOZ_ASSERT(mPrincipal, "Must have principal");
   MOZ_ASSERT(mDocumentURI, "Must have document URI");
   return NS_OK;
 }
 
 /*static */already_AddRefed<DOMParser>
 DOMParser::Constructor(const GlobalObject& aOwner,
-                       nsIPrincipal* aPrincipal, nsIURI* aDocumentURI,
-                       nsIURI* aBaseURI, ErrorResult& rv)
-{
-  if (aOwner.CallerType() != CallerType::System) {
-    rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
-    return nullptr;
-  }
-  RefPtr<DOMParser> domParser = new DOMParser(aOwner.GetAsSupports());
-  rv = domParser->InitInternal(aOwner.GetAsSupports(), aPrincipal, aDocumentURI,
-                               aBaseURI);
-  if (rv.Failed()) {
-    return nullptr;
-  }
-  return domParser.forget();
-}
-
-/*static */already_AddRefed<DOMParser>
-DOMParser::Constructor(const GlobalObject& aOwner,
                        ErrorResult& rv)
 {
   RefPtr<DOMParser> domParser = new DOMParser(aOwner.GetAsSupports());
   rv = domParser->InitInternal(aOwner.GetAsSupports(),
                                nsContentUtils::SubjectPrincipal(),
                                nullptr, nullptr);
   if (rv.Failed()) {
     return nullptr;
--- a/dom/base/DOMParser.h
+++ b/dom/base/DOMParser.h
@@ -39,21 +39,16 @@ public:
   // nsIDOMParser
   NS_DECL_NSIDOMPARSER
 
   // WebIDL API
   static already_AddRefed<DOMParser>
   Constructor(const GlobalObject& aOwner,
               mozilla::ErrorResult& rv);
 
-  static already_AddRefed<DOMParser>
-  Constructor(const GlobalObject& aOwner,
-              nsIPrincipal* aPrincipal, nsIURI* aDocumentURI, nsIURI* aBaseURI,
-              mozilla::ErrorResult& rv);
-
   already_AddRefed<nsIDocument>
   ParseFromString(const nsAString& aStr, mozilla::dom::SupportedType aType,
                   mozilla::ErrorResult& rv);
 
   already_AddRefed<nsIDocument>
   ParseFromBuffer(const mozilla::dom::Sequence<uint8_t>& aBuf,
                   uint32_t aBufLen, mozilla::dom::SupportedType aType,
                   mozilla::ErrorResult& rv);
--- a/dom/base/test/chrome/test_domparsing.xul
+++ b/dom/base/test/chrome/test_domparsing.xul
@@ -11,41 +11,36 @@
      target="_blank">Mozilla Bug 816410</a>
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
 "use strict";
 /** Test for Bug 816410 **/
 
-function throws(a, type, message) {
-  for (let fn of Array.isArray(a) ? a : [a]) {
-    try {
-      fn();
-      ok(false, message);
-    } catch (e) {
-      if (type) {
-        is(e.name, type, message);
-      } else {
-        ok(true, message);
-      }
+function throws(fn, type, message) {
+  try {
+    fn();
+    ok(false, message);
+  } catch (e) {
+    if (type) {
+      is(e.name, type, message);
+    } else {
+      ok(true, message);
     }
   }
 }
 
-// DOMParser constructor should not throw for null arguments
+// DOMParser constructor should not throw for extra arguments
 new DOMParser(undefined);
 new DOMParser(null);
-
-throws([
-  function() { new DOMParser(false); },
-  function() { new DOMParser(0); },
-  function() { new DOMParser(""); },
-  function() { new DOMParser({}); },
-], "TypeError", "DOMParser constructor should throw for extra arguments");
+new DOMParser(false);
+new DOMParser(0);
+new DOMParser("");
+new DOMParser({});
 
 {
   let parser = new DOMParser();
   throws(function() {
     parser.init();
   }, "NS_ERROR_UNEXPECTED", "init method should throw when DOMParser is created by constructor");
 }
 
--- a/dom/webidl/DOMParser.webidl
+++ b/dom/webidl/DOMParser.webidl
@@ -14,19 +14,17 @@ enum SupportedType {
   "text/html",
   "text/xml",
   "application/xml",
   "application/xhtml+xml",
   "image/svg+xml"
 };
 
 // the latter is Mozilla-specific
-[Constructor,
- Constructor(Principal? prin, optional URI? documentURI = null,
-             optional URI? baseURI = null)]
+[Constructor]
 interface DOMParser {
   [NewObject, Throws]
   Document parseFromString(DOMString str, SupportedType type);
 
   // Mozilla-specific stuff
   // Throws if the passed-in length is greater than the actual sequence length
   [NewObject, Throws, ChromeOnly]
   Document parseFromBuffer(sequence<octet> buf, unsigned long bufLen,