Bug 1533883 - Add webidl definition for checking if document was loaded with prototype. r=smaug
authorBrendan Dahl <bdahl@mozilla.com>
Tue, 16 Apr 2019 18:15:04 +0000
changeset 469807 2ccc88672342a7cd5708e6a984f62c71e4294a39
parent 469806 aeb8b8977e8e3470aa434f9bad99e78c4ee3bb31
child 469808 671d87853621c4bb7d03116f82bedb4e4ffb0011
push id35883
push userbtara@mozilla.com
push dateWed, 17 Apr 2019 21:47:29 +0000
treeherdermozilla-central@02b89c29412b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1533883
milestone68.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 1533883 - Add webidl definition for checking if document was loaded with prototype. r=smaug Needed for testing to ensure the prototype was used. Depends on D27744 Differential Revision: https://phabricator.services.mozilla.com/D27745
dom/base/Document.h
dom/base/nsContentUtils.cpp
dom/webidl/Document.webidl
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -2158,17 +2158,17 @@ class Document : public nsINode,
     return AllowXULXBL();
   }
 
   bool IsScriptEnabled();
 
   /**
    * Returns true if this document was created from a nsXULPrototypeDocument.
    */
-  bool HasPrototypeDocument() const { return mPrototypeDocument; }
+  bool LoadedFromPrototype() const { return mPrototypeDocument; }
 
   bool IsTopLevelContentDocument() const { return mIsTopLevelContentDocument; }
   void SetIsTopLevelContentDocument(bool aIsTopLevelContentDocument) {
     mIsTopLevelContentDocument = aIsTopLevelContentDocument;
     // When a document is set as TopLevelContentDocument, it must be
     // allowpaymentrequest. We handle the false case while a document is
     // appended in SetSubDocumentFor
     if (aIsTopLevelContentDocument) {
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -9575,17 +9575,17 @@ nsresult nsContentUtils::NewXULOrHTMLEle
     if (aFromParser == dom::NOT_FROM_PARSER) {
       global = GetEntryGlobal();
 
       // Documents created from the PrototypeDocumentSink always use
       // NOT_FROM_PARSER for non-XUL elements. We can get the global from the
       // document in that case.
       if (!global) {
         Document* doc = nodeInfo->GetDocument();
-        if (doc && doc->HasPrototypeDocument()) {
+        if (doc && doc->LoadedFromPrototype()) {
           global = doc->GetScopeObject();
         }
       }
     } else {
       global = nodeInfo->GetDocument()->GetScopeObject();
     }
     if (!global) {
       // In browser chrome code, one may have access to a document which doesn't
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -353,16 +353,19 @@ partial interface Document {
                                           DOMString attrValue);
   [Func="IsChromeOrXBL"]
   Element? getBindingParent(Node node);
   [Throws, Func="IsChromeOrXBL", NeedsSubjectPrincipal]
   void loadBindingDocument(DOMString documentURL);
   // Creates a new XUL element regardless of the document's default type.
   [CEReactions, NewObject, Throws, Func="IsChromeOrXBL"]
   Element createXULElement(DOMString localName, optional (ElementCreationOptions or DOMString) options);
+  // Wether the document was loaded using a nsXULPrototypeDocument.
+  [ChromeOnly]
+  readonly attribute boolean loadedFromPrototype;
 
   // The principal to use for the storage area of this document
   [ChromeOnly]
   readonly attribute Principal effectiveStoragePrincipal;
 
   // Touch bits
   // XXXbz I can't find the sane spec for this stuff, so just cribbing
   // from our xpidl for now.