2002-04-17 07:48:37 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2000-01-29 07:41:04 +03:00
|
|
|
|
1999-12-29 10:32:59 +03:00
|
|
|
#include "nspr.h"
|
2019-09-19 03:00:44 +03:00
|
|
|
#include "mozilla/dom/BrowserChild.h"
|
2019-01-28 18:35:17 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
#include "mozilla/BasicEvents.h"
|
2018-12-17 04:27:58 +03:00
|
|
|
#include "mozilla/Components.h"
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
#include "mozilla/EventDispatcher.h"
|
2015-05-19 21:15:34 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2016-12-16 06:16:31 +03:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
2019-03-29 18:11:22 +03:00
|
|
|
#include "mozilla/PresShell.h"
|
1999-12-29 10:32:59 +03:00
|
|
|
|
2000-01-29 07:41:04 +03:00
|
|
|
#include "nsDocLoader.h"
|
2020-02-11 04:22:29 +03:00
|
|
|
#include "nsDocShell.h"
|
2000-01-29 07:41:04 +03:00
|
|
|
#include "nsNetUtil.h"
|
2001-05-12 01:05:08 +04:00
|
|
|
#include "nsIHttpChannel.h"
|
2018-11-22 01:35:42 +03:00
|
|
|
#include "nsIWebNavigation.h"
|
2007-02-08 16:15:50 +03:00
|
|
|
#include "nsIWebProgressListener2.h"
|
2000-01-29 07:41:04 +03:00
|
|
|
|
2017-08-17 08:29:03 +03:00
|
|
|
#include "nsString.h"
|
1999-09-17 11:56:03 +04:00
|
|
|
|
1999-05-06 23:31:59 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2003-11-29 21:56:10 +03:00
|
|
|
#include "nscore.h"
|
2018-10-31 23:39:03 +03:00
|
|
|
#include "nsIWeakReferenceUtils.h"
|
2004-12-08 20:32:06 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2015-04-15 19:47:03 +03:00
|
|
|
#include "nsQueryObject.h"
|
1998-07-01 15:29:20 +04:00
|
|
|
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
#include "nsPIDOMWindow.h"
|
2019-05-16 22:35:30 +03:00
|
|
|
#include "nsGlobalWindow.h"
|
2000-12-15 02:26:35 +03:00
|
|
|
|
2000-07-25 09:45:56 +04:00
|
|
|
#include "nsIStringBundle.h"
|
1999-01-12 22:41:06 +03:00
|
|
|
|
2016-01-16 03:23:21 +03:00
|
|
|
#include "nsIDocShell.h"
|
2019-01-02 16:05:23 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2019-06-11 23:43:40 +03:00
|
|
|
#include "mozilla/dom/DocGroup.h"
|
2010-07-19 06:30:56 +04:00
|
|
|
#include "nsPresContext.h"
|
2010-08-05 06:15:55 +04:00
|
|
|
#include "nsIAsyncVerifyRedirectCallback.h"
|
2018-11-01 00:16:28 +03:00
|
|
|
#include "nsILoadURIDelegate.h"
|
|
|
|
#include "nsIBrowserDOMWindow.h"
|
2019-06-11 23:43:40 +03:00
|
|
|
#include "nsGlobalWindow.h"
|
|
|
|
#include "mozilla/ThrottledEventQueue.h"
|
2018-12-17 04:27:58 +03:00
|
|
|
using namespace mozilla;
|
2016-09-02 10:12:24 +03:00
|
|
|
using mozilla::DebugOnly;
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
using mozilla::eLoad;
|
|
|
|
using mozilla::EventDispatcher;
|
2015-06-04 01:25:57 +03:00
|
|
|
using mozilla::LogLevel;
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
using mozilla::WidgetEvent;
|
2019-09-19 03:00:44 +03:00
|
|
|
using mozilla::dom::BrowserChild;
|
2019-09-30 02:51:59 +03:00
|
|
|
using mozilla::dom::BrowsingContext;
|
2019-01-28 18:35:17 +03:00
|
|
|
using mozilla::dom::Document;
|
2015-06-04 01:25:57 +03:00
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
//
|
|
|
|
// Log module for nsIDocumentLoader logging...
|
|
|
|
//
|
2016-05-26 21:48:27 +03:00
|
|
|
// To enable logging (see mozilla/Logging.h for full details):
|
1999-11-22 08:46:03 +03:00
|
|
|
//
|
2016-05-26 21:48:27 +03:00
|
|
|
// set MOZ_LOG=DocLoader:5
|
|
|
|
// set MOZ_LOG_FILE=debug.log
|
1999-11-22 08:46:03 +03:00
|
|
|
//
|
2015-06-04 01:25:57 +03:00
|
|
|
// this enables LogLevel::Debug level information and places all output in
|
2016-05-26 21:48:27 +03:00
|
|
|
// the file 'debug.log'.
|
1999-11-22 08:46:03 +03:00
|
|
|
//
|
2016-01-30 03:30:00 +03:00
|
|
|
mozilla::LazyLogModule gDocLoaderLog("DocLoader");
|
2000-10-29 02:17:53 +04:00
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
#if defined(DEBUG)
|
2002-03-21 01:50:33 +03:00
|
|
|
void GetURIStringFromRequest(nsIRequest* request, nsACString& name) {
|
|
|
|
if (request)
|
|
|
|
request->GetName(name);
|
|
|
|
else
|
2004-06-17 04:13:25 +04:00
|
|
|
name.AssignLiteral("???");
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2015-02-11 20:46:40 +03:00
|
|
|
void nsDocLoader::RequestInfoHashInitEntry(PLDHashEntryHdr* entry,
|
2012-10-19 20:24:12 +04:00
|
|
|
const void* key) {
|
2002-07-09 04:54:41 +04:00
|
|
|
// Initialize the entry with placement new
|
|
|
|
new (entry) nsRequestInfo(key);
|
|
|
|
}
|
|
|
|
|
2012-10-19 20:24:12 +04:00
|
|
|
void nsDocLoader::RequestInfoHashClearEntry(PLDHashTable* table,
|
|
|
|
PLDHashEntryHdr* entry) {
|
2009-07-28 21:46:04 +04:00
|
|
|
nsRequestInfo* info = static_cast<nsRequestInfo*>(entry);
|
|
|
|
info->~nsRequestInfo();
|
|
|
|
}
|
2002-07-09 04:54:41 +04:00
|
|
|
|
2014-04-19 11:43:34 +04:00
|
|
|
// this is used for mListenerInfoList.Contains()
|
|
|
|
template <>
|
|
|
|
class nsDefaultComparator<nsDocLoader::nsListenerInfo,
|
|
|
|
nsIWebProgressListener*> {
|
|
|
|
public:
|
|
|
|
bool Equals(const nsDocLoader::nsListenerInfo& aInfo,
|
|
|
|
nsIWebProgressListener* const& aListener) const {
|
|
|
|
nsCOMPtr<nsIWebProgressListener> listener =
|
|
|
|
do_QueryReferent(aInfo.mWeakListener);
|
|
|
|
return aListener == listener;
|
|
|
|
}
|
2002-05-17 00:57:37 +04:00
|
|
|
};
|
|
|
|
|
2015-05-05 08:59:24 +03:00
|
|
|
/* static */ const PLDHashTableOps nsDocLoader::sRequestInfoHashOps = {
|
2015-09-15 00:23:47 +03:00
|
|
|
PLDHashTable::HashVoidPtrKeyStub, PLDHashTable::MatchEntryStub,
|
2015-05-05 08:59:24 +03:00
|
|
|
PLDHashTable::MoveEntryStub, nsDocLoader::RequestInfoHashClearEntry,
|
|
|
|
nsDocLoader::RequestInfoHashInitEntry};
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
nsDocLoader::nsDocLoader()
|
2012-07-30 18:20:58 +04:00
|
|
|
: mParent(nullptr),
|
2017-01-24 19:12:10 +03:00
|
|
|
mProgressStateFlags(0),
|
2011-04-01 04:15:27 +04:00
|
|
|
mCurrentSelfProgress(0),
|
|
|
|
mMaxSelfProgress(0),
|
|
|
|
mCurrentTotalProgress(0),
|
|
|
|
mMaxTotalProgress(0),
|
2015-05-05 08:59:24 +03:00
|
|
|
mRequestInfoHash(&sRequestInfoHashOps, sizeof(nsRequestInfo)),
|
2011-04-01 04:15:27 +04:00
|
|
|
mCompletedTotalProgress(0),
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsLoadingDocument(false),
|
|
|
|
mIsRestoringDocument(false),
|
|
|
|
mDontFlushLayout(false),
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
mIsFlushingLayout(false),
|
2019-06-11 23:43:40 +03:00
|
|
|
mTreatAsBackgroundLoad(false),
|
|
|
|
mHasFakeOnLoadDispatched(false),
|
|
|
|
mIsReadyToHandlePostMessage(false),
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
mDocumentOpenedButNotLoaded(false) {
|
2000-04-23 03:16:31 +04:00
|
|
|
ClearInternalProgress();
|
2000-04-03 06:26:05 +04:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug, ("DocLoader:%p: created.\n", this));
|
1998-07-01 15:29:20 +04:00
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
nsresult nsDocLoader::SetDocLoaderParent(nsDocLoader* aParent) {
|
2000-01-29 07:41:04 +03:00
|
|
|
mParent = aParent;
|
2015-02-05 02:15:13 +03:00
|
|
|
return NS_OK;
|
2000-01-29 07:41:04 +03:00
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
nsresult nsDocLoader::Init() {
|
2002-07-09 04:54:41 +04:00
|
|
|
nsresult rv = NS_NewLoadGroup(getter_AddRefs(mLoadGroup), this);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-17 11:56:03 +04:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
2016-12-16 06:16:31 +03:00
|
|
|
("DocLoader:%p: load group %p.\n", this, mLoadGroup.get()));
|
1999-08-27 02:45:55 +04:00
|
|
|
|
2002-12-11 03:15:19 +03:00
|
|
|
return NS_OK;
|
1999-06-28 14:35:57 +04:00
|
|
|
}
|
1998-07-01 15:29:20 +04:00
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
nsDocLoader::~nsDocLoader() {
|
1999-09-22 01:10:22 +04:00
|
|
|
/*
|
|
|
|
|ClearWeakReferences()| here is intended to prevent people holding
|
|
|
|
weak references from re-entering this destructor since |QueryReferent()|
|
|
|
|
will |AddRef()| me, and the subsequent |Release()| will try to destroy me.
|
|
|
|
At this point there should be only weak references remaining (otherwise, we
|
|
|
|
wouldn't be getting destroyed).
|
2018-11-30 13:46:48 +03:00
|
|
|
|
1999-09-22 01:10:22 +04:00
|
|
|
An alternative would be incrementing our refcount (consider it a
|
|
|
|
compressed flag saying "Don't re-destroy."). I haven't yet decided which
|
|
|
|
is better. [scc]
|
|
|
|
*/
|
2004-12-08 20:32:06 +03:00
|
|
|
// XXXbz now that NS_IMPL_RELEASE stabilizes by setting refcount to 1, is
|
|
|
|
// this needed?
|
2000-06-20 09:14:42 +04:00
|
|
|
ClearWeakReferences();
|
1999-09-22 01:10:22 +04:00
|
|
|
|
1999-09-17 11:56:03 +04:00
|
|
|
Destroy();
|
1998-10-02 01:48:12 +04:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug, ("DocLoader:%p: deleted.\n", this));
|
1998-07-01 15:29:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of ISupports methods...
|
|
|
|
*/
|
2017-10-02 17:58:39 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDocLoader)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDocLoader)
|
1998-07-22 15:23:32 +04:00
|
|
|
|
2017-10-02 17:58:39 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDocLoader)
|
2017-10-02 17:58:47 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocumentLoader)
|
2001-04-10 10:01:08 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
2000-01-29 07:41:04 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDocumentLoader)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2000-04-03 06:26:05 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebProgress)
|
2015-02-05 02:15:13 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink)
|
2000-05-07 06:01:10 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
2005-03-07 22:46:06 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
|
2005-02-21 23:58:01 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
|
2018-05-22 02:33:18 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY_CONCRETE(nsDocLoader)
|
2000-01-29 07:41:04 +03:00
|
|
|
NS_INTERFACE_MAP_END
|
1998-07-22 15:23:32 +04:00
|
|
|
|
2020-02-25 22:44:39 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WEAK(nsDocLoader, mChildrenInOnload)
|
2017-10-02 17:58:39 +03:00
|
|
|
|
2000-05-07 06:01:10 +04:00
|
|
|
/*
|
|
|
|
* Implementation of nsIInterfaceRequestor methods...
|
|
|
|
*/
|
2004-12-08 20:32:06 +03:00
|
|
|
NS_IMETHODIMP nsDocLoader::GetInterface(const nsIID& aIID, void** aSink) {
|
2000-05-07 06:01:10 +04:00
|
|
|
nsresult rv = NS_ERROR_NO_INTERFACE;
|
|
|
|
|
|
|
|
NS_ENSURE_ARG_POINTER(aSink);
|
|
|
|
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsILoadGroup))) {
|
|
|
|
*aSink = mLoadGroup;
|
|
|
|
NS_IF_ADDREF((nsISupports*)*aSink);
|
|
|
|
rv = NS_OK;
|
|
|
|
} else {
|
|
|
|
rv = QueryInterface(aIID, aSink);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
/* static */
|
|
|
|
already_AddRefed<nsDocLoader> nsDocLoader::GetAsDocLoader(
|
|
|
|
nsISupports* aSupports) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsDocLoader> ret = do_QueryObject(aSupports);
|
2013-04-22 15:15:59 +04:00
|
|
|
return ret.forget();
|
2004-12-08 20:32:06 +03:00
|
|
|
}
|
1999-06-28 14:35:57 +04:00
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
/* static */
|
|
|
|
nsresult nsDocLoader::AddDocLoaderAsChildOfRoot(nsDocLoader* aDocLoader) {
|
|
|
|
nsCOMPtr<nsIDocumentLoader> docLoaderService =
|
2018-12-17 04:27:58 +03:00
|
|
|
components::DocLoader::Service();
|
|
|
|
NS_ENSURE_TRUE(docLoaderService, NS_ERROR_UNEXPECTED);
|
2002-12-11 03:15:19 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsDocLoader> rootDocLoader = GetAsDocLoader(docLoaderService);
|
2004-12-08 20:32:06 +03:00
|
|
|
NS_ENSURE_TRUE(rootDocLoader, NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
return rootDocLoader->AddChildLoader(aDocLoader);
|
1998-07-22 15:23:32 +04:00
|
|
|
}
|
|
|
|
|
1999-03-12 08:20:29 +03:00
|
|
|
NS_IMETHODIMP
|
2004-12-08 20:32:06 +03:00
|
|
|
nsDocLoader::Stop(void) {
|
1999-11-22 08:46:03 +03:00
|
|
|
nsresult rv = NS_OK;
|
1999-03-12 08:20:29 +03:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
1999-11-22 08:46:03 +03:00
|
|
|
("DocLoader:%p: Stop() called\n", this));
|
1999-03-12 08:20:29 +03:00
|
|
|
|
2013-02-21 01:33:44 +04:00
|
|
|
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mChildList, nsDocLoader, Stop, ());
|
1998-10-09 09:49:34 +04:00
|
|
|
|
2003-03-01 23:39:44 +03:00
|
|
|
if (mLoadGroup) rv = mLoadGroup->Cancel(NS_BINDING_ABORTED);
|
1998-10-10 08:33:29 +04:00
|
|
|
|
2010-04-10 22:03:40 +04:00
|
|
|
// Don't report that we're flushing layout so IsBusy returns false after a
|
|
|
|
// Stop call.
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsFlushingLayout = false;
|
2010-04-10 22:03:40 +04:00
|
|
|
|
2006-06-23 05:17:47 +04:00
|
|
|
// Clear out mChildrenInOnload. We want to make sure to fire our
|
|
|
|
// onload at this point, and there's no issue with mChildrenInOnload
|
|
|
|
// after this, since mDocumentRequest will be null after the
|
|
|
|
// DocLoaderIsEmpty() call.
|
|
|
|
mChildrenInOnload.Clear();
|
2019-09-19 03:00:44 +03:00
|
|
|
mOOPChildrenLoading.Clear();
|
2006-06-23 05:17:47 +04:00
|
|
|
|
2005-07-13 20:43:30 +04:00
|
|
|
// Make sure to call DocLoaderIsEmpty now so that we reset mDocumentRequest,
|
|
|
|
// etc, as needed. We could be getting into here from a subframe onload, in
|
|
|
|
// which case the call to DocLoaderIsEmpty() is coming but hasn't quite
|
|
|
|
// happened yet, Canceling the loadgroup did nothing (because it was already
|
|
|
|
// empty), and we're about to start a new load (which is what triggered this
|
|
|
|
// Stop() call).
|
|
|
|
|
|
|
|
// XXXbz If the child frame loadgroups were requests in mLoadgroup, I suspect
|
|
|
|
// we wouldn't need the call here....
|
2006-06-23 05:17:47 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(!IsBusy(), "Shouldn't be busy here");
|
2011-10-17 18:59:28 +04:00
|
|
|
DocLoaderIsEmpty(false);
|
2015-02-05 02:15:13 +03:00
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
return rv;
|
2015-02-05 02:15:13 +03:00
|
|
|
}
|
1998-07-22 15:23:32 +04:00
|
|
|
|
2019-07-06 11:18:28 +03:00
|
|
|
bool nsDocLoader::TreatAsBackgroundLoad() { return mTreatAsBackgroundLoad; }
|
2019-06-11 23:43:40 +03:00
|
|
|
|
2019-07-06 11:18:28 +03:00
|
|
|
void nsDocLoader::SetBackgroundLoadIframe() { mTreatAsBackgroundLoad = true; }
|
2019-06-11 23:43:40 +03:00
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
bool nsDocLoader::IsBusy() {
|
1999-11-22 08:46:03 +03:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
//
|
|
|
|
// A document loader is busy if either:
|
|
|
|
//
|
2006-06-23 05:17:47 +04:00
|
|
|
// 1. One of its children is in the middle of an onload handler. Note that
|
|
|
|
// the handler may have already removed this child from mChildList!
|
2006-10-19 04:51:54 +04:00
|
|
|
// 2. It is currently loading a document and either has parts of it still
|
|
|
|
// loading, or has a busy child docloader.
|
2009-02-15 21:14:19 +03:00
|
|
|
// 3. It's currently flushing layout in DocLoaderIsEmpty().
|
1999-11-22 08:46:03 +03:00
|
|
|
//
|
1998-10-02 01:48:12 +04:00
|
|
|
|
2019-09-19 03:00:44 +03:00
|
|
|
if (!mChildrenInOnload.IsEmpty() || !mOOPChildrenLoading.IsEmpty() ||
|
|
|
|
mIsFlushingLayout) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2006-06-23 05:17:47 +04:00
|
|
|
}
|
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
/* Is this document loader busy? */
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
if (!IsBlockingLoadEvent()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2006-10-19 04:51:54 +04:00
|
|
|
}
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2019-09-19 03:00:44 +03:00
|
|
|
// Check if any in-process sub-document is awaiting its 'load' event:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool busy;
|
2006-10-19 04:51:54 +04:00
|
|
|
rv = mLoadGroup->IsPending(&busy);
|
|
|
|
if (NS_FAILED(rv)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2006-10-19 04:51:54 +04:00
|
|
|
}
|
|
|
|
if (busy) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-11-22 08:46:03 +03:00
|
|
|
}
|
|
|
|
|
2006-10-19 04:51:54 +04:00
|
|
|
/* check its child document loaders... */
|
2013-02-13 10:23:14 +04:00
|
|
|
uint32_t count = mChildList.Length();
|
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
2004-12-08 20:32:06 +03:00
|
|
|
nsIDocumentLoader* loader = ChildAt(i);
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2019-06-11 23:43:40 +03:00
|
|
|
// If 'dom.cross_origin_iframes_loaded_in_background' is set, the parent
|
|
|
|
// document treats cross domain iframes as background loading frame
|
2019-07-06 11:18:28 +03:00
|
|
|
if (loader && static_cast<nsDocLoader*>(loader)->TreatAsBackgroundLoad()) {
|
2019-06-11 23:43:40 +03:00
|
|
|
continue;
|
|
|
|
}
|
2004-12-08 20:32:06 +03:00
|
|
|
// This is a safe cast, because we only put nsDocLoader objects into the
|
2004-09-29 00:48:58 +04:00
|
|
|
// array
|
2007-07-08 11:08:04 +04:00
|
|
|
if (loader && static_cast<nsDocLoader*>(loader)->IsBusy()) return true;
|
1998-10-02 01:48:12 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1998-10-02 01:48:12 +04:00
|
|
|
}
|
|
|
|
|
1999-01-14 09:44:23 +03:00
|
|
|
NS_IMETHODIMP
|
2004-12-08 20:32:06 +03:00
|
|
|
nsDocLoader::GetContainer(nsISupports** aResult) {
|
2007-07-08 11:08:04 +04:00
|
|
|
NS_ADDREF(*aResult = static_cast<nsIDocumentLoader*>(this));
|
1999-11-15 10:29:23 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-01-14 09:44:23 +03:00
|
|
|
}
|
1998-10-02 01:48:12 +04:00
|
|
|
|
1999-10-27 08:44:42 +04:00
|
|
|
NS_IMETHODIMP
|
2004-12-08 20:32:06 +03:00
|
|
|
nsDocLoader::GetLoadGroup(nsILoadGroup** aResult) {
|
1999-10-27 08:44:42 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
if (nullptr == aResult) {
|
1999-10-27 08:44:42 +04:00
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
|
|
|
} else {
|
|
|
|
*aResult = mLoadGroup;
|
|
|
|
NS_IF_ADDREF(*aResult);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
void nsDocLoader::Destroy() {
|
2000-04-23 03:16:31 +04:00
|
|
|
Stop();
|
1999-09-17 11:56:03 +04:00
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
// Remove the document loader from the parent list of loaders...
|
2015-02-05 02:15:13 +03:00
|
|
|
if (mParent) {
|
2016-09-02 10:12:24 +03:00
|
|
|
DebugOnly<nsresult> rv = mParent->RemoveChildLoader(this);
|
|
|
|
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RemoveChildLoader failed");
|
2000-04-23 03:16:31 +04:00
|
|
|
}
|
1998-10-02 01:48:12 +04:00
|
|
|
|
2002-05-17 00:57:37 +04:00
|
|
|
// Release all the information about network requests...
|
2002-07-09 04:54:41 +04:00
|
|
|
ClearRequestInfoHash();
|
2000-06-20 09:14:42 +04:00
|
|
|
|
2002-05-17 00:57:37 +04:00
|
|
|
mListenerInfoList.Clear();
|
|
|
|
mListenerInfoList.Compact();
|
|
|
|
|
2016-11-10 06:11:27 +03:00
|
|
|
mDocumentRequest = nullptr;
|
1998-10-02 01:48:12 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
if (mLoadGroup) mLoadGroup->SetGroupObserver(nullptr);
|
1999-10-19 23:42:55 +04:00
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
DestroyChildren();
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsDocLoader::DestroyChildren() {
|
2013-02-13 10:23:14 +04:00
|
|
|
uint32_t count = mChildList.Length();
|
2004-12-08 20:32:06 +03:00
|
|
|
// if the doc loader still has children...we need to enumerate the
|
|
|
|
// children and make them null out their back ptr to the parent doc
|
|
|
|
// loader
|
2013-02-13 10:23:14 +04:00
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
2004-12-08 20:32:06 +03:00
|
|
|
nsIDocumentLoader* loader = ChildAt(i);
|
|
|
|
|
|
|
|
if (loader) {
|
|
|
|
// This is a safe cast, as we only put nsDocLoader objects into the
|
|
|
|
// array
|
2016-09-02 10:12:24 +03:00
|
|
|
DebugOnly<nsresult> rv =
|
|
|
|
static_cast<nsDocLoader*>(loader)->SetDocLoaderParent(nullptr);
|
|
|
|
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SetDocLoaderParent failed");
|
2004-12-08 20:32:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
mChildList.Clear();
|
1998-10-02 01:48:12 +04:00
|
|
|
}
|
|
|
|
|
1999-07-16 15:14:36 +04:00
|
|
|
NS_IMETHODIMP
|
2019-02-28 02:41:04 +03:00
|
|
|
nsDocLoader::OnStartRequest(nsIRequest* request) {
|
2001-04-28 01:05:52 +04:00
|
|
|
// called each time a request is added to the group.
|
2001-04-13 06:32:02 +04:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
if (MOZ_LOG_TEST(gDocLoaderLog, LogLevel::Debug)) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString name;
|
2002-03-21 01:50:33 +03:00
|
|
|
request->GetName(name);
|
2001-04-28 01:05:52 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t count = 0;
|
2001-04-28 01:05:52 +04:00
|
|
|
if (mLoadGroup) mLoadGroup->GetActiveCount(&count);
|
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
2001-04-28 01:05:52 +04:00
|
|
|
("DocLoader:%p: OnStartRequest[%p](%s) mIsLoadingDocument=%s, %u "
|
|
|
|
"active URLs",
|
|
|
|
this, request, name.get(), (mIsLoadingDocument ? "true" : "false"),
|
|
|
|
count));
|
|
|
|
}
|
2015-05-07 20:14:55 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool bJustStartedLoading = false;
|
2001-05-30 02:10:50 +04:00
|
|
|
|
2004-09-18 00:33:25 +04:00
|
|
|
nsLoadFlags loadFlags = 0;
|
2001-04-28 01:05:52 +04:00
|
|
|
request->GetLoadFlags(&loadFlags);
|
2001-04-13 06:32:02 +04:00
|
|
|
|
2001-04-28 01:05:52 +04:00
|
|
|
if (!mIsLoadingDocument && (loadFlags & nsIChannel::LOAD_DOCUMENT_URI)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
bJustStartedLoading = true;
|
|
|
|
mIsLoadingDocument = true;
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
mDocumentOpenedButNotLoaded = false;
|
2001-04-28 01:05:52 +04:00
|
|
|
ClearInternalProgress(); // only clear our progress if we are starting a
|
|
|
|
// new load....
|
|
|
|
}
|
2000-01-15 09:12:54 +03:00
|
|
|
|
2001-04-28 01:05:52 +04:00
|
|
|
//
|
2009-04-08 12:45:32 +04:00
|
|
|
// Create a new nsRequestInfo for the request that is starting to
|
|
|
|
// load...
|
|
|
|
//
|
|
|
|
AddRequestInfo(request);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Only fire a doStartDocumentLoad(...) if the document loader
|
2001-04-28 01:05:52 +04:00
|
|
|
// has initiated a load... Otherwise, this notification has
|
|
|
|
// resulted from a request being added to the load group.
|
|
|
|
//
|
|
|
|
if (mIsLoadingDocument) {
|
|
|
|
if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) {
|
2019-05-16 14:43:59 +03:00
|
|
|
//
|
|
|
|
// Make sure that the document channel is null at this point...
|
|
|
|
// (unless its been redirected)
|
|
|
|
//
|
|
|
|
NS_ASSERTION(
|
|
|
|
(loadFlags & nsIChannel::LOAD_REPLACE) || !(mDocumentRequest.get()),
|
|
|
|
"Overwriting an existing document channel!");
|
2001-04-28 01:05:52 +04:00
|
|
|
|
|
|
|
// This request is associated with the entire document...
|
|
|
|
mDocumentRequest = request;
|
2015-02-05 02:15:13 +03:00
|
|
|
mLoadGroup->SetDefaultLoadRequest(request);
|
2001-04-28 01:05:52 +04:00
|
|
|
|
|
|
|
// Only fire the start document load notification for the first
|
|
|
|
// document URI... Do not fire it again for redirections
|
|
|
|
//
|
2001-05-30 02:10:50 +04:00
|
|
|
if (bJustStartedLoading) {
|
2001-04-28 01:05:52 +04:00
|
|
|
// Update the progress status state
|
|
|
|
mProgressStateFlags = nsIWebProgressListener::STATE_START;
|
|
|
|
|
|
|
|
// Fire the start document load notification
|
|
|
|
doStartDocumentLoad();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-02-05 02:15:13 +03:00
|
|
|
}
|
2001-04-28 01:05:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(!mIsLoadingDocument || mDocumentRequest,
|
|
|
|
"mDocumentRequest MUST be set for the duration of a page load!");
|
|
|
|
|
2017-03-31 19:16:44 +03:00
|
|
|
// This is the only way to catch document request start event after a redirect
|
|
|
|
// has occured without changing inherited Firefox behaviour significantly.
|
|
|
|
// Problem description:
|
|
|
|
// The combination of |STATE_START + STATE_IS_DOCUMENT| is only sent for
|
|
|
|
// initial request (see |doStartDocumentLoad| call above).
|
|
|
|
// And |STATE_REDIRECTING + STATE_IS_DOCUMENT| is sent with old channel, which
|
|
|
|
// makes it impossible to filter by destination URL (see
|
|
|
|
// |AsyncOnChannelRedirect| implementation).
|
|
|
|
// Fixing any of those bugs may cause unpredictable consequences in any part
|
|
|
|
// of the browser, so we just add a custom flag for this exact situation.
|
|
|
|
int32_t extraFlags = 0;
|
|
|
|
if (mIsLoadingDocument && !bJustStartedLoading &&
|
|
|
|
(loadFlags & nsIChannel::LOAD_DOCUMENT_URI) &&
|
|
|
|
(loadFlags & nsIChannel::LOAD_REPLACE)) {
|
|
|
|
extraFlags = nsIWebProgressListener::STATE_IS_REDIRECTED_DOCUMENT;
|
|
|
|
}
|
|
|
|
doStartURLLoad(request, extraFlags);
|
2001-04-19 23:51:29 +04:00
|
|
|
|
2000-04-23 03:16:31 +04:00
|
|
|
return NS_OK;
|
1999-07-16 15:14:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-02-28 02:41:31 +03:00
|
|
|
nsDocLoader::OnStopRequest(nsIRequest* aRequest, nsresult aStatus) {
|
1999-11-22 08:46:03 +03:00
|
|
|
nsresult rv = NS_OK;
|
1999-08-27 02:45:55 +04:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
if (MOZ_LOG_TEST(gDocLoaderLog, LogLevel::Debug)) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString name;
|
2002-03-21 01:50:33 +03:00
|
|
|
aRequest->GetName(name);
|
2001-04-28 01:05:52 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t count = 0;
|
2001-04-28 01:05:52 +04:00
|
|
|
if (mLoadGroup) mLoadGroup->GetActiveCount(&count);
|
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
2016-12-16 06:16:31 +03:00
|
|
|
("DocLoader:%p: OnStopRequest[%p](%s) status=%" PRIx32
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
" mIsLoadingDocument=%s, mDocumentOpenedButNotLoaded=%s,"
|
|
|
|
" %u active URLs",
|
2016-12-16 06:16:31 +03:00
|
|
|
this, aRequest, name.get(), static_cast<uint32_t>(aStatus),
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
(mIsLoadingDocument ? "true" : "false"),
|
|
|
|
(mDocumentOpenedButNotLoaded ? "true" : "false"), count));
|
2001-04-28 01:05:52 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool bFireTransferring = false;
|
2009-04-08 12:45:32 +04:00
|
|
|
|
1999-09-23 02:58:29 +04:00
|
|
|
//
|
2009-04-08 12:45:32 +04:00
|
|
|
// Set the Maximum progress to the same value as the current progress.
|
|
|
|
// Since the URI has finished loading, all the data is there. Also,
|
|
|
|
// this will allow a more accurate estimation of the max progress (in case
|
|
|
|
// the old value was unknown ie. -1)
|
1999-09-23 02:58:29 +04:00
|
|
|
//
|
2009-04-08 12:45:32 +04:00
|
|
|
nsRequestInfo* info = GetRequestInfo(aRequest);
|
|
|
|
if (info) {
|
2011-09-07 06:57:46 +04:00
|
|
|
// Null out mLastStatus now so we don't find it when looking for
|
|
|
|
// status from now on. This destroys the nsStatusInfo and hence
|
|
|
|
// removes it from our list.
|
2012-07-30 18:20:58 +04:00
|
|
|
info->mLastStatus = nullptr;
|
2009-07-28 20:13:48 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t oldMax = info->mMaxProgress;
|
1999-09-23 02:58:29 +04:00
|
|
|
|
2009-04-08 12:45:32 +04:00
|
|
|
info->mMaxProgress = info->mCurrentProgress;
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
//
|
2009-04-08 12:45:32 +04:00
|
|
|
// If a request whose content-length was previously unknown has just
|
|
|
|
// finished loading, then use this new data to try to calculate a
|
|
|
|
// mMaxSelfProgress...
|
2000-06-19 09:54:37 +04:00
|
|
|
//
|
2012-08-22 19:56:38 +04:00
|
|
|
if ((oldMax < int64_t(0)) && (mMaxSelfProgress < int64_t(0))) {
|
2009-04-08 12:45:32 +04:00
|
|
|
mMaxSelfProgress = CalculateMaxProgress();
|
|
|
|
}
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2009-04-08 12:45:32 +04:00
|
|
|
// As we know the total progress of this request now, save it to be part
|
|
|
|
// of CalculateMaxProgress() result. We need to remove the info from the
|
|
|
|
// hash, see bug 480713.
|
|
|
|
mCompletedTotalProgress += info->mMaxProgress;
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2009-04-08 12:45:32 +04:00
|
|
|
//
|
|
|
|
// Determine whether a STATE_TRANSFERRING notification should be
|
|
|
|
// 'synthesized'.
|
|
|
|
//
|
|
|
|
// If nsRequestInfo::mMaxProgress (as stored in oldMax) and
|
|
|
|
// nsRequestInfo::mCurrentProgress are both 0, then the
|
|
|
|
// STATE_TRANSFERRING notification has not been fired yet...
|
|
|
|
//
|
2012-10-26 03:25:59 +04:00
|
|
|
if ((oldMax == 0) && (info->mCurrentProgress == 0)) {
|
2009-04-08 12:45:32 +04:00
|
|
|
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
|
2002-06-21 01:16:46 +04:00
|
|
|
|
2009-04-08 12:45:32 +04:00
|
|
|
// Only fire a TRANSFERRING notification if the request is also a
|
|
|
|
// channel -- data transfer requires a nsIChannel!
|
2002-06-21 01:16:46 +04:00
|
|
|
//
|
2009-04-08 12:45:32 +04:00
|
|
|
if (channel) {
|
|
|
|
if (NS_SUCCEEDED(aStatus)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
bFireTransferring = true;
|
2009-04-08 12:45:32 +04:00
|
|
|
}
|
2002-06-21 01:16:46 +04:00
|
|
|
//
|
2009-04-08 12:45:32 +04:00
|
|
|
// If the request failed (for any reason other than being
|
|
|
|
// redirected or retargeted), the TRANSFERRING notification can
|
|
|
|
// still be fired if a HTTP connection was established to a server.
|
|
|
|
//
|
|
|
|
else if (aStatus != NS_BINDING_REDIRECTED &&
|
|
|
|
aStatus != NS_BINDING_RETARGETED) {
|
2002-06-21 01:16:46 +04:00
|
|
|
//
|
2009-04-08 12:45:32 +04:00
|
|
|
// Only if the load has been targeted (see bug 268483)...
|
2002-06-21 01:16:46 +04:00
|
|
|
//
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t lf;
|
2009-04-08 12:45:32 +04:00
|
|
|
channel->GetLoadFlags(&lf);
|
|
|
|
if (lf & nsIChannel::LOAD_TARGETED) {
|
|
|
|
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest));
|
|
|
|
if (httpChannel) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t responseCode;
|
2009-04-08 12:45:32 +04:00
|
|
|
rv = httpChannel->GetResponseStatus(&responseCode);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
//
|
|
|
|
// A valid server status indicates that a connection was
|
|
|
|
// established to the server... So, fire the notification
|
|
|
|
// even though a failure occurred later...
|
|
|
|
//
|
2011-10-17 18:59:28 +04:00
|
|
|
bFireTransferring = true;
|
2002-06-21 01:16:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-08 12:45:32 +04:00
|
|
|
}
|
2002-06-21 01:16:46 +04:00
|
|
|
|
2009-04-08 12:45:32 +04:00
|
|
|
if (bFireTransferring) {
|
|
|
|
// Send a STATE_TRANSFERRING notification for the request.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t flags;
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2009-04-08 12:45:32 +04:00
|
|
|
flags = nsIWebProgressListener::STATE_TRANSFERRING |
|
|
|
|
nsIWebProgressListener::STATE_IS_REQUEST;
|
|
|
|
//
|
|
|
|
// Move the WebProgress into the STATE_TRANSFERRING state if necessary...
|
|
|
|
//
|
|
|
|
if (mProgressStateFlags & nsIWebProgressListener::STATE_START) {
|
|
|
|
mProgressStateFlags = nsIWebProgressListener::STATE_TRANSFERRING;
|
2002-06-21 01:16:46 +04:00
|
|
|
|
2009-04-08 12:45:32 +04:00
|
|
|
// Send STATE_TRANSFERRING for the document too...
|
|
|
|
flags |= nsIWebProgressListener::STATE_IS_DOCUMENT;
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2009-04-08 12:45:32 +04:00
|
|
|
FireOnStateChange(this, aRequest, flags, NS_OK);
|
1999-09-23 02:58:29 +04:00
|
|
|
}
|
2009-04-08 12:45:32 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Fire the OnStateChange(...) notification for stop request
|
|
|
|
//
|
|
|
|
doStopURLLoad(aRequest, aStatus);
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2009-04-08 12:45:32 +04:00
|
|
|
// Clear this request out of the hash to avoid bypass of FireOnStateChange
|
|
|
|
// when address of the request is reused.
|
|
|
|
RemoveRequestInfo(aRequest);
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2009-04-08 12:45:32 +04:00
|
|
|
//
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
// Only fire the DocLoaderIsEmpty(...) if we may need to fire onload.
|
2009-04-08 12:45:32 +04:00
|
|
|
//
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
if (IsBlockingLoadEvent()) {
|
2016-01-16 03:23:21 +03:00
|
|
|
nsCOMPtr<nsIDocShell> ds =
|
|
|
|
do_QueryInterface(static_cast<nsIRequestObserver*>(this));
|
|
|
|
bool doNotFlushLayout = false;
|
|
|
|
if (ds) {
|
|
|
|
// Don't do unexpected layout flushes while we're in process of restoring
|
|
|
|
// a document from the bfcache.
|
|
|
|
ds->GetRestoringDocument(&doNotFlushLayout);
|
|
|
|
}
|
|
|
|
DocLoaderIsEmpty(!doNotFlushLayout);
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
2015-02-05 02:15:13 +03:00
|
|
|
|
1999-09-23 02:58:29 +04:00
|
|
|
return NS_OK;
|
1999-07-16 15:14:36 +04:00
|
|
|
}
|
1998-10-02 01:48:12 +04:00
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
nsresult nsDocLoader::RemoveChildLoader(nsDocLoader* aChild) {
|
|
|
|
nsresult rv = mChildList.RemoveElement(aChild) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2016-08-08 13:16:15 +03:00
|
|
|
rv = aChild->SetDocLoaderParent(nullptr);
|
2004-12-08 20:32:06 +03:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
1998-10-02 01:48:12 +04:00
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
nsresult nsDocLoader::AddChildLoader(nsDocLoader* aChild) {
|
2018-10-14 19:12:22 +03:00
|
|
|
mChildList.AppendElement(aChild);
|
|
|
|
return aChild->SetDocLoaderParent(this);
|
1998-10-02 01:48:12 +04:00
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
NS_IMETHODIMP nsDocLoader::GetDocumentChannel(nsIChannel** aChannel) {
|
2002-12-11 03:15:19 +03:00
|
|
|
if (!mDocumentRequest) {
|
2012-07-30 18:20:58 +04:00
|
|
|
*aChannel = nullptr;
|
2002-12-11 03:15:19 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2002-12-11 03:15:19 +03:00
|
|
|
return CallQueryInterface(mDocumentRequest, aChannel);
|
2000-11-01 11:04:49 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
void nsDocLoader::DocLoaderIsEmpty(bool aFlushLayout) {
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
if (IsBlockingLoadEvent()) {
|
1999-12-15 05:18:52 +03:00
|
|
|
/* In the unimagineably rude circumstance that onload event handlers
|
|
|
|
triggered by this function actually kill the window ... ok, it's
|
|
|
|
not unimagineable; it's happened ... this deathgrip keeps this object
|
|
|
|
alive long enough to survive this function call. */
|
|
|
|
nsCOMPtr<nsIDocumentLoader> kungFuDeathGrip(this);
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2009-02-15 21:14:19 +03:00
|
|
|
// Don't flush layout if we're still busy.
|
|
|
|
if (IsBusy()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(!mIsFlushingLayout, "Someone screwed up");
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
// We may not have a document request if we are in a
|
|
|
|
// document.open() situation.
|
|
|
|
NS_ASSERTION(mDocumentRequest || mDocumentOpenedButNotLoaded,
|
|
|
|
"No Document Request!");
|
2009-02-15 21:14:19 +03:00
|
|
|
|
2010-07-19 06:30:56 +04:00
|
|
|
// The load group for this DocumentLoader is idle. Flush if we need to.
|
2010-04-10 22:03:40 +04:00
|
|
|
if (aFlushLayout && !mDontFlushLayout) {
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
nsCOMPtr<Document> doc = do_GetInterface(GetAsSupports(this));
|
2009-02-15 21:14:19 +03:00
|
|
|
if (doc) {
|
2010-07-19 06:30:56 +04:00
|
|
|
// We start loads from style resolution, so we need to flush out style
|
|
|
|
// no matter what. If we have user fonts, we also need to flush layout,
|
|
|
|
// since the reflow is what starts font loads.
|
2017-01-05 10:31:56 +03:00
|
|
|
mozilla::FlushType flushType = mozilla::FlushType::Style;
|
2018-02-21 01:00:10 +03:00
|
|
|
// Be safe in case this presshell is in teardown now
|
2019-01-27 18:30:38 +03:00
|
|
|
doc->FlushUserFontSet();
|
|
|
|
if (doc->GetUserFontSet()) {
|
2018-02-21 01:00:10 +03:00
|
|
|
flushType = mozilla::FlushType::Layout;
|
2010-07-19 06:30:56 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
mDontFlushLayout = mIsFlushingLayout = true;
|
2010-07-19 06:30:56 +04:00
|
|
|
doc->FlushPendingNotifications(flushType);
|
2011-10-17 18:59:28 +04:00
|
|
|
mDontFlushLayout = mIsFlushingLayout = false;
|
2009-02-15 21:14:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// And now check whether we're really busy; that might have changed with
|
|
|
|
// the layout flush.
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
//
|
|
|
|
// Note, mDocumentRequest can be null while mDocumentOpenedButNotLoaded is
|
|
|
|
// false if the flushing above re-entered this method.
|
|
|
|
if (IsBusy() || (!mDocumentRequest && !mDocumentOpenedButNotLoaded)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mDocumentRequest) {
|
2009-04-08 12:45:32 +04:00
|
|
|
// Clear out our request info hash, now that our load really is done and
|
|
|
|
// we don't need it anymore to CalculateMaxProgress().
|
|
|
|
ClearInternalProgress();
|
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
1999-11-22 08:46:03 +03:00
|
|
|
("DocLoader:%p: Is now idle...\n", this));
|
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
nsCOMPtr<nsIRequest> docRequest = mDocumentRequest;
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2016-11-10 06:11:27 +03:00
|
|
|
mDocumentRequest = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsLoadingDocument = false;
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
// Update the progress status state - the document is done
|
2000-08-25 22:39:46 +04:00
|
|
|
mProgressStateFlags = nsIWebProgressListener::STATE_STOP;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2015-02-05 02:15:13 +03:00
|
|
|
nsresult loadGroupStatus = NS_OK;
|
2000-10-26 10:34:20 +04:00
|
|
|
mLoadGroup->GetStatus(&loadGroupStatus);
|
|
|
|
|
2015-02-05 02:15:13 +03:00
|
|
|
//
|
|
|
|
// New code to break the circular reference between
|
|
|
|
// the load group and the docloader...
|
|
|
|
//
|
|
|
|
mLoadGroup->SetDefaultLoadRequest(nullptr);
|
2000-06-19 09:54:37 +04:00
|
|
|
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
// Take a ref to our parent now so that we can call ChildDoneWithOnload()
|
|
|
|
// on it even if our onload handler removes us from the docloader tree.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsDocLoader> parent = mParent;
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2006-06-23 05:17:47 +04:00
|
|
|
// Note that if calling ChildEnteringOnload() on the parent returns false
|
|
|
|
// then calling our onload handler is not safe. That can only happen on
|
|
|
|
// OOM, so that's ok.
|
|
|
|
if (!parent || parent->ChildEnteringOnload(this)) {
|
|
|
|
// Do nothing with our state after firing the
|
|
|
|
// OnEndDocumentLoad(...). The document loader may be loading a *new*
|
|
|
|
// document - if LoadDocument() was called from a handler!
|
|
|
|
//
|
|
|
|
doStopDocumentLoad(docRequest, loadGroupStatus);
|
|
|
|
|
2019-09-19 03:00:44 +03:00
|
|
|
NotifyDoneWithOnload(parent);
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(mDocumentOpenedButNotLoaded);
|
|
|
|
mDocumentOpenedButNotLoaded = false;
|
|
|
|
|
|
|
|
// Make sure we do the ChildEnteringOnload/ChildDoneWithOnload even if we
|
|
|
|
// plan to skip firing our own load event, because otherwise we might
|
|
|
|
// never end up firing our parent's load event.
|
|
|
|
RefPtr<nsDocLoader> parent = mParent;
|
|
|
|
if (!parent || parent->ChildEnteringOnload(this)) {
|
|
|
|
nsresult loadGroupStatus = NS_OK;
|
|
|
|
mLoadGroup->GetStatus(&loadGroupStatus);
|
|
|
|
// Make sure we're not canceling the loadgroup. If we are, then just
|
|
|
|
// like the normal navigation case we should not fire a load event.
|
|
|
|
if (NS_SUCCEEDED(loadGroupStatus) ||
|
|
|
|
loadGroupStatus == NS_ERROR_PARSED_DATA_CACHED) {
|
|
|
|
// Can "doc" or "window" ever come back null here? Our state machine
|
|
|
|
// is complicated enough I wouldn't bet against it...
|
|
|
|
nsCOMPtr<Document> doc = do_GetInterface(GetAsSupports(this));
|
|
|
|
if (doc) {
|
|
|
|
doc->SetReadyStateInternal(Document::READYSTATE_COMPLETE,
|
|
|
|
/* updateTimingInformation = */ false);
|
|
|
|
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = doc->GetWindow();
|
|
|
|
if (window && !doc->SkipLoadEventAfterClose()) {
|
2019-06-11 23:43:40 +03:00
|
|
|
if (!mozilla::dom::DocGroup::TryToLoadIframesInBackground() ||
|
|
|
|
(mozilla::dom::DocGroup::TryToLoadIframesInBackground() &&
|
|
|
|
!HasFakeOnLoadDispatched())) {
|
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
2019-07-06 11:18:28 +03:00
|
|
|
("DocLoader:%p: Firing load event for document.open\n",
|
|
|
|
this));
|
2019-06-11 23:43:40 +03:00
|
|
|
|
|
|
|
// This is a very cut-down version of
|
|
|
|
// nsDocumentViewer::LoadComplete that doesn't do various things
|
|
|
|
// that are not relevant here because this wasn't an actual
|
|
|
|
// navigation.
|
|
|
|
WidgetEvent event(true, eLoad);
|
|
|
|
event.mFlags.mBubbles = false;
|
|
|
|
event.mFlags.mCancelable = false;
|
|
|
|
// Dispatching to |window|, but using |document| as the target,
|
|
|
|
// per spec.
|
|
|
|
event.mTarget = doc;
|
|
|
|
nsEventStatus unused = nsEventStatus_eIgnore;
|
|
|
|
doc->SetLoadEventFiring(true);
|
|
|
|
EventDispatcher::Dispatch(window, nullptr, &event, nullptr,
|
2019-07-06 11:18:28 +03:00
|
|
|
&unused);
|
2019-06-11 23:43:40 +03:00
|
|
|
doc->SetLoadEventFiring(false);
|
|
|
|
|
|
|
|
// Now unsuppress painting on the presshell, if we
|
|
|
|
// haven't done that yet.
|
|
|
|
RefPtr<PresShell> presShell = doc->GetPresShell();
|
|
|
|
if (presShell && !presShell->IsDestroying()) {
|
|
|
|
presShell->UnsuppressPainting();
|
|
|
|
|
|
|
|
if (!presShell->IsDestroying()) {
|
|
|
|
presShell->LoadComplete();
|
|
|
|
}
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 03:00:44 +03:00
|
|
|
NotifyDoneWithOnload(parent);
|
1999-11-22 08:46:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-19 03:00:44 +03:00
|
|
|
void nsDocLoader::NotifyDoneWithOnload(nsDocLoader* aParent) {
|
|
|
|
if (aParent) {
|
|
|
|
// In-process parent:
|
|
|
|
aParent->ChildDoneWithOnload(this);
|
2019-09-30 02:51:59 +03:00
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(this);
|
|
|
|
if (!docShell) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
BrowsingContext* bc = nsDocShell::Cast(docShell)->GetBrowsingContext();
|
|
|
|
if (bc->IsContentSubframe() && !bc->GetParent()->IsInProcess()) {
|
2019-10-01 01:06:47 +03:00
|
|
|
if (BrowserChild* browserChild = BrowserChild::GetFrom(docShell)) {
|
2019-09-30 02:51:59 +03:00
|
|
|
mozilla::Unused << browserChild->SendMaybeFireEmbedderLoadEvents(
|
|
|
|
/*aIsTrusted*/ true, /*aFireLoadAtEmbeddingElement*/ false);
|
|
|
|
}
|
2019-09-19 03:00:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
void nsDocLoader::doStartDocumentLoad(void) {
|
2000-06-19 09:54:37 +04:00
|
|
|
#if defined(DEBUG)
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString buffer;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
GetURIStringFromRequest(mDocumentRequest, buffer);
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(
|
|
|
|
gDocLoaderLog, LogLevel::Debug,
|
2000-06-19 09:54:37 +04:00
|
|
|
("DocLoader:%p: ++ Firing OnStateChange for start document load (...)."
|
|
|
|
"\tURI: %s \n",
|
2002-03-21 01:50:33 +03:00
|
|
|
this, buffer.get()));
|
2000-06-19 09:54:37 +04:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2000-08-25 22:39:46 +04:00
|
|
|
// Fire an OnStatus(...) notification STATE_START. This indicates
|
2001-02-21 23:38:08 +03:00
|
|
|
// that the document represented by mDocumentRequest has started to
|
2000-06-19 09:54:37 +04:00
|
|
|
// load...
|
|
|
|
FireOnStateChange(this, mDocumentRequest,
|
2000-08-25 22:39:46 +04:00
|
|
|
nsIWebProgressListener::STATE_START |
|
|
|
|
nsIWebProgressListener::STATE_IS_DOCUMENT |
|
|
|
|
nsIWebProgressListener::STATE_IS_REQUEST |
|
2004-10-01 08:52:26 +04:00
|
|
|
nsIWebProgressListener::STATE_IS_WINDOW |
|
2000-08-25 22:39:46 +04:00
|
|
|
nsIWebProgressListener::STATE_IS_NETWORK,
|
2000-06-19 09:54:37 +04:00
|
|
|
NS_OK);
|
|
|
|
}
|
|
|
|
|
2017-03-31 19:16:44 +03:00
|
|
|
void nsDocLoader::doStartURLLoad(nsIRequest* request, int32_t aExtraFlags) {
|
2000-06-19 09:54:37 +04:00
|
|
|
#if defined(DEBUG)
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString buffer;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
GetURIStringFromRequest(request, buffer);
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
2000-06-19 09:54:37 +04:00
|
|
|
("DocLoader:%p: ++ Firing OnStateChange start url load (...)."
|
|
|
|
"\tURI: %s\n",
|
2002-03-21 01:50:33 +03:00
|
|
|
this, buffer.get()));
|
2000-06-19 09:54:37 +04:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
FireOnStateChange(this, request,
|
2000-08-25 22:39:46 +04:00
|
|
|
nsIWebProgressListener::STATE_START |
|
2017-03-31 19:16:44 +03:00
|
|
|
nsIWebProgressListener::STATE_IS_REQUEST | aExtraFlags,
|
2000-06-19 09:54:37 +04:00
|
|
|
NS_OK);
|
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
void nsDocLoader::doStopURLLoad(nsIRequest* request, nsresult aStatus) {
|
2000-06-19 09:54:37 +04:00
|
|
|
#if defined(DEBUG)
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString buffer;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
GetURIStringFromRequest(request, buffer);
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
2000-06-19 09:54:37 +04:00
|
|
|
("DocLoader:%p: ++ Firing OnStateChange for end url load (...)."
|
2016-12-16 06:16:31 +03:00
|
|
|
"\tURI: %s status=%" PRIx32 "\n",
|
|
|
|
this, buffer.get(), static_cast<uint32_t>(aStatus)));
|
2000-06-19 09:54:37 +04:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
FireOnStateChange(this, request,
|
2000-08-25 22:39:46 +04:00
|
|
|
nsIWebProgressListener::STATE_STOP |
|
|
|
|
nsIWebProgressListener::STATE_IS_REQUEST,
|
2000-06-19 09:54:37 +04:00
|
|
|
aStatus);
|
2009-07-28 20:13:48 +04:00
|
|
|
|
2011-09-07 06:57:46 +04:00
|
|
|
// Fire a status change message for the most recent unfinished
|
|
|
|
// request to make sure that the displayed status is not outdated.
|
2012-10-19 20:24:12 +04:00
|
|
|
if (!mStatusInfoList.isEmpty()) {
|
|
|
|
nsStatusInfo* statusInfo = mStatusInfoList.getFirst();
|
2011-09-07 06:57:46 +04:00
|
|
|
FireOnStatusChange(this, statusInfo->mRequest, statusInfo->mStatusCode,
|
|
|
|
statusInfo->mStatusMessage.get());
|
2009-07-28 20:13:48 +04:00
|
|
|
}
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
void nsDocLoader::doStopDocumentLoad(nsIRequest* request, nsresult aStatus) {
|
2000-06-19 09:54:37 +04:00
|
|
|
#if defined(DEBUG)
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString buffer;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
GetURIStringFromRequest(request, buffer);
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
2000-06-19 09:54:37 +04:00
|
|
|
("DocLoader:%p: ++ Firing OnStateChange for end document load (...)."
|
2016-12-16 06:16:31 +03:00
|
|
|
"\tURI: %s Status=%" PRIx32 "\n",
|
|
|
|
this, buffer.get(), static_cast<uint32_t>(aStatus)));
|
2000-06-19 09:54:37 +04:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2011-09-09 07:19:45 +04:00
|
|
|
// Firing STATE_STOP|STATE_IS_DOCUMENT will fire onload handlers.
|
|
|
|
// Grab our parent chain before doing that so we can still dispatch
|
|
|
|
// STATE_STOP|STATE_IS_WINDW_STATE_IS_NETWORK to them all, even if
|
|
|
|
// the onload handlers rearrange the docshell tree.
|
|
|
|
WebProgressList list;
|
|
|
|
GatherAncestorWebProgresses(list);
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
//
|
2002-05-17 00:57:37 +04:00
|
|
|
// Fire an OnStateChange(...) notification indicating the the
|
2000-06-19 09:54:37 +04:00
|
|
|
// current document has finished loading...
|
|
|
|
//
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t flags = nsIWebProgressListener::STATE_STOP |
|
2011-09-09 07:19:45 +04:00
|
|
|
nsIWebProgressListener::STATE_IS_DOCUMENT;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < list.Length(); ++i) {
|
2011-09-09 07:19:45 +04:00
|
|
|
list[i]->DoFireOnStateChange(this, request, flags, aStatus);
|
|
|
|
}
|
2000-12-23 09:07:38 +03:00
|
|
|
|
|
|
|
//
|
2002-05-17 00:57:37 +04:00
|
|
|
// Fire a final OnStateChange(...) notification indicating the the
|
2000-12-23 09:07:38 +03:00
|
|
|
// current document has finished loading...
|
|
|
|
//
|
2011-09-09 07:19:45 +04:00
|
|
|
flags = nsIWebProgressListener::STATE_STOP |
|
|
|
|
nsIWebProgressListener::STATE_IS_WINDOW |
|
|
|
|
nsIWebProgressListener::STATE_IS_NETWORK;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < list.Length(); ++i) {
|
2011-09-09 07:19:45 +04:00
|
|
|
list[i]->DoFireOnStateChange(this, request, flags, aStatus);
|
|
|
|
}
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2000-04-03 06:26:05 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// The following section contains support for nsIWebProgress and related stuff
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
NS_IMETHODIMP
|
2004-12-08 20:32:06 +03:00
|
|
|
nsDocLoader::AddProgressListener(nsIWebProgressListener* aListener,
|
2014-04-19 11:43:34 +04:00
|
|
|
uint32_t aNotifyMask) {
|
|
|
|
if (mListenerInfoList.Contains(aListener)) {
|
2002-05-17 00:57:37 +04:00
|
|
|
// The listener is already registered!
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2004-10-25 19:55:33 +04:00
|
|
|
nsWeakPtr listener = do_GetWeakReference(aListener);
|
|
|
|
if (!listener) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2018-10-14 19:12:22 +03:00
|
|
|
mListenerInfoList.AppendElement(nsListenerInfo(listener, aNotifyMask));
|
|
|
|
return NS_OK;
|
2000-04-03 06:26:05 +04:00
|
|
|
}
|
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
NS_IMETHODIMP
|
2004-12-08 20:32:06 +03:00
|
|
|
nsDocLoader::RemoveProgressListener(nsIWebProgressListener* aListener) {
|
2014-04-19 11:43:34 +04:00
|
|
|
return mListenerInfoList.RemoveElement(aListener) ? NS_OK : NS_ERROR_FAILURE;
|
2000-04-03 06:26:05 +04:00
|
|
|
}
|
|
|
|
|
2000-12-15 02:26:35 +03:00
|
|
|
NS_IMETHODIMP
|
2016-01-30 20:05:36 +03:00
|
|
|
nsDocLoader::GetDOMWindow(mozIDOMWindowProxy** aResult) {
|
2004-12-08 20:32:06 +03:00
|
|
|
return CallGetInterface(this, aResult);
|
2000-12-15 02:26:35 +03:00
|
|
|
}
|
|
|
|
|
2013-04-25 09:26:13 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocLoader::GetDOMWindowID(uint64_t* aResult) {
|
|
|
|
*aResult = 0;
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<mozIDOMWindowProxy> window;
|
2013-04-25 09:26:13 +04:00
|
|
|
nsresult rv = GetDOMWindow(getter_AddRefs(window));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> piwindow = nsPIDOMWindowOuter::From(window);
|
2013-04-25 09:26:13 +04:00
|
|
|
NS_ENSURE_STATE(piwindow);
|
|
|
|
|
|
|
|
*aResult = piwindow->WindowID();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-06-27 22:40:33 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocLoader::GetInnerDOMWindowID(uint64_t* aResult) {
|
|
|
|
*aResult = 0;
|
|
|
|
|
|
|
|
nsCOMPtr<mozIDOMWindowProxy> window;
|
|
|
|
nsresult rv = GetDOMWindow(getter_AddRefs(window));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> outer = nsPIDOMWindowOuter::From(window);
|
|
|
|
NS_ENSURE_STATE(outer);
|
|
|
|
|
|
|
|
nsPIDOMWindowInner* inner = outer->GetCurrentInnerWindow();
|
|
|
|
if (!inner) {
|
|
|
|
// If we don't have an inner window, return 0.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = inner->WindowID();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-25 09:26:13 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocLoader::GetIsTopLevel(bool* aResult) {
|
|
|
|
*aResult = false;
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<mozIDOMWindowProxy> window;
|
2013-04-30 02:52:57 +04:00
|
|
|
GetDOMWindow(getter_AddRefs(window));
|
|
|
|
if (window) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> piwindow = nsPIDOMWindowOuter::From(window);
|
2013-04-30 02:52:57 +04:00
|
|
|
NS_ENSURE_STATE(piwindow);
|
2013-04-25 09:26:13 +04:00
|
|
|
|
2019-07-26 19:48:31 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> topWindow = piwindow->GetInProcessTop();
|
2013-04-30 02:52:57 +04:00
|
|
|
*aResult = piwindow == topWindow;
|
|
|
|
}
|
2013-04-25 09:26:13 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-07-02 06:17:15 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsDocLoader::GetIsLoadingDocument(bool* aIsLoadingDocument) {
|
2002-07-02 06:17:15 +04:00
|
|
|
*aIsLoadingDocument = mIsLoadingDocument;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-07-29 19:03:41 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocLoader::GetLoadType(uint32_t* aLoadType) {
|
|
|
|
*aLoadType = 0;
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2017-07-20 02:07:39 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocLoader::GetTarget(nsIEventTarget** aTarget) {
|
|
|
|
nsCOMPtr<mozIDOMWindowProxy> window;
|
|
|
|
nsresult rv = GetDOMWindow(getter_AddRefs(window));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2018-02-08 23:54:00 +03:00
|
|
|
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(window);
|
|
|
|
NS_ENSURE_STATE(global);
|
2017-07-20 02:07:39 +03:00
|
|
|
|
2018-02-08 23:54:00 +03:00
|
|
|
nsCOMPtr<nsIEventTarget> target =
|
|
|
|
global->EventTargetFor(mozilla::TaskCategory::Other);
|
2017-07-20 02:07:39 +03:00
|
|
|
target.forget(aTarget);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocLoader::SetTarget(nsIEventTarget* aTarget) {
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t nsDocLoader::GetMaxTotalProgress() {
|
|
|
|
int64_t newMaxTotal = 0;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2013-02-13 10:23:14 +04:00
|
|
|
uint32_t count = mChildList.Length();
|
2015-02-05 02:15:13 +03:00
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t individualProgress = 0;
|
2005-01-09 23:43:35 +03:00
|
|
|
nsIDocumentLoader* docloader = ChildAt(i);
|
2000-04-23 03:16:31 +04:00
|
|
|
if (docloader) {
|
2004-12-08 20:32:06 +03:00
|
|
|
// Cast is safe since all children are nsDocLoader too
|
2005-01-09 23:43:35 +03:00
|
|
|
individualProgress = ((nsDocLoader*)docloader)->GetMaxTotalProgress();
|
2000-04-23 03:16:31 +04:00
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
if (individualProgress < int64_t(0)) // if one of the elements doesn't know
|
2005-01-09 23:43:35 +03:00
|
|
|
// it's size then none of them do
|
2000-04-25 05:45:37 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
newMaxTotal = int64_t(-1);
|
2000-04-25 05:45:37 +04:00
|
|
|
break;
|
|
|
|
} else
|
2004-09-29 00:48:58 +04:00
|
|
|
newMaxTotal += individualProgress;
|
2000-04-23 03:16:31 +04:00
|
|
|
}
|
2004-09-29 00:48:58 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t progress = -1;
|
|
|
|
if (mMaxSelfProgress >= int64_t(0) && newMaxTotal >= int64_t(0))
|
2004-09-29 00:48:58 +04:00
|
|
|
progress = newMaxTotal + mMaxSelfProgress;
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2004-09-29 00:48:58 +04:00
|
|
|
return progress;
|
2000-04-23 03:16:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
2015-02-05 02:15:13 +03:00
|
|
|
// The following section contains support for nsIProgressEventSink which is used
|
2001-03-29 04:12:49 +04:00
|
|
|
// to pass progress and status between the actual request and the doc loader.
|
2000-04-23 03:16:31 +04:00
|
|
|
// The doc loader then turns around and makes the right web progress calls based
|
|
|
|
// on this information.
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-02-05 02:15:13 +03:00
|
|
|
NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest* aRequest, nsISupports* ctxt,
|
2015-01-08 22:48:52 +03:00
|
|
|
int64_t aProgress, int64_t aProgressMax) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t progressDelta = 0;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
|
|
|
//
|
2002-06-21 01:16:46 +04:00
|
|
|
// Update the RequestInfo entry with the new progress data
|
2000-06-19 09:54:37 +04:00
|
|
|
//
|
2014-06-25 07:36:39 +04:00
|
|
|
if (nsRequestInfo* info = GetRequestInfo(aRequest)) {
|
|
|
|
// Update info->mCurrentProgress before we call FireOnStateChange,
|
|
|
|
// since that can make the "info" pointer invalid.
|
|
|
|
int64_t oldCurrentProgress = info->mCurrentProgress;
|
2015-01-08 22:48:52 +03:00
|
|
|
progressDelta = aProgress - oldCurrentProgress;
|
|
|
|
info->mCurrentProgress = aProgress;
|
2014-06-25 07:36:39 +04:00
|
|
|
|
2004-04-11 00:03:03 +04:00
|
|
|
// suppress sending STATE_TRANSFERRING if this is upload progress (see bug
|
|
|
|
// 240053)
|
2014-06-25 07:36:39 +04:00
|
|
|
if (!info->mUploading && (int64_t(0) == oldCurrentProgress) &&
|
|
|
|
(int64_t(0) == info->mMaxProgress)) {
|
2004-09-18 00:33:25 +04:00
|
|
|
//
|
|
|
|
// If we receive an OnProgress event from a toplevel channel that the URI
|
|
|
|
// Loader has not yet targeted, then we must suppress the event. This is
|
|
|
|
// necessary to ensure that webprogresslisteners do not get confused when
|
|
|
|
// the channel is finally targeted. See bug 257308.
|
|
|
|
//
|
|
|
|
nsLoadFlags lf = 0;
|
|
|
|
aRequest->GetLoadFlags(&lf);
|
|
|
|
if ((lf & nsIChannel::LOAD_DOCUMENT_URI) &&
|
|
|
|
!(lf & nsIChannel::LOAD_TARGETED)) {
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(
|
|
|
|
gDocLoaderLog, LogLevel::Debug,
|
2004-09-18 00:33:25 +04:00
|
|
|
("DocLoader:%p Ignoring OnProgress while load is not targeted\n",
|
|
|
|
this));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
//
|
|
|
|
// This is the first progress notification for the entry. If
|
2015-01-08 22:48:52 +03:00
|
|
|
// (aMaxProgress != -1) then the content-length of the data is known,
|
2000-06-19 09:54:37 +04:00
|
|
|
// so update mMaxSelfProgress... Otherwise, set it to -1 to indicate
|
|
|
|
// that the content-length is no longer known.
|
|
|
|
//
|
2015-01-08 22:48:52 +03:00
|
|
|
if (aProgressMax != -1) {
|
|
|
|
mMaxSelfProgress += aProgressMax;
|
|
|
|
info->mMaxProgress = aProgressMax;
|
2000-06-19 09:54:37 +04:00
|
|
|
} else {
|
2012-08-22 19:56:38 +04:00
|
|
|
mMaxSelfProgress = int64_t(-1);
|
|
|
|
info->mMaxProgress = int64_t(-1);
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2000-08-25 22:39:46 +04:00
|
|
|
// Send a STATE_TRANSFERRING notification for the request.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t flags;
|
2015-02-05 02:15:13 +03:00
|
|
|
|
|
|
|
flags = nsIWebProgressListener::STATE_TRANSFERRING |
|
2000-08-25 22:39:46 +04:00
|
|
|
nsIWebProgressListener::STATE_IS_REQUEST;
|
2000-06-19 09:54:37 +04:00
|
|
|
//
|
2000-08-25 22:39:46 +04:00
|
|
|
// Move the WebProgress into the STATE_TRANSFERRING state if necessary...
|
2000-06-19 09:54:37 +04:00
|
|
|
//
|
2000-08-25 22:39:46 +04:00
|
|
|
if (mProgressStateFlags & nsIWebProgressListener::STATE_START) {
|
|
|
|
mProgressStateFlags = nsIWebProgressListener::STATE_TRANSFERRING;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2000-08-25 22:39:46 +04:00
|
|
|
// Send STATE_TRANSFERRING for the document too...
|
|
|
|
flags |= nsIWebProgressListener::STATE_IS_DOCUMENT;
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2001-03-29 04:12:49 +04:00
|
|
|
FireOnStateChange(this, aRequest, flags, NS_OK);
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2014-06-25 07:36:39 +04:00
|
|
|
// Update our overall current progress count.
|
2000-06-19 09:54:37 +04:00
|
|
|
mCurrentSelfProgress += progressDelta;
|
2009-04-08 12:45:32 +04:00
|
|
|
}
|
2000-06-19 09:54:37 +04:00
|
|
|
//
|
2001-03-29 04:12:49 +04:00
|
|
|
// The request is not part of the load group, so ignore its progress
|
2000-06-19 09:54:37 +04:00
|
|
|
// information...
|
|
|
|
//
|
|
|
|
else {
|
|
|
|
#if defined(DEBUG)
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString buffer;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2001-03-29 04:12:49 +04:00
|
|
|
GetURIStringFromRequest(aRequest, buffer);
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(
|
|
|
|
gDocLoaderLog, LogLevel::Debug,
|
2001-03-29 04:12:49 +04:00
|
|
|
("DocLoader:%p OOPS - No Request Info for: %s\n", this, buffer.get()));
|
2000-06-19 09:54:37 +04:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
return NS_OK;
|
2000-04-23 03:16:31 +04:00
|
|
|
}
|
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
//
|
|
|
|
// Fire progress notifications out to any registered nsIWebProgressListeners
|
|
|
|
//
|
2001-03-29 04:12:49 +04:00
|
|
|
FireOnProgressChange(this, aRequest, aProgress, aProgressMax, progressDelta,
|
2000-06-19 09:54:37 +04:00
|
|
|
mCurrentTotalProgress, mMaxTotalProgress);
|
2000-04-25 05:45:37 +04:00
|
|
|
|
2000-04-23 03:16:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-05 02:15:13 +03:00
|
|
|
NS_IMETHODIMP nsDocLoader::OnStatus(nsIRequest* aRequest, nsISupports* ctxt,
|
2014-01-04 19:02:17 +04:00
|
|
|
nsresult aStatus,
|
|
|
|
const char16_t* aStatusArg) {
|
2000-07-25 09:45:56 +04:00
|
|
|
//
|
|
|
|
// Fire progress notifications out to any registered nsIWebProgressListeners
|
|
|
|
//
|
2012-08-14 13:10:42 +04:00
|
|
|
if (aStatus != NS_OK) {
|
2004-04-11 00:03:03 +04:00
|
|
|
// Remember the current status for this request
|
|
|
|
nsRequestInfo* info;
|
|
|
|
info = GetRequestInfo(aRequest);
|
|
|
|
if (info) {
|
2012-08-07 19:11:35 +04:00
|
|
|
bool uploading = (aStatus == NS_NET_STATUS_WRITING ||
|
|
|
|
aStatus == NS_NET_STATUS_SENDING_TO);
|
2004-04-11 00:03:03 +04:00
|
|
|
// If switching from uploading to downloading (or vice versa), then we
|
|
|
|
// need to reset our progress counts. This is designed with HTTP form
|
|
|
|
// submission in mind, where an upload is performed followed by download
|
|
|
|
// of possibly several documents.
|
|
|
|
if (info->mUploading != uploading) {
|
2012-10-26 03:25:59 +04:00
|
|
|
mCurrentSelfProgress = mMaxSelfProgress = 0;
|
|
|
|
mCurrentTotalProgress = mMaxTotalProgress = 0;
|
|
|
|
mCompletedTotalProgress = 0;
|
2004-04-11 00:03:03 +04:00
|
|
|
info->mUploading = uploading;
|
2012-10-26 03:25:59 +04:00
|
|
|
info->mCurrentProgress = 0;
|
|
|
|
info->mMaxProgress = 0;
|
2004-04-11 00:03:03 +04:00
|
|
|
}
|
|
|
|
}
|
2010-05-14 13:24:41 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIStringBundleService> sbs =
|
|
|
|
mozilla::services::GetStringBundleService();
|
|
|
|
if (!sbs) return NS_ERROR_FAILURE;
|
2017-08-04 07:40:52 +03:00
|
|
|
nsAutoString msg;
|
|
|
|
nsresult rv = sbs->FormatStatusMessage(aStatus, aStatusArg, msg);
|
2010-05-14 13:24:41 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2009-07-28 20:13:48 +04:00
|
|
|
|
|
|
|
// Keep around the message. In case a request finishes, we need to make sure
|
|
|
|
// to send the status message of another request to our user to that we
|
|
|
|
// don't display, for example, "Transferring" messages for requests that are
|
|
|
|
// already done.
|
|
|
|
if (info) {
|
2011-09-07 06:57:46 +04:00
|
|
|
if (!info->mLastStatus) {
|
|
|
|
info->mLastStatus = new nsStatusInfo(aRequest);
|
|
|
|
} else {
|
|
|
|
// We're going to move it to the front of the list, so remove
|
|
|
|
// it from wherever it is now.
|
2012-10-19 20:24:12 +04:00
|
|
|
info->mLastStatus->remove();
|
2011-09-07 06:57:46 +04:00
|
|
|
}
|
|
|
|
info->mLastStatus->mStatusMessage = msg;
|
|
|
|
info->mLastStatus->mStatusCode = aStatus;
|
|
|
|
// Put the info at the front of the list
|
2012-10-19 20:24:12 +04:00
|
|
|
mStatusInfoList.insertFront(info->mLastStatus);
|
2009-07-28 20:13:48 +04:00
|
|
|
}
|
2017-08-04 07:40:52 +03:00
|
|
|
FireOnStatusChange(this, aRequest, aStatus, msg.get());
|
2000-07-25 09:45:56 +04:00
|
|
|
}
|
2000-04-23 03:16:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
void nsDocLoader::ClearInternalProgress() {
|
2002-07-09 04:54:41 +04:00
|
|
|
ClearRequestInfoHash();
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2012-10-26 03:25:59 +04:00
|
|
|
mCurrentSelfProgress = mMaxSelfProgress = 0;
|
|
|
|
mCurrentTotalProgress = mMaxTotalProgress = 0;
|
|
|
|
mCompletedTotalProgress = 0;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2000-08-25 22:39:46 +04:00
|
|
|
mProgressStateFlags = nsIWebProgressListener::STATE_STOP;
|
2000-04-03 06:26:05 +04:00
|
|
|
}
|
2000-04-25 05:45:37 +04:00
|
|
|
|
2014-04-19 11:43:34 +04:00
|
|
|
/**
|
|
|
|
* |_code| is executed for every listener matching |_flag|
|
|
|
|
* |listener| should be used inside |_code| as the nsIWebProgressListener var.
|
|
|
|
*/
|
|
|
|
#define NOTIFY_LISTENERS(_flag, _code) \
|
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
nsCOMPtr<nsIWebProgressListener> listener; \
|
|
|
|
ListenerArray::BackwardIterator iter(mListenerInfoList); \
|
|
|
|
while (iter.HasMore()) { \
|
|
|
|
nsListenerInfo& info = iter.GetNext(); \
|
|
|
|
if (!(info.mNotifyMask & (_flag))) { \
|
|
|
|
continue; \
|
|
|
|
} \
|
|
|
|
listener = do_QueryReferent(info.mWeakListener); \
|
|
|
|
if (!listener) { \
|
|
|
|
iter.Remove(); \
|
|
|
|
continue; \
|
|
|
|
} \
|
|
|
|
_code \
|
|
|
|
} \
|
|
|
|
mListenerInfoList.Compact(); \
|
|
|
|
PR_END_MACRO
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
void nsDocLoader::FireOnProgressChange(nsDocLoader* aLoadInitiator,
|
2012-08-22 19:56:38 +04:00
|
|
|
nsIRequest* request, int64_t aProgress,
|
|
|
|
int64_t aProgressMax,
|
|
|
|
int64_t aProgressDelta,
|
|
|
|
int64_t aTotalProgress,
|
|
|
|
int64_t aMaxTotalProgress) {
|
2000-06-19 09:54:37 +04:00
|
|
|
if (mIsLoadingDocument) {
|
|
|
|
mCurrentTotalProgress += aProgressDelta;
|
2004-09-29 00:48:58 +04:00
|
|
|
mMaxTotalProgress = GetMaxTotalProgress();
|
2000-06-19 09:54:37 +04:00
|
|
|
|
|
|
|
aTotalProgress = mCurrentTotalProgress;
|
|
|
|
aMaxTotalProgress = mMaxTotalProgress;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString buffer;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
GetURIStringFromRequest(request, buffer);
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
2016-12-16 06:16:31 +03:00
|
|
|
("DocLoader:%p: Progress (%s): curSelf: %" PRId64 " maxSelf: %" PRId64
|
|
|
|
" curTotal: %" PRId64 " maxTotal %" PRId64 "\n",
|
2002-03-21 01:50:33 +03:00
|
|
|
this, buffer.get(), aProgress, aProgressMax, aTotalProgress,
|
|
|
|
aMaxTotalProgress));
|
2000-06-19 09:54:37 +04:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2014-04-19 11:43:34 +04:00
|
|
|
NOTIFY_LISTENERS(
|
|
|
|
nsIWebProgress::NOTIFY_PROGRESS,
|
2005-01-09 23:43:35 +03:00
|
|
|
// XXX truncates 64-bit to 32-bit
|
2001-02-21 23:38:08 +03:00
|
|
|
listener->OnProgressChange(aLoadInitiator, request, int32_t(aProgress),
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t(aProgressMax), int32_t(aTotalProgress),
|
|
|
|
int32_t(aMaxTotalProgress)););
|
2001-02-01 00:02:08 +03:00
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
// Pass the notification up to the parent...
|
|
|
|
if (mParent) {
|
2001-02-21 23:38:08 +03:00
|
|
|
mParent->FireOnProgressChange(aLoadInitiator, request, aProgress,
|
2000-06-19 09:54:37 +04:00
|
|
|
aProgressMax, aProgressDelta, aTotalProgress,
|
|
|
|
aMaxTotalProgress);
|
|
|
|
}
|
2000-04-25 05:45:37 +04:00
|
|
|
}
|
|
|
|
|
2011-09-09 07:19:45 +04:00
|
|
|
void nsDocLoader::GatherAncestorWebProgresses(WebProgressList& aList) {
|
|
|
|
for (nsDocLoader* loader = this; loader; loader = loader->mParent) {
|
|
|
|
aList.AppendElement(loader);
|
|
|
|
}
|
|
|
|
}
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
void nsDocLoader::FireOnStateChange(nsIWebProgress* aProgress,
|
2012-08-22 19:56:38 +04:00
|
|
|
nsIRequest* aRequest, int32_t aStateFlags,
|
2004-12-08 20:32:06 +03:00
|
|
|
nsresult aStatus) {
|
2011-09-09 07:19:45 +04:00
|
|
|
WebProgressList list;
|
|
|
|
GatherAncestorWebProgresses(list);
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < list.Length(); ++i) {
|
2011-09-09 07:19:45 +04:00
|
|
|
list[i]->DoFireOnStateChange(aProgress, aRequest, aStateFlags, aStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsDocLoader::DoFireOnStateChange(nsIWebProgress* const aProgress,
|
|
|
|
nsIRequest* const aRequest,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t& aStateFlags,
|
2011-09-09 07:19:45 +04:00
|
|
|
const nsresult aStatus) {
|
2000-06-19 09:54:37 +04:00
|
|
|
//
|
2000-08-25 22:39:46 +04:00
|
|
|
// Remove the STATE_IS_NETWORK bit if necessary.
|
2000-06-19 09:54:37 +04:00
|
|
|
//
|
|
|
|
// The rule is to remove this bit, if the notification has been passed
|
|
|
|
// up from a child WebProgress, and the current WebProgress is already
|
|
|
|
// active...
|
|
|
|
//
|
|
|
|
if (mIsLoadingDocument &&
|
2015-02-05 02:15:13 +03:00
|
|
|
(aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK) &&
|
2000-06-19 09:54:37 +04:00
|
|
|
(this != aProgress)) {
|
2000-08-25 22:39:46 +04:00
|
|
|
aStateFlags &= ~nsIWebProgressListener::STATE_IS_NETWORK;
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2005-06-16 03:52:46 +04:00
|
|
|
// Add the STATE_RESTORING bit if necessary.
|
|
|
|
if (mIsRestoringDocument)
|
|
|
|
aStateFlags |= nsIWebProgressListener::STATE_RESTORING;
|
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
#if defined(DEBUG)
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString buffer;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
GetURIStringFromRequest(aRequest, buffer);
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
2000-06-19 09:54:37 +04:00
|
|
|
("DocLoader:%p: Status (%s): code: %x\n", this, buffer.get(),
|
2002-03-21 01:50:33 +03:00
|
|
|
aStateFlags));
|
2000-06-19 09:54:37 +04:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2001-04-28 01:05:52 +04:00
|
|
|
NS_ASSERTION(aRequest,
|
|
|
|
"Firing OnStateChange(...) notification with a NULL request!");
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2014-04-19 11:43:34 +04:00
|
|
|
NOTIFY_LISTENERS(
|
|
|
|
((aStateFlags >> 16) & nsIWebProgress::NOTIFY_STATE_ALL),
|
2000-06-19 09:54:37 +04:00
|
|
|
listener->OnStateChange(aProgress, aRequest, aStateFlags, aStatus););
|
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
void nsDocLoader::FireOnLocationChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest, nsIURI* aUri,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags) {
|
2014-04-19 11:43:34 +04:00
|
|
|
NOTIFY_LISTENERS(
|
|
|
|
nsIWebProgress::NOTIFY_LOCATION,
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
|
|
|
("DocLoader [%p] calling %p->OnLocationChange", this,
|
|
|
|
listener.get()));
|
2011-11-10 18:01:11 +04:00
|
|
|
listener->OnLocationChange(aWebProgress, aRequest, aUri, aFlags););
|
2002-05-17 00:57:37 +04:00
|
|
|
|
2001-05-19 01:46:59 +04:00
|
|
|
// Pass the notification up to the parent...
|
|
|
|
if (mParent) {
|
2011-11-10 18:01:11 +04:00
|
|
|
mParent->FireOnLocationChange(aWebProgress, aRequest, aUri, aFlags);
|
2001-05-19 01:46:59 +04:00
|
|
|
}
|
2000-07-25 09:45:56 +04:00
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
void nsDocLoader::FireOnStatusChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest, nsresult aStatus,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aMessage) {
|
2014-04-19 11:43:34 +04:00
|
|
|
NOTIFY_LISTENERS(
|
|
|
|
nsIWebProgress::NOTIFY_STATUS,
|
2000-07-25 09:45:56 +04:00
|
|
|
listener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage););
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2002-05-17 00:57:37 +04:00
|
|
|
// Pass the notification up to the parent...
|
|
|
|
if (mParent) {
|
|
|
|
mParent->FireOnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
|
|
|
|
}
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2007-02-08 16:15:50 +03:00
|
|
|
bool nsDocLoader::RefreshAttempted(nsIWebProgress* aWebProgress, nsIURI* aURI,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aDelay, bool aSameURI) {
|
2007-02-08 16:15:50 +03:00
|
|
|
/*
|
|
|
|
* Returns true if the refresh may proceed,
|
|
|
|
* false if the refresh should be blocked.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool allowRefresh = true;
|
2007-02-08 16:15:50 +03:00
|
|
|
|
2014-04-19 11:43:34 +04:00
|
|
|
NOTIFY_LISTENERS(
|
|
|
|
nsIWebProgress::NOTIFY_REFRESH,
|
2007-02-08 16:15:50 +03:00
|
|
|
nsCOMPtr<nsIWebProgressListener2> listener2 =
|
2014-04-19 11:43:34 +04:00
|
|
|
do_QueryReferent(info.mWeakListener);
|
2007-02-08 16:15:50 +03:00
|
|
|
if (!listener2) continue;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool listenerAllowedRefresh;
|
2007-02-08 16:15:50 +03:00
|
|
|
nsresult listenerRV = listener2->OnRefreshAttempted(
|
|
|
|
aWebProgress, aURI, aDelay, aSameURI, &listenerAllowedRefresh);
|
|
|
|
if (NS_FAILED(listenerRV)) continue;
|
|
|
|
|
|
|
|
allowRefresh = allowRefresh && listenerAllowedRefresh;);
|
|
|
|
|
|
|
|
// Pass the notification up to the parent...
|
|
|
|
if (mParent) {
|
|
|
|
allowRefresh = allowRefresh && mParent->RefreshAttempted(aWebProgress, aURI,
|
|
|
|
aDelay, aSameURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
return allowRefresh;
|
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
nsresult nsDocLoader::AddRequestInfo(nsIRequest* aRequest) {
|
2015-09-15 00:23:12 +03:00
|
|
|
if (!mRequestInfoHash.Add(aRequest, mozilla::fallible)) {
|
2002-07-09 04:54:41 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
2002-07-09 04:54:41 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2009-04-08 12:45:32 +04:00
|
|
|
void nsDocLoader::RemoveRequestInfo(nsIRequest* aRequest) {
|
2015-09-15 00:23:24 +03:00
|
|
|
mRequestInfoHash.Remove(aRequest);
|
2009-04-08 12:45:32 +04:00
|
|
|
}
|
|
|
|
|
2018-07-13 13:01:53 +03:00
|
|
|
nsDocLoader::nsRequestInfo* nsDocLoader::GetRequestInfo(
|
|
|
|
nsIRequest* aRequest) const {
|
2015-05-21 10:34:25 +03:00
|
|
|
return static_cast<nsRequestInfo*>(mRequestInfoHash.Search(aRequest));
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
void nsDocLoader::ClearRequestInfoHash(void) { mRequestInfoHash.Clear(); }
|
2002-07-09 04:54:41 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t nsDocLoader::CalculateMaxProgress() {
|
|
|
|
int64_t max = mCompletedTotalProgress;
|
2015-06-12 07:19:53 +03:00
|
|
|
for (auto iter = mRequestInfoHash.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
auto info = static_cast<const nsRequestInfo*>(iter.Get());
|
2015-06-10 23:07:40 +03:00
|
|
|
|
|
|
|
if (info->mMaxProgress < info->mCurrentProgress) {
|
|
|
|
return int64_t(-1);
|
|
|
|
}
|
|
|
|
max += info->mMaxProgress;
|
|
|
|
}
|
2004-09-29 00:48:58 +04:00
|
|
|
return max;
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2010-08-05 06:15:55 +04:00
|
|
|
NS_IMETHODIMP nsDocLoader::AsyncOnChannelRedirect(
|
|
|
|
nsIChannel* aOldChannel, nsIChannel* aNewChannel, uint32_t aFlags,
|
|
|
|
nsIAsyncVerifyRedirectCallback* cb) {
|
2018-11-01 00:16:28 +03:00
|
|
|
if (aFlags & (nsIChannelEventSink::REDIRECT_TEMPORARY |
|
|
|
|
nsIChannelEventSink::REDIRECT_PERMANENT)) {
|
|
|
|
nsCOMPtr<nsIDocShell> docShell =
|
|
|
|
do_QueryInterface(static_cast<nsIRequestObserver*>(this));
|
|
|
|
|
|
|
|
nsCOMPtr<nsILoadURIDelegate> delegate;
|
|
|
|
if (docShell) {
|
|
|
|
docShell->GetLoadURIDelegate(getter_AddRefs(delegate));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> newURI;
|
2019-04-25 15:16:35 +03:00
|
|
|
nsCOMPtr<nsILoadInfo> info = nullptr;
|
2018-11-01 00:16:28 +03:00
|
|
|
if (delegate) {
|
|
|
|
// No point in getting the URI if we don't have a LoadURIDelegate.
|
|
|
|
aNewChannel->GetURI(getter_AddRefs(newURI));
|
2019-04-25 15:16:35 +03:00
|
|
|
info = aNewChannel->LoadInfo();
|
2019-01-28 18:35:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Document> loadingDoc;
|
|
|
|
if (info) {
|
|
|
|
info->GetLoadingDocument(getter_AddRefs(loadingDoc));
|
2018-11-01 00:16:28 +03:00
|
|
|
}
|
|
|
|
|
2019-01-28 18:35:17 +03:00
|
|
|
if (newURI && info && !loadingDoc) {
|
2018-11-01 00:16:28 +03:00
|
|
|
const int where = nsIBrowserDOMWindow::OPEN_CURRENTWINDOW;
|
|
|
|
bool loadURIHandled = false;
|
2018-11-22 01:35:42 +03:00
|
|
|
nsresult rv = delegate->LoadURI(
|
|
|
|
newURI, where, nsIWebNavigation::LOAD_FLAGS_IS_REDIRECT,
|
2018-11-01 00:16:28 +03:00
|
|
|
/* triggering principal */ nullptr, &loadURIHandled);
|
|
|
|
if (NS_SUCCEEDED(rv) && loadURIHandled) {
|
2020-02-10 17:30:29 +03:00
|
|
|
aOldChannel->Cancel(NS_ERROR_ABORT);
|
|
|
|
cb->OnRedirectVerifyCallback(NS_ERROR_ABORT);
|
2018-11-01 00:16:28 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-28 01:05:52 +04:00
|
|
|
if (aOldChannel) {
|
|
|
|
nsLoadFlags loadFlags = 0;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t stateFlags = nsIWebProgressListener::STATE_REDIRECTING |
|
2001-04-28 01:05:52 +04:00
|
|
|
nsIWebProgressListener::STATE_IS_REQUEST;
|
|
|
|
|
|
|
|
aOldChannel->GetLoadFlags(&loadFlags);
|
|
|
|
// If the document channel is being redirected, then indicate that the
|
|
|
|
// document is being redirected in the notification...
|
|
|
|
if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) {
|
|
|
|
stateFlags |= nsIWebProgressListener::STATE_IS_DOCUMENT;
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
2017-10-09 20:03:40 +03:00
|
|
|
// We only set mDocumentRequest in OnStartRequest(), but its possible
|
|
|
|
// to get a redirect before that for service worker interception.
|
|
|
|
if (mDocumentRequest) {
|
2018-10-02 00:38:01 +03:00
|
|
|
nsCOMPtr<nsIRequest> request(aOldChannel);
|
2017-10-09 20:03:40 +03:00
|
|
|
NS_ASSERTION(request == mDocumentRequest, "Wrong Document Channel");
|
|
|
|
}
|
2001-04-28 01:05:52 +04:00
|
|
|
#endif /* DEBUG */
|
|
|
|
}
|
|
|
|
|
2010-10-01 03:55:11 +04:00
|
|
|
OnRedirectStateChange(aOldChannel, aNewChannel, aFlags, stateFlags);
|
2001-04-28 01:05:52 +04:00
|
|
|
FireOnStateChange(this, aOldChannel, stateFlags, NS_OK);
|
|
|
|
}
|
|
|
|
|
2010-08-05 06:15:55 +04:00
|
|
|
cb->OnRedirectVerifyCallback(NS_OK);
|
2001-04-28 01:05:52 +04:00
|
|
|
return NS_OK;
|
2000-08-25 05:32:40 +04:00
|
|
|
}
|
|
|
|
|
2019-01-26 21:31:58 +03:00
|
|
|
void nsDocLoader::OnSecurityChange(nsISupports* aContext, uint32_t aState) {
|
2000-09-15 02:56:56 +04:00
|
|
|
//
|
2015-02-05 02:15:13 +03:00
|
|
|
// Fire progress notifications out to any registered nsIWebProgressListeners.
|
2000-09-15 02:56:56 +04:00
|
|
|
//
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2000-09-15 02:56:56 +04:00
|
|
|
nsCOMPtr<nsIRequest> request = do_QueryInterface(aContext);
|
2007-07-08 11:08:04 +04:00
|
|
|
nsIWebProgress* webProgress = static_cast<nsIWebProgress*>(this);
|
2000-09-15 02:56:56 +04:00
|
|
|
|
2014-04-19 11:43:34 +04:00
|
|
|
NOTIFY_LISTENERS(nsIWebProgress::NOTIFY_SECURITY,
|
2018-11-29 18:46:08 +03:00
|
|
|
listener->OnSecurityChange(webProgress, request, aState););
|
2001-02-01 00:02:08 +03:00
|
|
|
|
2000-09-15 02:56:56 +04:00
|
|
|
// Pass the notification up to the parent...
|
|
|
|
if (mParent) {
|
2018-11-29 18:50:38 +03:00
|
|
|
mParent->OnSecurityChange(aContext, aState);
|
2000-09-15 02:56:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-21 23:58:01 +03:00
|
|
|
/*
|
|
|
|
* Implementation of nsISupportsPriority methods...
|
|
|
|
*
|
|
|
|
* The priority of the DocLoader _is_ the priority of its LoadGroup.
|
|
|
|
*
|
|
|
|
* XXX(darin): Once we start storing loadgroups in loadgroups, this code will
|
2015-02-05 02:15:13 +03:00
|
|
|
* go away.
|
2005-02-21 23:58:01 +03:00
|
|
|
*/
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsDocLoader::GetPriority(int32_t* aPriority) {
|
2005-02-21 23:58:01 +03:00
|
|
|
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(mLoadGroup);
|
|
|
|
if (p) return p->GetPriority(aPriority);
|
|
|
|
|
|
|
|
*aPriority = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsDocLoader::SetPriority(int32_t aPriority) {
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
2005-02-21 23:58:01 +03:00
|
|
|
("DocLoader:%p: SetPriority(%d) called\n", this, aPriority));
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(mLoadGroup);
|
|
|
|
if (p) p->SetPriority(aPriority);
|
|
|
|
|
2013-02-21 01:33:44 +04:00
|
|
|
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mChildList, nsDocLoader, SetPriority,
|
|
|
|
(aPriority));
|
2005-02-21 23:58:01 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsDocLoader::AdjustPriority(int32_t aDelta) {
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
2005-02-22 01:21:21 +03:00
|
|
|
("DocLoader:%p: AdjustPriority(%d) called\n", this, aDelta));
|
2005-02-21 23:58:01 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(mLoadGroup);
|
2005-02-22 01:21:21 +03:00
|
|
|
if (p) p->AdjustPriority(aDelta);
|
2005-02-21 23:58:01 +03:00
|
|
|
|
2013-02-21 01:33:44 +04:00
|
|
|
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mChildList, nsDocLoader,
|
|
|
|
AdjustPriority, (aDelta));
|
2005-02-21 23:58:01 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
#if 0
|
2004-12-08 20:32:06 +03:00
|
|
|
void nsDocLoader::DumpChannelInfo()
|
2000-06-19 09:54:37 +04:00
|
|
|
{
|
|
|
|
nsChannelInfo *info;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t i, count;
|
|
|
|
int32_t current=0, max=0;
|
2000-06-19 09:54:37 +04:00
|
|
|
|
2015-02-05 02:15:13 +03:00
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("==== DocLoader=%x\n", this);
|
2000-06-19 09:54:37 +04:00
|
|
|
|
|
|
|
count = mChannelInfoList.Count();
|
|
|
|
for(i=0; i<count; i++) {
|
|
|
|
info = (nsChannelInfo *)mChannelInfoList.ElementAt(i);
|
|
|
|
|
|
|
|
# if defined(DEBUG)
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString buffer;
|
2000-06-19 09:54:37 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (info->mURI) {
|
2002-03-21 01:50:33 +03:00
|
|
|
rv = info->mURI->GetSpec(buffer);
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" [%d] current=%d max=%d [%s]\n", i,
|
2015-02-05 02:15:13 +03:00
|
|
|
info->mCurrentProgress,
|
2002-03-21 01:50:33 +03:00
|
|
|
info->mMaxProgress, buffer.get());
|
2000-06-19 09:54:37 +04:00
|
|
|
# endif /* DEBUG */
|
|
|
|
|
|
|
|
current += info->mCurrentProgress;
|
|
|
|
if (max >= 0) {
|
|
|
|
if (info->mMaxProgress < info->mCurrentProgress) {
|
|
|
|
max = -1;
|
|
|
|
} else {
|
|
|
|
max += info->mMaxProgress;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("\nCurrent=%d Total=%d\n====\n", current, max);
|
2000-06-19 09:54:37 +04:00
|
|
|
}
|
2000-06-19 17:03:52 +04:00
|
|
|
#endif /* 0 */
|