Bug 1531128 part 1. Add an nsIScriptChannel API to ask whether the channel is a document load. r=mccr8
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 27 Feb 2019 22:05:59 +0000
changeset 461563 21c7deb32a777b484039c8f85d748b75a47f5b95
parent 461562 4b6ea94397b45153eccfddfac342d3076773975a
child 461564 170b333092c82ce0cf39eec04f91f3700c9260e4
push id35625
push usercsabou@mozilla.com
push dateThu, 28 Feb 2019 10:55:23 +0000
treeherdermozilla-central@fd53d5e80bca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1531128
milestone67.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 1531128 part 1. Add an nsIScriptChannel API to ask whether the channel is a document load. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D21439
dom/base/nsIScriptChannel.idl
dom/jsurl/nsJSProtocolHandler.cpp
--- a/dom/base/nsIScriptChannel.idl
+++ b/dom/base/nsIScriptChannel.idl
@@ -59,10 +59,17 @@ interface nsIScriptChannel : nsISupports
    * channel returns will be returned asynchronously; the only thing
    * this property affects is when the program executes.
    *
    * The default value of this property is TRUE.
    *
    * Setting this property after asyncOpen has been called on the
    * channel has no effect.
    */
-  attribute boolean executeAsync;   
+  attribute boolean executeAsync;
+
+  /**
+   * Check whether this script channel is a document load.  This is
+   * needed because script channels can lie about their
+   * LOAD_DOCUMENT_URI flag until they have run the script.
+   */
+  [notxpcom, nostdcall] readonly attribute boolean isDocumentLoad;
 };
--- a/dom/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/jsurl/nsJSProtocolHandler.cpp
@@ -1007,16 +1007,23 @@ nsJSChannel::SetExecuteAsync(bool aIsAsy
 }
 
 NS_IMETHODIMP
 nsJSChannel::GetExecuteAsync(bool* aIsAsync) {
   *aIsAsync = mIsAsync;
   return NS_OK;
 }
 
+bool nsJSChannel::GetIsDocumentLoad() {
+  // Our LOAD_DOCUMENT_URI flag, if any, lives on our stream channel.
+  nsLoadFlags flags;
+  mStreamChannel->GetLoadFlags(&flags);
+  return flags & LOAD_DOCUMENT_URI;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 
 nsJSProtocolHandler::nsJSProtocolHandler() {}
 
 nsresult nsJSProtocolHandler::Init() { return NS_OK; }
 
 nsJSProtocolHandler::~nsJSProtocolHandler() {}