Back out bug 783129 / b0788a95a2bd (merged with e01ca7212c8a) due to test failures
authorGavin Sharp <gavin@gavinsharp.com>
Fri, 21 Dec 2012 18:50:00 -0500
changeset 116843 972c3e4a494f07a127bd25f90967025baaff8793
parent 116842 495e435f86d91ec588bc1c77bc4739779dd6cf9a
child 116844 d7c7bc64a114b0609621362677eb43a0a454a870
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs783129
milestone20.0a1
Back out bug 783129 / b0788a95a2bd (merged with e01ca7212c8a) due to test failures
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/base/src/nsNodeUtils.h
content/events/src/nsEventDispatcher.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfo.h
dom/interfaces/core/nsIDOMDocument.idl
dom/interfaces/events/Makefile.in
dom/interfaces/events/nsIDOMElementReplaceEvent.idl
dom/tests/mochitest/Makefile.in
dom/tests/mochitest/general/test_interfaces.html
dom/tests/mochitest/webcomponents/Makefile.in
dom/tests/mochitest/webcomponents/test_document_register.html
dom/tests/mochitest/webcomponents/test_document_register_lifecycle.html
js/xpconnect/src/dictionary_helper_gen.conf
js/xpconnect/src/event_impl_gen.conf.in
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -56,17 +56,16 @@
 #include "nsRange.h"
 #include "nsIDOMText.h"
 #include "nsIDOMComment.h"
 #include "nsDOMDocumentType.h"
 #include "nsNodeIterator.h"
 #include "nsTreeWalker.h"
 
 #include "nsIServiceManager.h"
-#include "nsDOMClassInfo.h"
 
 #include "nsContentCID.h"
 #include "nsError.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsIJSON.h"
 #include "nsThreadUtils.h"
 #include "nsNodeInfoManager.h"
@@ -131,22 +130,20 @@
 #include "nsIDocumentLoaderFactory.h"
 #include "nsIDocumentLoader.h"
 #include "nsIContentViewer.h"
 #include "nsIXMLContentSink.h"
 #include "nsIXULDocument.h"
 #include "nsIPrompt.h"
 #include "nsIPropertyBag2.h"
 #include "nsIDOMPageTransitionEvent.h"
-#include "nsJSUtils.h"
 #include "nsFrameLoader.h"
 #include "nsEscape.h"
 #include "nsObjectLoadingContent.h"
 #include "nsHtml5TreeOpExecutor.h"
-#include "nsIDOMElementReplaceEvent.h"
 #ifdef MOZ_MEDIA
 #include "nsHTMLMediaElement.h"
 #endif // MOZ_MEDIA
 #ifdef MOZ_WEBRTC
 #include "IPeerConnection.h"
 #endif // MOZ_WEBRTC
 
 #include "mozAutoDocUpdate.h"
@@ -166,17 +163,16 @@
 #include "nsIContentSecurityPolicy.h"
 #include "nsCSPService.h"
 #include "nsHTMLStyleSheet.h"
 #include "nsHTMLCSSStyleSheet.h"
 #include "mozilla/dom/DOMImplementation.h"
 #include "mozilla/dom/Link.h"
 #include "nsXULAppAPI.h"
 #include "nsDOMTouchEvent.h"
-#include "DictionaryHelpers.h"
 
 #include "mozilla/Preferences.h"
 
 #include "imgILoader.h"
 #include "imgRequestProxy.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsSandboxFlags.h"
 #include "nsIAppsService.h"
@@ -192,18 +188,16 @@ typedef nsTArray<Link*> LinkArray;
 
 // Reference to the document which requested DOM full-screen mode.
 nsWeakPtr nsDocument::sFullScreenDoc = nullptr;
 
 // Reference to the root document of the branch containing the document
 // which requested DOM full-screen mode.
 nsWeakPtr nsDocument::sFullScreenRootDoc = nullptr;
 
-nsIDOMElement* nsDocument::sCurrentUpgradeElement = nullptr;
-
 #ifdef PR_LOGGING
 static PRLogModuleInfo* gDocumentLeakPRLog;
 static PRLogModuleInfo* gCspPRLog;
 #endif
 
 #define NAME_NOT_VALID ((nsSimpleContentList*)1)
 
 nsIdentifierMapEntry::~nsIdentifierMapEntry()
@@ -1374,21 +1368,16 @@ nsDocument::~nsDocument()
   nsCycleCollector_DEBUG_wasFreed(static_cast<nsIDocument*>(this));
 #endif
 
   NS_ASSERTION(!mIsShowing, "Destroying a currently-showing document");
 
   mInDestructor = true;
   mInUnlinkOrDeletion = true;
 
-  nsISupports* supports;
-  QueryInterface(NS_GET_IID(nsCycleCollectionISupports), reinterpret_cast<void**>(&supports));
-  NS_ASSERTION(supports, "Failed to QI to nsCycleCollectionISupports?!");
-  nsContentUtils::DropJSObjects(supports);
-
   // Clear mObservers to keep it in sync with the mutationobserver list
   mObservers.Clear();
 
   if (mStyleSheetSetList) {
     mStyleSheetSetList->Disconnect();
   }
 
   if (mAnimationController) {
@@ -1704,35 +1693,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   }
 
   if (tmp->mCSSLoader) {
     tmp->mCSSLoader->TraverseCachedSheets(cb);
   }
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 
-struct CustomPrototypeTraceArgs {
-  TraceCallback callback;
-  void* closure;
-};
-
-
-static PLDHashOperator
-CustomPrototypeTrace(const nsAString& aName, JSObject* aObject, void *aArg)
-{
-  CustomPrototypeTraceArgs* traceArgs = static_cast<CustomPrototypeTraceArgs*>(aArg);
-  MOZ_ASSERT(aObject, "Protocol object value must not be null");
-  traceArgs->callback(aObject, "mCustomPrototypes entry", traceArgs->closure);
-  return PL_DHASH_NEXT;
-}
-
-
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsDocument)
-  CustomPrototypeTraceArgs customPrototypeArgs = { aCallback, aClosure };
-  tmp->mCustomPrototypes.EnumerateRead(CustomPrototypeTrace, &customPrototypeArgs);
   nsINode::Trace(tmp, aCallback, aClosure);
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
   tmp->mInUnlinkOrDeletion = true;
 
   // Clear out our external resources
@@ -1786,18 +1757,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
   tmp->mRadioGroups.Clear();
 
   // nsDocument has a pretty complex destructor, so we're going to
   // assume that *most* cycles you actually want to break somewhere
   // else, and not unlink an awful lot here.
 
   tmp->mIdentifierMap.Clear();
 
-  tmp->mCustomPrototypes.Clear();
-
   if (tmp->mAnimationController) {
     tmp->mAnimationController->Unlink();
   }
 
   tmp->mPendingTitleChangeEvent.Revoke();
 
   if (tmp->mCSSLoader) {
     tmp->mCSSLoader->UnlinkCachedSheets();
@@ -1812,17 +1781,16 @@ nsDocument::Init()
 {
   if (mCSSLoader || mStyleImageLoader || mNodeInfoManager || mScriptLoader) {
     return NS_ERROR_ALREADY_INITIALIZED;
   }
 
   mIdentifierMap.Init();
   mStyledLinks.Init();
   mRadioGroups.Init();
-  mCustomPrototypes.Init();
 
   // Force initialization.
   nsINode::nsSlots* slots = Slots();
 
   // Prepend self as mutation-observer whether we need it or not (some
   // subclasses currently do, other don't). This is because the code in
   // nsNodeUtils always notifies the first observer first, expecting the
   // first observer to be the document.
@@ -1849,25 +1817,16 @@ nsDocument::Init()
 
   NS_ASSERTION(OwnerDoc() == this, "Our nodeinfo is busted!");
 
   mScriptLoader = new nsScriptLoader(this);
 
   mImageTracker.Init();
   mPlugins.Init();
 
-  nsXPCOMCycleCollectionParticipant* participant;
-  CallQueryInterface(this, &participant);
-  NS_ASSERTION(participant, "Failed to QI to nsXPCOMCycleCollectionParticipant!");
-
-  nsISupports* thisSupports;
-  QueryInterface(NS_GET_IID(nsCycleCollectionISupports), reinterpret_cast<void**>(&thisSupports));
-  NS_ASSERTION(thisSupports, "Failed to QI to nsCycleCollectionISupports!");
-  nsContentUtils::HoldJSObjects(thisSupports, participant);
-
   return NS_OK;
 }
 
 void
 nsIDocument::DeleteAllProperties()
 {
   for (uint32_t i = 0; i < GetPropertyTableCount(); ++i) {
     PropertyTable(i)->DeleteAllProperties();
@@ -4622,228 +4581,16 @@ nsDocument::GetElementsByTagName(const n
   nsRefPtr<nsContentList> list = GetElementsByTagName(aTagname);
   NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
 
   // transfer ref to aReturn
   *aReturn = list.forget().get();
   return NS_OK;
 }
 
-static JSBool
-CustomElementConstructor(JSContext *aCx, unsigned aArgc, JS::Value* aVp)
-{
-  JS::CallArgs args = JS::CallArgsFromVp(aArgc, aVp);
-
-  JSObject* global = JS_GetGlobalForObject(aCx, &args.callee());
-  nsCOMPtr<nsPIDOMWindow> window = do_QueryWrapper(aCx, global);
-  MOZ_ASSERT(window, "Should have a non-null window");
-
-  nsIDocument* document = window->GetDoc();
-
-  // Function name is the type of the custom element.
-  JSString* jsFunName = JS_GetFunctionId(JS_ValueToFunction(aCx,
-                                                            args.calleev()));
-  nsDependentJSString elemName;
-  if (!elemName.init(aCx, jsFunName)) {
-    return false;
-  }
-
-  nsCOMPtr<nsIContent> newElement;
-  nsresult rv = document->CreateElem(elemName, nullptr, kNameSpaceID_XHTML,
-                                     getter_AddRefs(newElement));
-  JS::Value v;
-  rv = nsContentUtils::WrapNative(aCx, global, newElement,
-                                  (nsWrapperCache*) nullptr, &v);
-  NS_ENSURE_SUCCESS(rv, false);
-
-  JS_SET_RVAL(aCx, aVp, v);
-  return true;
-}
-
-static nsresult
-GetPrototypeFromClassInfoId(JSContext* aCx, JSObject* aScope,
-                            nsDOMClassInfoID aClassInfoId,
-                            JSObject** aPrototype)
-{
-  nsIXPConnect* xpc = nsContentUtils::XPConnect();
-
-  nsIClassInfo* classInfo = NS_GetDOMClassInfoInstance(aClassInfoId);
-  NS_ENSURE_TRUE(classInfo, NS_ERROR_UNEXPECTED);
-
-  nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
-  nsresult rv = xpc->GetWrappedNativePrototype(aCx, aScope, classInfo,
-                                               getter_AddRefs(holder));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  JSObject* interface;
-  rv = holder->GetJSObject(&interface);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aPrototype = interface;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDocument::Register(const nsAString& aName, const JS::Value& aOptions,
-                     JSContext* aCx, uint8_t aArgc,
-                     jsval* aConstructor /* out param */)
-{
-  nsAutoString lcName;
-  nsContentUtils::ASCIIToLower(aName, lcName);
-
-  NS_ENSURE_TRUE(StringBeginsWith(lcName, NS_LITERAL_STRING("x-")),
-                 NS_ERROR_DOM_INVALID_CHARACTER_ERR);
-
-  nsresult rv = nsContentUtils::CheckQName(lcName, false);
-  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INVALID_CHARACTER_ERR);
-
-  DocumentRegisterOptions options;
-  nsCOMPtr<nsILifecycleCallback> lifecycleCallback;
-
-  if (aArgc > 0) {
-    rv = options.Init(aCx, &aOptions);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    if (options.lifecycle) {
-      JS::Value callbacksValue;
-      rv = options.lifecycle->GetAsJSVal(&callbacksValue);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      LifecycleCallbacks callbacks;
-      rv = callbacks.Init(aCx, &callbacksValue);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      lifecycleCallback = callbacks.created;
-    }
-  }
-
-  // TODO(wchen): Templates are not currently supported. Bug 818976.
-  if (options.customTemplate) {
-    return NS_ERROR_NOT_IMPLEMENTED;
-  }
-
-  nsIScriptGlobalObject* sgo = GetScopeObject();
-  NS_ENSURE_TRUE(sgo, NS_ERROR_UNEXPECTED);
-  JSObject* global = sgo->GetGlobalJSObject();
-
-  JSObject* protoObject;
-  if (!options.prototype) {
-    // If a prototype is not provided, we use the interface prototype for
-    // HTMLSpanElement.
-    rv = GetPrototypeFromClassInfoId(aCx, global,
-                                     eDOMClassInfo_HTMLSpanElement_id,
-                                     &protoObject);
-    NS_ENSURE_SUCCESS(rv, rv);
-  } else {
-    JS::Value customProto;
-    rv = options.prototype->GetAsJSVal(&customProto);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    NS_ENSURE_TRUE(!customProto.isPrimitive(), NS_ERROR_TYPE_ERR);
-
-    protoObject = &customProto.toObject();
-
-    // If a prototype is provided, we must check to ensure that it inherits
-    // from HTMLElement.
-    JSObject* htmlProto;
-    rv = GetPrototypeFromClassInfoId(aCx, global,
-                                     eDOMClassInfo_HTMLElement_id,
-                                     &htmlProto);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // Check the proto chain for HTMLElement prototype.
-    JSObject* protoProto;
-    NS_ENSURE_TRUE(JS_GetPrototype(aCx, protoObject, &protoProto),
-                   NS_ERROR_UNEXPECTED);
-    while (protoProto) {
-      if (protoProto == htmlProto) {
-        break;
-      }
-      NS_ENSURE_TRUE(JS_GetPrototype(aCx, protoProto, &protoProto),
-                     NS_ERROR_UNEXPECTED);
-    }
-
-    NS_ENSURE_TRUE(protoProto, NS_ERROR_DOM_TYPE_MISMATCH_ERR);
-  }
-
-  // Associate the prototype with the custom element.
-  mCustomPrototypes.Put(lcName, protoObject);
-
-  // Do element upgrade.
-  nsRefPtr<nsContentList> list = GetElementsByTagName(lcName);
-  for (int32_t i = 0; i < list->Length(false); i++) {
-    nsINode* oldNode = list->Item(i, false);
-
-    // TODO(wchen): Perform upgrade on Shadow DOM when implemented.
-    // Bug 806506.
-    nsCOMPtr<nsINode> newNode;
-    rv = nsNodeUtils::Clone(oldNode, true, getter_AddRefs(newNode));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    nsINode* parentNode = oldNode->GetParentNode();
-    MOZ_ASSERT(parentNode, "Node obtained by GetElementsByTagName.");
-    nsCOMPtr<nsIDOMElement> newElement = do_QueryInterface(newNode);
-    MOZ_ASSERT(newElement, "Cloned of node obtained by GetElementsByTagName.");
-
-    ErrorResult error;
-    parentNode->ReplaceChild(*newNode, *oldNode, error);
-    rv = error.ErrorCode();
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // Dispatch elementreplaced to replaced elements.
-    nsCOMPtr<nsIDOMEvent> event;
-    rv = CreateEvent(NS_LITERAL_STRING("elementreplace"), getter_AddRefs(event));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    if (lifecycleCallback) {
-      // Update static member used for "this" translation
-      // when calling callback.
-      sCurrentUpgradeElement = newElement.get();
-      lifecycleCallback->Created(nullptr);
-      sCurrentUpgradeElement = nullptr;
-    }
-
-    nsCOMPtr<nsIDOMElementReplaceEvent> ptEvent = do_QueryInterface(event);
-    MOZ_ASSERT(ptEvent);
-
-    rv = ptEvent->InitElementReplaceEvent(NS_LITERAL_STRING("elementreplace"),
-                                          false, false, newElement);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    event->SetTrusted(true);
-    event->SetTarget(oldNode);
-    nsEventDispatcher::DispatchDOMEvent(oldNode, nullptr, event,
-                                        nullptr, nullptr);
-  }
-
-  nsContentUtils::DispatchTrustedEvent(this, static_cast<nsIDocument*>(this),
-                                       NS_LITERAL_STRING("elementupgrade"),
-                                       true, true);
-
-  // Create constructor to return. Store the name of the custom element as the
-  // name of the function.
-  JSFunction* constructor = JS_NewFunction(aCx, CustomElementConstructor, 0,
-                                           JSFUN_CONSTRUCTOR, nullptr,
-                                           NS_ConvertUTF16toUTF8(lcName).get());
-  JSObject* constructorObject = JS_GetFunctionObject(constructor);
-
-  JS::Value protoVal = OBJECT_TO_JSVAL(protoObject);
-  NS_ENSURE_TRUE(JS_SetProperty(aCx, constructorObject, "prototype",
-                                &protoVal), NS_ERROR_UNEXPECTED);
-
-  JS::Value constructorVal = OBJECT_TO_JSVAL(constructorObject);
-  NS_ENSURE_TRUE(JS_SetProperty(aCx, protoObject, "constructor",
-                                &constructorVal), NS_ERROR_UNEXPECTED);
-
-  // Return the constructor.
-  *aConstructor = OBJECT_TO_JSVAL(constructorObject);
-
-  return NS_OK;
-}
-
 already_AddRefed<nsContentList>
 nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
                                    const nsAString& aLocalName)
 {
   int32_t nameSpaceId = kNameSpaceID_Wildcard;
 
   if (!aNamespaceURI.EqualsLiteral("*")) {
     nsresult rv =
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -1000,28 +1000,16 @@ public:
   void UpdateVisibilityState();
   // Posts an event to call UpdateVisibilityState
   virtual void PostVisibilityUpdateEvent();
 
   virtual void DocSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const;
   // DocSizeOfIncludingThis is inherited from nsIDocument.
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
-
-  static nsIDOMElement* CurrentUpgradeElement()
-  {
-    return sCurrentUpgradeElement;
-  }
-
-  JSObject* GetCustomPrototype(const nsAString& aElementName)
-  {
-    JSObject* prototype = nullptr;
-    mCustomPrototypes.Get(aElementName, &prototype);
-    return prototype;
-  }
 protected:
   friend class nsNodeUtils;
 
   // Returns true if a request for DOM full-screen is currently enabled in
   // this document. This returns true if there are no windowed plugins in this
   // doc tree, and if the document is visible, and if the api is not
   // disabled by pref. aIsCallerChrome must contain the return value of
   // nsContentUtils::IsCallerChrome() from the context we're checking.
@@ -1169,24 +1157,16 @@ protected:
   // the "fullscreen" permission granted.
   static nsWeakPtr sPendingPointerLockElement;
 
   // Stack of full-screen elements. When we request full-screen we push the
   // full-screen element onto this stack, and when we cancel full-screen we
   // pop one off this stack, restoring the previous full-screen state
   nsTArray<nsWeakPtr> mFullScreenStack;
 
-  // Weak reference to the current upgraded element in document.register.
-  // This member is used for function |this| translation when calling a
-  // callback interface in document.register.
-  static nsIDOMElement* sCurrentUpgradeElement;
-
-  // Hashtable for custom element prototypes in web components.
-  nsDataHashtable<nsStringHashKey, JSObject*> mCustomPrototypes;
-
   nsRefPtr<nsEventListenerManager> mListenerManager;
   nsCOMPtr<nsIDOMStyleSheetList> mDOMStyleSheets;
   nsRefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
   nsRefPtr<nsScriptLoader> mScriptLoader;
   nsDocHeaderData* mHeaderData;
   /* mIdentifierMap works as follows for IDs:
    * 1) Attribute changes affect the table immediately (removing and adding
    *    entries as needed).
--- a/content/base/src/nsNodeUtils.h
+++ b/content/base/src/nsNodeUtils.h
@@ -152,26 +152,16 @@ public:
                         nsCOMArray<nsINode> &aNodesWithProperties,
                         nsINode **aResult)
   {
     return CloneAndAdopt(aNode, true, aDeep, aNewNodeInfoManager, nullptr,
                          nullptr, aNodesWithProperties, nullptr, aResult);
   }
 
   /**
-   * Clones aNode, its attributes and, if aDeep is true, its descendant nodes
-   */
-  static nsresult Clone(nsINode *aNode, bool aDeep, nsINode **aResult)
-  {
-    nsCOMArray<nsINode> dummyNodeWithProperties;
-    return CloneAndAdopt(aNode, true, aDeep, nullptr, nullptr, nullptr,
-                         dummyNodeWithProperties, aNode->GetParent(), aResult);
-  }
-
-  /**
    * Walks aNode, its attributes and descendant nodes. If aNewNodeInfoManager is
    * not null, it is used to create new nodeinfos for the nodes. Also reparents
    * the XPConnect wrappers for the nodes in aNewScope if aCx is not null.
    * aNodesWithProperties will be filled with all the nodes that have
    * properties.
    *
    * @param aNode Node to adopt.
    * @param aNewNodeInfoManager The nodeinfo manager to use to create new
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -811,18 +811,16 @@ nsEventDispatcher::CreateEvent(nsPresCon
       aEventType.LowerCaseEqualsLiteral("timeevents"))
     return NS_NewDOMTimeEvent(aDOMEvent, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("xulcommandevent") ||
       aEventType.LowerCaseEqualsLiteral("xulcommandevents"))
     return NS_NewDOMXULCommandEvent(aDOMEvent, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("commandevent") ||
       aEventType.LowerCaseEqualsLiteral("commandevents"))
     return NS_NewDOMCommandEvent(aDOMEvent, aPresContext, nullptr);
-  if (aEventType.LowerCaseEqualsLiteral("elementreplace"))
-    return NS_NewDOMElementReplaceEvent(aDOMEvent, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("datacontainerevent") ||
       aEventType.LowerCaseEqualsLiteral("datacontainerevents"))
     return NS_NewDOMDataContainerEvent(aDOMEvent, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("messageevent"))
     return NS_NewDOMMessageEvent(aDOMEvent, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("progressevent"))
     return NS_NewDOMProgressEvent(aDOMEvent, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("notifypaintevent"))
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -2355,19 +2355,16 @@ nsDOMClassInfo::Init()
   NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
 
   nsresult rv = CallGetService(nsIXPConnect::GetCID(), &sXPConnect);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIXPCFunctionThisTranslator> elt = new nsEventListenerThisTranslator();
   sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsIDOMEventListener), elt);
 
-  nsCOMPtr<nsIXPCFunctionThisTranslator> lct = new nsLifecycleCallbacksThisTranslator();
-  sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsILifecycleCallback), lct);
-
   nsCOMPtr<nsIScriptSecurityManager> sm =
     do_GetService("@mozilla.org/scriptsecuritymanager;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   sSecMan = sm;
   NS_ADDREF(sSecMan);
 
   nsCOMPtr<nsIThreadJSContextStack> stack =
@@ -7939,23 +7936,16 @@ nsElementSH::PreCreate(nsISupports *nati
 
     // If this assertion fires the QI implementation for the object in
     // question doesn't use the nsIContent pointer as the nsISupports
     // pointer. That must be fixed, or we'll crash...
     NS_ABORT_IF_FALSE(content_qi == element, "Uh, fix QI!");
   }
 #endif
 
-  nsAutoString elementName;
-  nsContentUtils::ASCIIToLower(element->NodeName(), elementName);
-  if (StringBeginsWith(elementName, NS_LITERAL_STRING("x-"))) {
-    // Don't allow slim wrappers for custom elements.
-    return rv == NS_SUCCESS_ALLOW_SLIM_WRAPPERS ? NS_OK : rv;
-  }
-
   nsIDocument *doc = element->HasFlag(NODE_FORCE_XBL_BINDINGS) ?
                      element->OwnerDoc() :
                      element->GetCurrentDoc();
 
   if (!doc) {
     return rv;
   }
 
@@ -7991,27 +7981,16 @@ nsElementSH::PostCreate(nsIXPConnectWrap
 
     // If this assertion fires the QI implementation for the object in
     // question doesn't use the nsIContent pointer as the nsISupports
     // pointer. That must be fixed, or we'll crash...
     NS_ABORT_IF_FALSE(content_qi == element, "Uh, fix QI!");
   }
 #endif
 
-  // If we have a registered x-tag then we fix the prototype.
-  nsAutoString elementName;
-  nsContentUtils::ASCIIToLower(element->NodeName(), elementName);
-  if (StringBeginsWith(elementName, NS_LITERAL_STRING("x-"))) {
-    nsDocument* document = static_cast<nsDocument*>(element->OwnerDoc());
-    JSObject* prototype = document->GetCustomPrototype(elementName);
-    if (prototype) {
-      return JS_SetPrototype(cx, obj, prototype) ? NS_OK : NS_ERROR_UNEXPECTED;
-    }
-  }
-
   nsIDocument* doc;
   if (element->HasFlag(NODE_FORCE_XBL_BINDINGS)) {
     doc = element->OwnerDoc();
   }
   else {
     doc = element->GetCurrentDoc();
   }
 
@@ -10213,34 +10192,16 @@ nsEventListenerThisTranslator::Translate
   NS_ENSURE_TRUE(event, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIDOMEventTarget> target;
   event->GetCurrentTarget(getter_AddRefs(target));
   target.forget(_retval);
   return NS_OK;
 }
 
-NS_INTERFACE_MAP_BEGIN(nsLifecycleCallbacksThisTranslator)
-  NS_INTERFACE_MAP_ENTRY(nsIXPCFunctionThisTranslator)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-
-NS_IMPL_ADDREF(nsLifecycleCallbacksThisTranslator)
-NS_IMPL_RELEASE(nsLifecycleCallbacksThisTranslator)
-
-
-NS_IMETHODIMP
-nsLifecycleCallbacksThisTranslator::TranslateThis(nsISupports *aInitialThis,
-                                                  nsISupports **_retval)
-{
-  NS_IF_ADDREF(*_retval = nsDocument::CurrentUpgradeElement());
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 nsDOMConstructorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
                               JSObject *globalObj, JSObject **parentObj)
 {
   nsDOMConstructor *wrapped = static_cast<nsDOMConstructor *>(nativeObj);
 
 #ifdef DEBUG
   {
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -1203,34 +1203,16 @@ public:
 
   // nsISupports
   NS_DECL_ISUPPORTS
 
   // nsIXPCFunctionThisTranslator
   NS_DECL_NSIXPCFUNCTIONTHISTRANSLATOR
 };
 
-class nsLifecycleCallbacksThisTranslator : public nsIXPCFunctionThisTranslator
-{
-public:
-  nsLifecycleCallbacksThisTranslator()
-  {
-  }
-
-  virtual ~nsLifecycleCallbacksThisTranslator()
-  {
-  }
-
-  // nsISupports
-  NS_DECL_ISUPPORTS
-
-  // nsIXPCFunctionThisTranslator
-  NS_DECL_NSIXPCFUNCTIONTHISTRANSLATOR
-};
-
 class nsDOMConstructorSH : public nsDOMGenericSH
 {
 protected:
   nsDOMConstructorSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
   {
   }
 
 public:
--- a/dom/interfaces/core/nsIDOMDocument.idl
+++ b/dom/interfaces/core/nsIDOMDocument.idl
@@ -42,21 +42,16 @@ interface nsIDOMDocument : nsIDOMNode
                                   raises(DOMException);
   nsIDOMProcessingInstruction   createProcessingInstruction(in DOMString target, 
                                                             in DOMString data)
                                   raises(DOMException);
   nsIDOMAttr                    createAttribute(in DOMString name)
                                   raises(DOMException);
   nsIDOMNodeList                getElementsByTagName(in DOMString tagname);
 
-  [optional_argc,
-   implicit_jscontext] jsval    register(in DOMString name,
-                                         [optional] in jsval options)
-                                  raises(DOMException);
-
   // Introduced in DOM Level 2:
   [optional_argc] nsIDOMNode    importNode(in nsIDOMNode importedNode,
                                            [optional] in boolean deep)
                                   raises(DOMException);
   // Introduced in DOM Level 2:
   nsIDOMElement                 createElementNS(in DOMString namespaceURI,
                                                 in DOMString qualifiedName)
                                   raises(DOMException);
@@ -407,29 +402,8 @@ interface nsIDOMDocument : nsIDOMNode
   readonly attribute DOMString mozVisibilityState;
 
   /**
    * Returns "BackCompat" if we're in quirks mode or "CSS1Compat" if we're in
    * strict mode.  (XML documents are always in strict mode.)
    */
   readonly attribute DOMString compatMode;
 };
-
-/**
- * Interface for lifecycle callbacks in document.register.
- */
-
-[scriptable, function, uuid(bfcd6299-081e-45d8-99f6-cb06fe2e70de)]
-interface nsILifecycleCallback : nsISupports
-{
-  void created(in nsIDOMElement dummy);
-};
-
-dictionary LifecycleCallbacks {
-  nsILifecycleCallback created;
-};
-
-dictionary DocumentRegisterOptions {
-  nsIVariant prototype;
-  nsIDOMDocumentFragment customTemplate;
-  nsIVariant lifecycle;
-};
-
--- a/dom/interfaces/events/Makefile.in
+++ b/dom/interfaces/events/Makefile.in
@@ -42,17 +42,16 @@ XPIDLSRCS =					\
 	nsIDOMPaintRequest.idl			\
 	nsIDOMPaintRequestList.idl		\
 	nsIDOMSimpleGestureEvent.idl		\
 	nsIDOMDeviceLightEvent.idl              \
 	nsIDOMDeviceProximityEvent.idl          \
 	nsIDOMUserProximityEvent.idl            \
 	nsIDOMDeviceOrientationEvent.idl        \
 	nsIDOMDeviceMotionEvent.idl		\
-	nsIDOMElementReplaceEvent.idl		\
 	nsIDOMScrollAreaEvent.idl		\
 	nsIDOMTransitionEvent.idl		\
 	nsIDOMAnimationEvent.idl		\
 	nsIDOMPopStateEvent.idl			\
 	nsIDOMCloseEvent.idl			\
 	nsIDOMTouchEvent.idl			\
 	nsIDOMHashChangeEvent.idl		\
 	nsIDOMCustomEvent.idl			\
deleted file mode 100644
--- a/dom/interfaces/events/nsIDOMElementReplaceEvent.idl
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsIDOMEvent.idl"
-
-interface nsIDOMElement;
-
-[scriptable, builtinclass, uuid(f57f7c46-d420-4f32-a61b-0eb585d30ee1)]
-interface nsIDOMElementReplaceEvent : nsIDOMEvent
-{
-  readonly attribute nsIDOMElement upgrade;
-
-  void initElementReplaceEvent(in DOMString typeArg,
-                               in boolean canBubbleArg,
-                               in boolean canCancelArg,
-                               in nsIDOMElement upgrade);
-};
-
-dictionary ElementReplaceEventInit : EventInit
-{
-  nsIDOMElement upgrade;
-};
--- a/dom/tests/mochitest/Makefile.in
+++ b/dom/tests/mochitest/Makefile.in
@@ -22,17 +22,16 @@ DIRS	+= \
 	whatwg \
 	geolocation \
 	localstorage \
 	orientation \
 	sessionstorage \
 	storageevent \
 	pointerlock \
 	webapps \
-	webcomponents \
 	$(NULL)
 
 #needs IPC support, also tests do not run successfully in Firefox for now
 #ifneq (mobile,$(MOZ_BUILD_APP))
 #DIRS	+= notification
 #endif
 
 include $(topsrcdir)/config/rules.mk
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -523,18 +523,17 @@ var interfaceNamesInGlobalScope =
     "MozNetworkStatsManager",
     "MozNetworkStats",
     "MozNetworkStatsData",
     "RTCSessionDescription",
     "RTCIceCandidate",
     "RTCPeerConnection",
     "LocalMediaStream",
     "CSSConditionRule",
-    "CSSGroupingRule",
-    "ElementReplaceEvent"
+    "CSSGroupingRule"
   ]
 
 for (var i in SpecialPowers.Components.interfaces) {
   var s = i.toString();
   var name = null;
   if (s.indexOf("nsIDOM") == 0) {
     name = s.substring("nsIDOM".length);
   } else if (s.indexOf("nsI") == 0) {
deleted file mode 100644
--- a/dom/tests/mochitest/webcomponents/Makefile.in
+++ /dev/null
@@ -1,18 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-DEPTH		= @DEPTH@
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-relativesrcdir	= @relativesrcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MOCHITEST_FILES	= \
-		test_document_register.html \
-		test_document_register_lifecycle.html \
-		$(NULL)
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/dom/tests/mochitest/webcomponents/test_document_register.html
+++ /dev/null
@@ -1,79 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=783129
--->
-<head>
-  <title>Test for document.register using custom prototype</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-
-<script>
-var gElementUpgraded = false;
-var gElementReplaced = false;
-
-function elementUpgrade() {
-  gElementUpgraded = true;
-
-  // Check for prototype on upgraded element.
-  var documentElement = document.getElementById("grabme");
-  ok(documentElement.hello, "Upgraded element should inherit 'hello' method from prototype.");
-  documentElement.hello();
-
-  var customChild = document.getElementById("kid");
-  ok(customChild, "Upgrade should preserve children.");
-  ok(customChild.parentNode == documentElement, "Parent should be updated to new custom element.");
-
-  // Try creating new element and checking for prototype.
-  var constructedElement = document.createElement("x-hello");
-  ok(constructedElement.hello, "Created element should inherit 'hello' method from prototype.");
-  constructedElement.hello();
-}
-
-function elementReplace(e) {
-  gElementReplaced = true;
-
-  ok(e.upgrade != e.target, "Upgraded element should be different from the target.");
-  ok(e.upgrade.firstElementChild.id == "kid", "Upgrade element should have a child.");
-  ok(e.target.firstElementChild.id == "kid", "Replacement element should have a child.");
-}
-
-function startTest() {
-  var HtmlProto = function() {};
-  HtmlProto.prototype = HTMLElement.prototype;
-
-  // Create a prototype that inheits from HTMLElement.
-  var customProto = new HtmlProto();
-  customProto.hello = function() {
-    ok(true, "Custom element should use provided prototype.");
-  };
-
-  var oldElem = document.getElementById("grabme");
-  oldElem.addEventListener("elementreplace", elementReplace);
-
-  document.addEventListener("elementupgrade", elementUpgrade);
-  var elementConstructor = document.register("x-hello", { prototype: customProto });
-
-  // Try creating new element and checking for prototype.
-  var constructedElement = new elementConstructor();
-  ok(constructedElement.hello, "Created element should inherit 'hello' method from prototype.");
-  constructedElement.hello();
-
-  ok(!oldElem.hello, "Element obtained prior to registration should not have inherited prototype.");
-
-  ok(gElementUpgraded && gElementReplaced, "Upgrade and replace events should have been fired.");
-
-  SimpleTest.finish();
-}
-
-SimpleTest.waitForExplicitFinish();
-</script>
-
-</head>
-<body onload="startTest()">
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783129">Bug 783129</a>
-<x-hello id="grabme">
-<div id="kid"></div>
-</x-hello>
-</body>
-</html>
deleted file mode 100644
--- a/dom/tests/mochitest/webcomponents/test_document_register_lifecycle.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=783129
--->
-<head>
-  <title>Test for document.register lifecycle callback</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-
-<script>
-
-var gLifecycleCallbackCalled = false;
-
-var lifecycleCallbacks = {
-  created: function() {
-    is(this.getAttribute("id"), "grabme", "|this| value should be the upgrade element");
-    gLifecycleCallbackCalled = true;
-  }
-};
-
-function startTest() {
-  var HtmlProto = function() {};
-  HtmlProto.prototype = HTMLElement.prototype;
-
-  // Create a prototype that inheits from HTMLElement.
-  var customProto = new HtmlProto();
-  customProto.hello = function() {
-    ok(true, "Custom element should use provided prototype.");
-  };
-
-  var elementConstructor = document.register("x-hello", { prototype: customProto, lifecycle: lifecycleCallbacks });
-
-  ok(gLifecycleCallbackCalled, "Lifecycle callback should be called.");
-
-  SimpleTest.finish();
-}
-
-SimpleTest.waitForExplicitFinish();
-</script>
-
-</head>
-<body onload="startTest()">
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783129">Bug 783129</a>
-<x-hello id="grabme">
-<div id="kid"></div>
-</x-hello>
-</body>
-</html>
--- a/js/xpconnect/src/dictionary_helper_gen.conf
+++ b/js/xpconnect/src/dictionary_helper_gen.conf
@@ -9,18 +9,16 @@ dictionaries = [
      [ 'MouseEventInit', 'nsIDOMMouseEvent.idl' ],
      [ 'WheelEventInit', 'nsIDOMWheelEvent.idl' ],
      [ 'IDBObjectStoreParameters', 'nsIIDBDatabase.idl' ],
      [ 'IDBIndexParameters', 'nsIIDBObjectStore.idl' ],
      [ 'GeoPositionOptions', 'nsIDOMGeoGeolocation.idl' ],
      [ 'DOMFileMetadataParameters', 'nsIDOMLockedFile.idl' ],
      [ 'XMLHttpRequestParameters', 'nsIXMLHttpRequest.idl' ],
      [ 'DeviceStorageEnumerationParameters', 'nsIDOMDeviceStorage.idl' ],
-     [ 'DocumentRegisterOptions', 'nsIDOMDocument.idl' ],
-     [ 'LifecycleCallbacks', 'nsIDOMDocument.idl' ],
      [ 'CameraSize', 'nsIDOMCameraManager.idl' ],
      [ 'CameraRegion', 'nsIDOMCameraManager.idl' ],
      [ 'CameraPosition', 'nsIDOMCameraManager.idl' ],
      [ 'CameraSelector', 'nsIDOMCameraManager.idl' ],
      [ 'CameraPictureOptions', 'nsIDOMCameraManager.idl' ],
      [ 'CameraRecordingOptions', 'nsIDOMCameraManager.idl' ],
      [ 'ArchiveReaderOptions', 'nsIDOMArchiveReader.idl' ],
      [ 'SmsThreadListItem', 'nsISmsRequest.idl' ]
@@ -31,11 +29,10 @@ special_includes = [
     'nsContentUtils.h',
     'XPCQuickStubs.h',
     'nsIDOMApplicationRegistry.h'
   ]
 
 # name of the type to not include using #include "typename.h"
 exclude_automatic_type_include = [
     'nsISupports',
-    'mozIDOMApplication',
-    'nsILifecycleCallback'
+    'mozIDOMApplication'
   ]
--- a/js/xpconnect/src/event_impl_gen.conf.in
+++ b/js/xpconnect/src/event_impl_gen.conf.in
@@ -27,17 +27,16 @@ simple_events = [
     'BluetoothDeviceAddressEvent',
 #endif
 #ifdef MOZ_B2G_RIL
     'ICCCardLockErrorEvent',
     'MozWifiStatusChangeEvent',
     'MozWifiConnectionInfoEvent',
     'MozCellBroadcastEvent',
 #endif
-    'ElementReplaceEvent',
     'DeviceStorageChangeEvent',
     'PopupBlockedEvent'
   ]
 
 """ include file names """
 special_includes = [
     'DictionaryHelpers.h',
     'nsContentUtils.h',