Compare commits
295
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42f895f27f | ||
|
|
a6f632714f | ||
|
|
b28effe2ea | ||
|
|
afd6edd667 | ||
|
|
582a1ce72a | ||
|
|
71ac56ba40 | ||
|
|
ae184d09e6 | ||
|
|
868f0755ae | ||
|
|
5ca8fbd41c | ||
|
|
549c8b9283 | ||
|
|
77e8ba7eaf | ||
|
|
e854d58633 | ||
|
|
d58cb8e11b | ||
|
|
429a7bdb93 | ||
|
|
3f14e9ec5f | ||
|
|
aefb293793 | ||
|
|
c583315558 | ||
|
|
834ecdc59a | ||
|
|
798c2ed4f8 | ||
|
|
767b637c83 | ||
|
|
702ad218b0 | ||
|
|
b9af9c0c51 | ||
|
|
9d6e28d3d0 | ||
|
|
c735355ae1 | ||
|
|
10a10fd375 | ||
|
|
1012dbe9e5 | ||
|
|
9982c1f5cb | ||
|
|
fe912e94e4 | ||
|
|
770b1c9071 | ||
|
|
daf56131a7 | ||
|
|
d8686de401 | ||
|
|
c8a38346c8 | ||
|
|
70bafe4df5 | ||
|
|
498b1ab0c8 | ||
|
|
2f145b6eda | ||
|
|
06a092d08e | ||
|
|
d107016d37 | ||
|
|
63371593c0 | ||
|
|
ce1dc7e6c6 | ||
|
|
a4780ebaeb | ||
|
|
c384fa6e25 | ||
|
|
5e8e0d05a6 | ||
|
|
bf95a03189 | ||
|
|
c75e412f17 | ||
|
|
0bbe6ec105 | ||
|
|
48d31ea5eb | ||
|
|
3cf0843679 | ||
|
|
ff21776616 | ||
|
|
2f022ab1fa | ||
|
|
14e7f881be | ||
|
|
4f03fb2798 | ||
|
|
3dd316f739 | ||
|
|
972ab6d437 | ||
|
|
83ae5bd019 | ||
|
|
c237a54f23 | ||
|
|
8f72a673ca | ||
|
|
3266e0976f | ||
|
|
4433519ae8 | ||
|
|
d419fe2d52 | ||
|
|
c77c6de9ce | ||
|
|
2ed0607c74 | ||
|
|
922a72766c | ||
|
|
16d1313104 | ||
|
|
0387f52bd3 | ||
|
|
a1ca8ca9bd | ||
|
|
2ee2ca7dfb | ||
|
|
0d7b7b74c6 | ||
|
|
45db2388fe | ||
|
|
323288bc72 | ||
|
|
3323a8eda3 | ||
|
|
71293f0fe4 | ||
|
|
a91722be27 | ||
|
|
1ef64f9ea3 | ||
|
|
4a960879c8 | ||
|
|
4329ae3337 | ||
|
|
ad453f0b28 | ||
|
|
d332d4a60d | ||
|
|
ad5e9449d2 | ||
|
|
71848c23a4 | ||
|
|
1d321e689e | ||
|
|
b9b9d5bfb9 | ||
|
|
b92abc83c2 | ||
|
|
4950c982e0 | ||
|
|
86b184b957 | ||
|
|
33ba46c6bb | ||
|
|
451980d51b | ||
|
|
4ddbe58171 | ||
|
|
84caa4f3ad | ||
|
|
4f44e23c16 | ||
|
|
a69eda9b9c | ||
|
|
f1b51be787 | ||
|
|
82faff19e1 | ||
|
|
1597b61148 | ||
|
|
694c5f889c | ||
|
|
c1f8c0cb5d | ||
|
|
dcab408a5f | ||
|
|
407c503fa4 | ||
|
|
9130f12906 | ||
|
|
5e2b3d1d89 | ||
|
|
0c5a41e894 | ||
|
|
e29a8bd113 | ||
|
|
83abc5af59 | ||
|
|
47101f49c0 | ||
|
|
f6a6900a6b | ||
|
|
40aad1a220 | ||
|
|
1e14031a59 | ||
|
|
765c90318f | ||
|
|
ef8d18da70 | ||
|
|
7bf3e4c464 | ||
|
|
57523a0deb | ||
|
|
3f25d0c8e4 | ||
|
|
ab05017026 | ||
|
|
255c7f6f3a | ||
|
|
5ffe27bb03 | ||
|
|
0633844f46 | ||
|
|
d0126b96cd | ||
|
|
d4cd571021 | ||
|
|
016c55f409 | ||
|
|
016313d559 | ||
|
|
1fa428a789 | ||
|
|
d41fe2f55a | ||
|
|
4d9da86152 | ||
|
|
aa19e3d8ba | ||
|
|
f5b146a460 | ||
|
|
e2403eeb5a | ||
|
|
301ae8c2df | ||
|
|
21403c31e0 | ||
|
|
29bca891d5 | ||
|
|
bb70605829 | ||
|
|
3f3d626434 | ||
|
|
a04d67dd12 | ||
|
|
9e2da53a02 | ||
|
|
2b41c85019 | ||
|
|
e9d41c9968 | ||
|
|
0e0feed5da | ||
|
|
7f238b1cf9 | ||
|
|
6235023c8b | ||
|
|
f51beb3fda | ||
|
|
a934165b57 | ||
|
|
2516886ceb | ||
|
|
fbab1f4f9e | ||
|
|
90c42b7afd | ||
|
|
2deaddfca2 | ||
|
|
0ccb51f2ae | ||
|
|
5e5f2277f5 | ||
|
|
265d1b8019 | ||
|
|
687f535b9c | ||
|
|
54b4fb0be6 | ||
|
|
a054ece041 | ||
|
|
c6ca4380e9 | ||
|
|
744b044935 | ||
|
|
b246f7b2f1 | ||
|
|
8618719921 | ||
|
|
b6db7da98a | ||
|
|
9805ddc483 | ||
|
|
83ac4391b6 | ||
|
|
027a4cac9c | ||
|
|
66470fa1d8 | ||
|
|
451509e2c0 | ||
|
|
7895b8acd9 | ||
|
|
ccff4610c5 | ||
|
|
3045e1d5c9 | ||
|
|
44de3c3023 | ||
|
|
a3124c55a1 | ||
|
|
c4ed566602 | ||
|
|
15a1f78f8b | ||
|
|
8b44473fe6 | ||
|
|
6e0aee959e | ||
|
|
99c2e698d2 | ||
|
|
15ac4021b0 | ||
|
|
344b272991 | ||
|
|
fb8fcffe1d | ||
|
|
b67a630966 | ||
|
|
a148bd40d8 | ||
|
|
e59757fddf | ||
|
|
be954fca72 | ||
|
|
f411e02716 | ||
|
|
a34d02924c | ||
|
|
084ea153c1 | ||
|
|
c40bda67bb | ||
|
|
0c2de12ffd | ||
|
|
e44709892b | ||
|
|
237f8d7ebd | ||
|
|
5001007287 | ||
|
|
f83a88907a | ||
|
|
ff8603d7a2 | ||
|
|
31ad2d12db | ||
|
|
494cfe32c9 | ||
|
|
b4f0be5e95 | ||
|
|
ac62e4cfdd | ||
|
|
0fa41e2adc | ||
|
|
61af6cc299 | ||
|
|
c3a21acaee | ||
|
|
3fb8648bed | ||
|
|
f18d78dea0 | ||
|
|
16ae8db806 | ||
|
|
43f57fe642 | ||
|
|
f50410bd79 | ||
|
|
609d904cc1 | ||
|
|
fa1628f767 | ||
|
|
0136960ec0 | ||
|
|
d9e0b4be85 | ||
|
|
a17ab79b88 | ||
|
|
f11fff32fa | ||
|
|
912e37d202 | ||
|
|
e15b6906c5 | ||
|
|
b048f3d473 | ||
|
|
6cdd6c6286 | ||
|
|
25c1a5cbe3 | ||
|
|
83a71d9c9d | ||
|
|
d8a0849b7f | ||
|
|
02923a3648 | ||
|
|
a5da610b87 | ||
|
|
aedf5c0169 | ||
|
|
1c16924e08 | ||
|
|
9c21ed1804 | ||
|
|
41b982b9bb | ||
|
|
4c76b52e09 | ||
|
|
e50cfc7b63 | ||
|
|
8bbc95988a | ||
|
|
ed9eb8f722 | ||
|
|
1cd91bc155 | ||
|
|
8c8e5fba69 | ||
|
|
ed1ea719dd | ||
|
|
d38d5414fc | ||
|
|
1182ecd0b4 | ||
|
|
3220b7dc56 | ||
|
|
3e82ac05b1 | ||
|
|
3ab7bd811f | ||
|
|
8c4892fb45 | ||
|
|
11749de754 | ||
|
|
5186d78330 | ||
|
|
0538c32e32 | ||
|
|
46040d136d | ||
|
|
35c731cf08 | ||
|
|
b1851a4ad0 | ||
|
|
935ce8fa8e | ||
|
|
85b89ee754 | ||
|
|
9c006089e1 | ||
|
|
c3fc87a904 | ||
|
|
5f04717b00 | ||
|
|
e74b4ad8f8 | ||
|
|
fa68aa6fd5 | ||
|
|
9f37161ec5 | ||
|
|
21348b56d9 | ||
|
|
ad69c023a9 | ||
|
|
206b1af429 | ||
|
|
2bdbc482e7 | ||
|
|
a444b5cc39 | ||
|
|
d050188cd5 | ||
|
|
3a1bebfb87 | ||
|
|
d3d3aad6e5 | ||
|
|
d8d0538162 | ||
|
|
36369e0fef | ||
|
|
3c1e71f0b1 | ||
|
|
71137783ac | ||
|
|
fe0963002f | ||
|
|
aeef4240d5 | ||
|
|
938e6204ef | ||
|
|
16aaa21930 | ||
|
|
6b7997abbe | ||
|
|
f358c4dfa9 | ||
|
|
ad5cb04d71 | ||
|
|
ba5930cc8e | ||
|
|
6376255c0c | ||
|
|
9be6582ec3 | ||
|
|
883fa80f7d | ||
|
|
82b6d2cf9d | ||
|
|
09b4a7828e | ||
|
|
ed58b7905e | ||
|
|
31f47a2ba4 | ||
|
|
8b3b858546 | ||
|
|
dd506c896f | ||
|
|
f8588a2e86 | ||
|
|
0aa1b02b2b | ||
|
|
e008deb88b | ||
|
|
56cb90a482 | ||
|
|
812574875b | ||
|
|
cd196a77d4 | ||
|
|
e175224b88 | ||
|
|
0afb9e2d75 | ||
|
|
e733c3681b | ||
|
|
157cd64a8e | ||
|
|
5c3c92da90 | ||
|
|
aa21f96cf5 | ||
|
|
537c63d600 | ||
|
|
975db4c7f0 | ||
|
|
528abd534e | ||
|
|
320682148b | ||
|
|
1ed84ac1f8 | ||
|
|
9c9d04e3e0 | ||
|
|
19504d5263 | ||
|
|
533b346f4e | ||
|
|
6afd96c460 | ||
|
|
9858dc03cb |
No files matched your search
@@ -22,5 +22,4 @@
|
||||
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
|
||||
# don't change CLOBBER for WebIDL changes any more.
|
||||
|
||||
Clobber for NSS Update
|
||||
|
||||
Clobber for NSS update
|
||||
@@ -18,7 +18,7 @@ directory. This will contain relevant documentation regarding contributing,
|
||||
using and distributing this code and its binaries.
|
||||
|
||||
If you are interested in the development and building side of things, some
|
||||
information will be available on the [Pale Moon developer wiki](http://developer.palemoon.org).
|
||||
information will be available on the [Pale Moon developer site](http://developer.palemoon.org).
|
||||
You are also always welcome to get in touch with our community on the [Pale Moon forum](https://forum.palemoon.org/).
|
||||
|
||||
### A note about trademarks and branding
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
'listitem-2-3']);
|
||||
|
||||
queueTraversalSequence(gQueue, docAcc, TraversalRules.Graphic, null,
|
||||
['image-2', 'image-3']);
|
||||
['image-1', 'image-2', 'image-3']);
|
||||
|
||||
queueTraversalSequence(gQueue, docAcc, TraversalRules.Link, null,
|
||||
['link-0', 'link-1', 'link-2', 'link-3']);
|
||||
@@ -117,7 +117,7 @@
|
||||
'1. Scheme', '2. Racket', '3. Clojure',
|
||||
'4. Standard Lisp', 'link-0', ' Lisp',
|
||||
'checkbox-1-5', ' LeLisp', '• JavaScript',
|
||||
'heading-5', 'image-2', 'image-3',
|
||||
'heading-5', 'image-1', 'image-2', 'image-3',
|
||||
'Not actually an image', 'link-1', 'anchor-1',
|
||||
'link-2', 'anchor-2', 'link-3', '3', '1', '4',
|
||||
'1', 'Sunday', 'M', 'Week 1', '3', '4', '7', '2',
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
document.getElementsByTagName("img")[0].firstChild.data = "2";
|
||||
|
||||
var accTree = {
|
||||
role: ROLE_TEXT,
|
||||
children: [ { role: ROLE_TEXT_LEAF } ]
|
||||
role: ROLE_GRAPHIC,
|
||||
children: []
|
||||
};
|
||||
testAccessibleTree("the_img", accTree);
|
||||
SimpleTest.finish();
|
||||
|
||||
@@ -38,7 +38,7 @@ if test -n "$USE_ICU"; then
|
||||
dnl We also don't do it on Windows because sometimes the file goes
|
||||
dnl missing -- possibly due to overzealous antivirus software? --
|
||||
dnl which prevents the browser from starting up :(
|
||||
if test -z "$JS_STANDALONE" -a "$OS_TARGET" != WINNT -a "$MOZ_WIDGET_TOOLKIT" != "android"; then
|
||||
if test -z "$JS_STANDALONE"; then
|
||||
MOZ_ICU_DATA_ARCHIVE=1
|
||||
else
|
||||
MOZ_ICU_DATA_ARCHIVE=
|
||||
|
||||
@@ -310,6 +310,7 @@ def old_configure_options(*options):
|
||||
'--disable-browser-statusbar',
|
||||
'--disable-sync',
|
||||
'--disable-personas',
|
||||
'--enable-phoenix-extensions',
|
||||
|
||||
# Below are configure flags used by Basilisk
|
||||
'--disable-webextensions',
|
||||
|
||||
Vendored
-6
@@ -40,12 +40,6 @@ external_dirs += ['media/libwebp']
|
||||
if CONFIG['CPU_ARCH'] == 'arm':
|
||||
external_dirs += ['media/openmax_dl']
|
||||
|
||||
if CONFIG['MOZ_WEBSPEECH_POCKETSPHINX']:
|
||||
external_dirs += [
|
||||
'media/sphinxbase',
|
||||
'media/pocketsphinx',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_FFVPX']:
|
||||
external_dirs += ['media/ffvpx']
|
||||
|
||||
|
||||
Vendored
+3
@@ -112,6 +112,7 @@ CERT_GetCertChainFromCert
|
||||
CERT_GetCertEmailAddress
|
||||
CERT_GetCertificateDer
|
||||
CERT_GetCertificateRequestExtensions
|
||||
CERT_GetCertKeyType
|
||||
CERT_GetCertTimes
|
||||
CERT_GetCertTrust
|
||||
CERT_GetCommonName
|
||||
@@ -270,6 +271,7 @@ NSS_Init
|
||||
NSS_Initialize
|
||||
NSS_InitWithMerge
|
||||
NSS_IsInitialized
|
||||
NSS_OptionGet
|
||||
NSS_OptionSet
|
||||
NSS_NoDB_Init
|
||||
NSS_SecureMemcmp
|
||||
@@ -383,6 +385,7 @@ PK11_GetNextSymKey
|
||||
PK11_GetPadMechanism
|
||||
PK11_GetPrivateKeyNickname
|
||||
PK11_GetPrivateModulusLen
|
||||
PK11_GetSlotFromPrivateKey
|
||||
PK11_GetSlotID
|
||||
PK11_GetSlotInfo
|
||||
PK11_GetSlotName
|
||||
|
||||
@@ -10,4 +10,4 @@
|
||||
# hardcoded milestones in the tree from these two files.
|
||||
#--------------------------------------------------------
|
||||
|
||||
4.5.0
|
||||
4.6.0
|
||||
@@ -65,9 +65,13 @@ if CONFIG['MOZ_DEBUG']:
|
||||
|
||||
# Force using malloc_usable_size when building with jemalloc because _msize
|
||||
# causes assertions on Win64. See bug 719579.
|
||||
# This causes a known warning due to the way mozjemalloc is linked and the
|
||||
# malloc_usable_size function not being available at compile time on MSVC
|
||||
# so we suppress that particular warning (C4013)
|
||||
if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['MOZ_MEMORY']:
|
||||
DEFINES['HAVE_MALLOC_USABLE_SIZE'] = True
|
||||
DEFINES['SQLITE_WITHOUT_MSIZE'] = True
|
||||
CFLAGS += ['-wd4013']
|
||||
|
||||
# Omit unused functions to save some library footprint.
|
||||
DEFINES['SQLITE_OMIT_DEPRECATED'] = True
|
||||
|
||||
+20958
-15503
File diff suppressed because it is too large.
Load diff
+1205
-888
File diff suppressed because it is too large.
Load diff
@@ -91,7 +91,7 @@ const Curl = {
|
||||
if (utils.isUrlEncodedRequest(data) ||
|
||||
["PUT", "POST", "PATCH"].includes(data.method)) {
|
||||
postDataText = data.postDataText;
|
||||
addPostData("--data");
|
||||
addPostData("--data-raw");
|
||||
addPostData(utils.writePostDataTextParams(postDataText));
|
||||
ignoredHeaders.add("content-length");
|
||||
} else if (multipartRequest) {
|
||||
@@ -400,7 +400,12 @@ const CurlUtils = {
|
||||
* Credit: Google DevTools
|
||||
*/
|
||||
escapeStringWin: function (str) {
|
||||
/* Replace quote by double quote (but not by \") because it is
|
||||
/*
|
||||
Replace dollar sign because of commands (e.g $(cmd.exe)) in
|
||||
powershell when using double quotes.
|
||||
Useful details http://www.rlmueller.net/PowerShellEscape.htm
|
||||
|
||||
Replace quote by double quote (but not by \") because it is
|
||||
recognized by both cmd.exe and MS Crt arguments parser.
|
||||
|
||||
Replace % by "%" because it could be expanded to an environment
|
||||
@@ -414,7 +419,8 @@ const CurlUtils = {
|
||||
Replace new line outside of quotes since cmd.exe doesn't let
|
||||
to do it inside.
|
||||
*/
|
||||
return "\"" + str.replace(/"/g, "\"\"")
|
||||
return "\"" + str.replace(/\$/g, "`$")
|
||||
.replace(/"/g, "\"\"")
|
||||
.replace(/%/g, "\"%\"")
|
||||
.replace(/\\/g, "\\\\")
|
||||
.replace(/[\r\n]+/g, "\"^$&\"") + "\"";
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
a {
|
||||
-moz-user-focus: normal;
|
||||
-moz-user-input: enabled;
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@@ -1440,6 +1440,8 @@ exports.CSS_PROPERTIES = {
|
||||
"supports": [],
|
||||
"values": [
|
||||
"auto",
|
||||
"disabled",
|
||||
"enabled",
|
||||
"inherit",
|
||||
"initial",
|
||||
"none",
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "AbortController.h"
|
||||
#include "AbortSignal.h"
|
||||
#include "mozilla/dom/AbortControllerBinding.h"
|
||||
#include "WorkerPrivate.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AbortController, mGlobal, mSignal)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(AbortController)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(AbortController)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AbortController)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
/* static */ bool
|
||||
AbortController::IsEnabled(JSContext* aCx, JSObject* aGlobal)
|
||||
{
|
||||
if (NS_IsMainThread()) {
|
||||
return Preferences::GetBool("dom.abortController.enabled", false);
|
||||
}
|
||||
|
||||
using namespace workers;
|
||||
|
||||
// Otherwise, check the pref via the WorkerPrivate
|
||||
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
||||
if (!workerPrivate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return workerPrivate->AbortControllerEnabled();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<AbortController>
|
||||
AbortController::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!global) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<AbortController> abortController = new AbortController(global);
|
||||
return abortController.forget();
|
||||
}
|
||||
|
||||
AbortController::AbortController(nsIGlobalObject* aGlobal)
|
||||
: mGlobal(aGlobal)
|
||||
, mAborted(false)
|
||||
{}
|
||||
|
||||
JSObject*
|
||||
AbortController::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return AbortControllerBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
nsIGlobalObject*
|
||||
AbortController::GetParentObject() const
|
||||
{
|
||||
return mGlobal;
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
AbortController::Signal()
|
||||
{
|
||||
if (!mSignal) {
|
||||
mSignal = new AbortSignal(this, mAborted);
|
||||
}
|
||||
|
||||
return mSignal;
|
||||
}
|
||||
|
||||
void
|
||||
AbortController::Abort()
|
||||
{
|
||||
if (mAborted) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAborted = true;
|
||||
|
||||
if (mSignal) {
|
||||
mSignal->Abort();
|
||||
}
|
||||
}
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
@@ -0,0 +1,59 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_AbortController_h
|
||||
#define mozilla_dom_AbortController_h
|
||||
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/AbortSignal.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class AbortController final : public nsISupports
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AbortController)
|
||||
|
||||
static bool
|
||||
IsEnabled(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
static already_AddRefed<AbortController>
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
|
||||
explicit AbortController(nsIGlobalObject* aGlobal);
|
||||
|
||||
JSObject*
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
nsIGlobalObject*
|
||||
GetParentObject() const;
|
||||
|
||||
AbortSignal*
|
||||
Signal();
|
||||
|
||||
void
|
||||
Abort();
|
||||
|
||||
private:
|
||||
~AbortController() = default;
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> mGlobal;
|
||||
RefPtr<AbortSignal> mSignal;
|
||||
|
||||
bool mAborted;
|
||||
};
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
|
||||
#endif // mozilla_dom_AbortController_h
|
||||
@@ -0,0 +1,131 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "AbortSignal.h"
|
||||
#include "AbortController.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/AbortSignalBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(AbortSignal)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(AbortSignal,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mController)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(AbortSignal,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mController)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(AbortSignal)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(AbortSignal, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(AbortSignal, DOMEventTargetHelper)
|
||||
|
||||
AbortSignal::AbortSignal(AbortController* aController,
|
||||
bool aAborted)
|
||||
: DOMEventTargetHelper(aController->GetParentObject())
|
||||
, mController(aController)
|
||||
, mAborted(aAborted)
|
||||
{}
|
||||
|
||||
AbortSignal::AbortSignal(bool aAborted)
|
||||
: mAborted(aAborted)
|
||||
{}
|
||||
|
||||
JSObject*
|
||||
AbortSignal::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return AbortSignalBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
bool
|
||||
AbortSignal::Aborted() const
|
||||
{
|
||||
return mAborted;
|
||||
}
|
||||
|
||||
void
|
||||
AbortSignal::Abort()
|
||||
{
|
||||
// Re-entrancy guard
|
||||
if (mAborted) {
|
||||
return;
|
||||
}
|
||||
mAborted = true;
|
||||
|
||||
// We might be deleted as a result of aborting a follower, so ensure we
|
||||
// stay alive until all followers have been aborted.
|
||||
RefPtr<AbortSignal> pinThis = this;
|
||||
|
||||
// Let's inform the followers.
|
||||
for (uint32_t i = 0; i < mFollowers.Length(); ++i) {
|
||||
mFollowers[i]->Aborted();
|
||||
}
|
||||
|
||||
EventInit init;
|
||||
init.mBubbles = false;
|
||||
init.mCancelable = false;
|
||||
|
||||
RefPtr<Event> event =
|
||||
Event::Constructor(this, NS_LITERAL_STRING("abort"), init);
|
||||
event->SetTrusted(true);
|
||||
|
||||
bool dummy;
|
||||
DispatchEvent(event, &dummy);
|
||||
}
|
||||
|
||||
void
|
||||
AbortSignal::AddFollower(AbortSignal::Follower* aFollower)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(aFollower);
|
||||
if (!mFollowers.Contains(aFollower)) {
|
||||
mFollowers.AppendElement(aFollower);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AbortSignal::RemoveFollower(AbortSignal::Follower* aFollower)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(aFollower);
|
||||
mFollowers.RemoveElement(aFollower);
|
||||
}
|
||||
|
||||
// AbortSignal::Follower
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
AbortSignal::Follower::~Follower()
|
||||
{
|
||||
Unfollow();
|
||||
}
|
||||
|
||||
void
|
||||
AbortSignal::Follower::Follow(AbortSignal* aSignal)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(aSignal);
|
||||
|
||||
Unfollow();
|
||||
|
||||
mFollowingSignal = aSignal;
|
||||
aSignal->AddFollower(this);
|
||||
}
|
||||
|
||||
void
|
||||
AbortSignal::Follower::Unfollow()
|
||||
{
|
||||
if (mFollowingSignal) {
|
||||
mFollowingSignal->RemoveFollower(this);
|
||||
mFollowingSignal = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_AbortSignal_h
|
||||
#define mozilla_dom_AbortSignal_h
|
||||
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class AbortController;
|
||||
class AbortSignal;
|
||||
|
||||
class AbortSignal final : public DOMEventTargetHelper
|
||||
{
|
||||
public:
|
||||
// This class must be implemented by objects who want to follow a AbortSignal.
|
||||
class Follower
|
||||
{
|
||||
public:
|
||||
virtual void Aborted() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~Follower();
|
||||
|
||||
void
|
||||
Follow(AbortSignal* aSignal);
|
||||
|
||||
void
|
||||
Unfollow();
|
||||
|
||||
RefPtr<AbortSignal> mFollowingSignal;
|
||||
};
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AbortSignal, DOMEventTargetHelper)
|
||||
|
||||
AbortSignal(AbortController* aController, bool aAborted);
|
||||
explicit AbortSignal(bool aAborted);
|
||||
|
||||
JSObject*
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
bool
|
||||
Aborted() const;
|
||||
|
||||
void
|
||||
Abort();
|
||||
|
||||
IMPL_EVENT_HANDLER(abort);
|
||||
|
||||
void
|
||||
AddFollower(Follower* aFollower);
|
||||
|
||||
void
|
||||
RemoveFollower(Follower* aFollower);
|
||||
|
||||
private:
|
||||
~AbortSignal() = default;
|
||||
|
||||
RefPtr<AbortController> mController;
|
||||
|
||||
// Raw pointers. Follower unregisters itself in the DTOR.
|
||||
nsTArray<Follower*> mFollowers;
|
||||
|
||||
bool mAborted;
|
||||
};
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
|
||||
#endif // mozilla_dom_AbortSignal_h
|
||||
@@ -4,18 +4,23 @@
|
||||
# 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/.
|
||||
|
||||
EXPORTS.mozilla.dom.battery += [
|
||||
'Constants.h',
|
||||
'Types.h',
|
||||
with Files("**"):
|
||||
BUG_COMPONENT = ("Core", "DOM")
|
||||
|
||||
TEST_DIRS += ['tests']
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'AbortController.h',
|
||||
'AbortSignal.h',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'BatteryManager.cpp',
|
||||
'AbortController.cpp',
|
||||
'AbortSignal.cpp',
|
||||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
LOCAL_INCLUDES += [
|
||||
'../workers',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
|
||||
MOCHITEST_MANIFESTS += ['test/mochitest.ini']
|
||||
@@ -0,0 +1,113 @@
|
||||
<script>
|
||||
function ok(a, msg) {
|
||||
parent.postMessage({ type: "check", status: !!a, message: msg }, "*");
|
||||
}
|
||||
|
||||
function is(a, b, msg) {
|
||||
ok(a === b, msg);
|
||||
}
|
||||
|
||||
function testWebIDL() {
|
||||
ok("FetchController" in self, "We have a FetchController prototype");
|
||||
ok("FetchSignal" in self, "We have a FetchSignal prototype");
|
||||
|
||||
var fc = new FetchController();
|
||||
ok(!!fc, "FetchController can be created");
|
||||
ok(fc instanceof FetchController, "FetchController is a FetchController");
|
||||
|
||||
ok(!!fc.signal, "FetchController has a signal");
|
||||
ok(fc.signal instanceof FetchSignal, "fetchSignal is a FetchSignal");
|
||||
is(fc.signal.aborted, false, "By default FetchSignal.aborted is false");
|
||||
next();
|
||||
}
|
||||
|
||||
function testUpdateData() {
|
||||
var fc = new FetchController();
|
||||
|
||||
is(fc.signal.aborted, false, "By default FetchSignal.aborted is false");
|
||||
|
||||
fc.abort();
|
||||
is(fc.signal.aborted, true, "Signal is aborted");
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
function testAbortEvent() {
|
||||
var fc = new FetchController();
|
||||
fc.signal.onabort = function(e) {
|
||||
is(e.type, "abort", "Abort received");
|
||||
next();
|
||||
}
|
||||
fc.abort();
|
||||
}
|
||||
|
||||
function testAbortedFetch() {
|
||||
var fc = new FetchController();
|
||||
fc.abort();
|
||||
|
||||
fetch('slow.sjs', { signal: fc.signal }).then(() => {
|
||||
ok(false, "Fetch should not return a resolved promise");
|
||||
}, e => {
|
||||
is(e.name, "AbortError", "We have an abort error");
|
||||
}).then(next);
|
||||
}
|
||||
|
||||
function testFetchAndAbort() {
|
||||
var fc = new FetchController();
|
||||
|
||||
var p = fetch('slow.sjs', { signal: fc.signal });
|
||||
fc.abort();
|
||||
|
||||
p.then(() => {
|
||||
ok(false, "Fetch should not return a resolved promise");
|
||||
}, e => {
|
||||
is(e.name, "AbortError", "We have an abort error");
|
||||
}).then(next);
|
||||
}
|
||||
|
||||
function testWorkerAbortedFetch() {
|
||||
var w = new Worker('worker_fetch_controller.js');
|
||||
w.onmessage = function(e) {
|
||||
ok(e.data, "Abort + Fetch works in workers");
|
||||
next();
|
||||
}
|
||||
w.postMessage('testWorkerAbortedFetch');
|
||||
}
|
||||
|
||||
function testWorkerFetchAndAbort() {
|
||||
var w = new Worker('worker_fetch_controller.js');
|
||||
w.onmessage = function(e) {
|
||||
ok(e.data, "Abort + Fetch works in workers");
|
||||
next();
|
||||
}
|
||||
w.postMessage('testWorkerFetchAndAbort');
|
||||
}
|
||||
|
||||
var steps = [
|
||||
// Simple stuff
|
||||
testWebIDL,
|
||||
testUpdateData,
|
||||
|
||||
// Event propagation
|
||||
testAbortEvent,
|
||||
|
||||
// fetch + signaling
|
||||
testAbortedFetch,
|
||||
testFetchAndAbort,
|
||||
testWorkerAbortedFetch,
|
||||
testWorkerFetchAndAbort,
|
||||
];
|
||||
|
||||
function next() {
|
||||
if (!steps.length) {
|
||||
parent.postMessage({ type: "finish" }, "*");
|
||||
return;
|
||||
}
|
||||
|
||||
var step = steps.shift();
|
||||
step();
|
||||
}
|
||||
|
||||
next();
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,6 @@
|
||||
[DEFAULT]
|
||||
support-files =
|
||||
file_abort_controller.html
|
||||
worker_fetch_controller.js
|
||||
|
||||
[test_abort_controller.html]
|
||||
@@ -0,0 +1,8 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
MOCHITEST_MANIFESTS += ['mochitest.ini']
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test FetchController</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.fetchController.enabled", true ]]}, () => {
|
||||
let ifr = document.createElement('iframe');
|
||||
ifr.src = "file_fetch_controller.html";
|
||||
document.body.appendChild(ifr);
|
||||
|
||||
onmessage = function(e) {
|
||||
if (e.data.type == "finish") {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.data.type == "check") {
|
||||
ok(e.data.status, e.data.message);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(false, "Something when wrong.");
|
||||
}
|
||||
});
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
function testWorkerAbortedFetch() {
|
||||
var fc = new AbortController();
|
||||
fc.abort();
|
||||
|
||||
fetch('slow.sjs', { signal: fc.signal }).then(() => {
|
||||
postMessage(false);
|
||||
}, e => {
|
||||
postMessage(e.name == "AbortError");
|
||||
});
|
||||
}
|
||||
|
||||
function testWorkerFetchAndAbort() {
|
||||
var fc = new AbortController();
|
||||
|
||||
var p = fetch('slow.sjs', { signal: fc.signal });
|
||||
fc.abort();
|
||||
|
||||
p.then(() => {
|
||||
postMessage(false);
|
||||
}, e => {
|
||||
postMessage(e.name == "AbortError");
|
||||
});
|
||||
}
|
||||
|
||||
onmessage = function(e) {
|
||||
self[e.data]();
|
||||
}
|
||||
@@ -166,8 +166,11 @@ NS_INTERFACE_MAP_END
|
||||
/* static */ bool
|
||||
CustomElementRegistry::IsCustomElementEnabled(JSContext* aCx, JSObject* aObject)
|
||||
{
|
||||
return false;
|
||||
/*
|
||||
return Preferences::GetBool("dom.webcomponents.customelements.enabled") ||
|
||||
Preferences::GetBool("dom.webcomponents.enabled");
|
||||
*/
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<CustomElementRegistry>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define mozilla_dom_ElementInlines_h
|
||||
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "ImportManager.h"
|
||||
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "HTMLLinkElement.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
@@ -18,7 +19,6 @@
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -156,7 +156,7 @@ ImportLoader::Updater::UpdateMainReferrer(uint32_t aNewIdx)
|
||||
// Our nearest predecessor has changed. So let's add the ScriptLoader to the
|
||||
// new one if there is any. And remove it from the old one.
|
||||
RefPtr<ImportManager> manager = mLoader->Manager();
|
||||
nsScriptLoader* loader = mLoader->mDocument->ScriptLoader();
|
||||
ScriptLoader* loader = mLoader->mDocument->ScriptLoader();
|
||||
ImportLoader*& pred = mLoader->mBlockingPredecessor;
|
||||
ImportLoader* newPred = manager->GetNearestPredecessor(newMainReferrer);
|
||||
if (pred) {
|
||||
@@ -339,7 +339,7 @@ ImportLoader::DispatchEventIfFinished(nsINode* aNode)
|
||||
}
|
||||
|
||||
void
|
||||
ImportLoader::AddBlockedScriptLoader(nsScriptLoader* aScriptLoader)
|
||||
ImportLoader::AddBlockedScriptLoader(ScriptLoader* aScriptLoader)
|
||||
{
|
||||
if (mBlockedScriptLoaders.Contains(aScriptLoader)) {
|
||||
return;
|
||||
@@ -352,7 +352,7 @@ ImportLoader::AddBlockedScriptLoader(nsScriptLoader* aScriptLoader)
|
||||
}
|
||||
|
||||
bool
|
||||
ImportLoader::RemoveBlockedScriptLoader(nsScriptLoader* aScriptLoader)
|
||||
ImportLoader::RemoveBlockedScriptLoader(ScriptLoader* aScriptLoader)
|
||||
{
|
||||
aScriptLoader->RemoveParserBlockingScriptExecutionBlocker();
|
||||
return mBlockedScriptLoaders.RemoveElement(aScriptLoader);
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsURIHashKey.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIPrincipal;
|
||||
@@ -184,8 +184,8 @@ public:
|
||||
// and wait for that to run its scripts. We keep track of all the
|
||||
// ScriptRunners that are waiting for this import. NOTE: updating
|
||||
// the main referrer might change this list.
|
||||
void AddBlockedScriptLoader(nsScriptLoader* aScriptLoader);
|
||||
bool RemoveBlockedScriptLoader(nsScriptLoader* aScriptLoader);
|
||||
void AddBlockedScriptLoader(ScriptLoader* aScriptLoader);
|
||||
bool RemoveBlockedScriptLoader(ScriptLoader* aScriptLoader);
|
||||
void SetBlockingPredecessor(ImportLoader* aLoader);
|
||||
|
||||
private:
|
||||
@@ -230,7 +230,7 @@ private:
|
||||
|
||||
// List of pending ScriptLoaders that are waiting for this import
|
||||
// to finish.
|
||||
nsTArray<RefPtr<nsScriptLoader>> mBlockedScriptLoaders;
|
||||
nsTArray<RefPtr<ScriptLoader>> mBlockedScriptLoaders;
|
||||
|
||||
// There is always exactly one referrer link that is flagged as
|
||||
// the main referrer the primary link. This is the one that is
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
#include "mozilla/Likely.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
#include "ScriptSettings.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/LocationBinding.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "BatteryManager.h"
|
||||
#ifdef MOZ_GAMEPAD
|
||||
#include "mozilla/dom/GamepadServiceTest.h"
|
||||
#endif
|
||||
@@ -197,8 +196,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPermissions)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGeolocation)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNotification)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryPromise)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPowerManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConnection)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStorageManager)
|
||||
@@ -249,13 +246,6 @@ Navigator::Invalidate()
|
||||
mNotification = nullptr;
|
||||
}
|
||||
|
||||
if (mBatteryManager) {
|
||||
mBatteryManager->Shutdown();
|
||||
mBatteryManager = nullptr;
|
||||
}
|
||||
|
||||
mBatteryPromise = nullptr;
|
||||
|
||||
if (mPowerManager) {
|
||||
mPowerManager->Shutdown();
|
||||
mPowerManager = nullptr;
|
||||
@@ -1321,39 +1311,6 @@ Navigator::GetMozNotification(ErrorResult& aRv)
|
||||
return mNotification;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// Navigator::nsINavigatorBattery
|
||||
//*****************************************************************************
|
||||
|
||||
Promise*
|
||||
Navigator::GetBattery(ErrorResult& aRv)
|
||||
{
|
||||
if (mBatteryPromise) {
|
||||
return mBatteryPromise;
|
||||
}
|
||||
|
||||
if (!mWindow || !mWindow->GetDocShell()) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
|
||||
RefPtr<Promise> batteryPromise = Promise::Create(go, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
mBatteryPromise = batteryPromise;
|
||||
|
||||
if (!mBatteryManager) {
|
||||
mBatteryManager = new battery::BatteryManager(mWindow);
|
||||
mBatteryManager->Init();
|
||||
}
|
||||
|
||||
mBatteryPromise->MaybeResolve(mBatteryManager);
|
||||
|
||||
return mBatteryPromise;
|
||||
}
|
||||
|
||||
PowerManager*
|
||||
Navigator::GetMozPower(ErrorResult& aRv)
|
||||
{
|
||||
|
||||
@@ -51,10 +51,6 @@ namespace dom {
|
||||
|
||||
class Permissions;
|
||||
|
||||
namespace battery {
|
||||
class BatteryManager;
|
||||
} // namespace battery
|
||||
|
||||
class Promise;
|
||||
|
||||
class DesktopNotificationCenter;
|
||||
@@ -136,7 +132,6 @@ public:
|
||||
Permissions* GetPermissions(ErrorResult& aRv);
|
||||
// The XPCOM GetDoNotTrack is ok
|
||||
Geolocation* GetGeolocation(ErrorResult& aRv);
|
||||
Promise* GetBattery(ErrorResult& aRv);
|
||||
|
||||
static void AppName(nsAString& aAppName, bool aUsePrefOverriddenValue);
|
||||
|
||||
@@ -269,8 +264,6 @@ private:
|
||||
RefPtr<Permissions> mPermissions;
|
||||
RefPtr<Geolocation> mGeolocation;
|
||||
RefPtr<DesktopNotificationCenter> mNotification;
|
||||
RefPtr<battery::BatteryManager> mBatteryManager;
|
||||
RefPtr<Promise> mBatteryPromise;
|
||||
RefPtr<PowerManager> mPowerManager;
|
||||
RefPtr<network::Connection> mConnection;
|
||||
#ifdef MOZ_AUDIO_CHANNEL_MANAGER
|
||||
|
||||
@@ -26,7 +26,6 @@ XPIDL_SOURCES += [
|
||||
'nsIObjectLoadingContent.idl',
|
||||
'nsIRemoteWindowContext.idl',
|
||||
'nsIScriptChannel.idl',
|
||||
'nsIScriptLoaderObserver.idl',
|
||||
'nsISelection.idl',
|
||||
'nsISelectionController.idl',
|
||||
'nsISelectionDisplay.idl',
|
||||
@@ -96,7 +95,6 @@ EXPORTS += [
|
||||
'nsINode.h',
|
||||
'nsINodeList.h',
|
||||
'nsIScriptContext.h',
|
||||
'nsIScriptElement.h',
|
||||
'nsIScriptGlobalObject.h',
|
||||
'nsIScriptNameSpaceManager.h',
|
||||
'nsIScriptObjectPrincipal.h',
|
||||
@@ -117,7 +115,6 @@ EXPORTS += [
|
||||
'nsRange.h',
|
||||
'nsReferencedElement.h',
|
||||
'nsSandboxFlags.h',
|
||||
'nsScriptLoader.h',
|
||||
'nsStructuredCloneContainer.h',
|
||||
'nsStubAnimationObserver.h',
|
||||
'nsStubDocumentObserver.h',
|
||||
@@ -208,7 +205,6 @@ EXPORTS.mozilla.dom += [
|
||||
'ResponsiveImageSelector.h',
|
||||
'SameProcessMessageQueue.h',
|
||||
'ScreenOrientation.h',
|
||||
'ScriptSettings.h',
|
||||
'ShadowRoot.h',
|
||||
'SimpleTreeIterator.h',
|
||||
'StructuredCloneHolder.h',
|
||||
@@ -328,8 +324,6 @@ SOURCES += [
|
||||
'nsRange.cpp',
|
||||
'nsReferencedElement.cpp',
|
||||
'nsScreen.cpp',
|
||||
'nsScriptElement.cpp',
|
||||
'nsScriptLoader.cpp',
|
||||
'nsScriptNameSpaceManager.cpp',
|
||||
'nsStructuredCloneContainer.cpp',
|
||||
'nsStubAnimationObserver.cpp',
|
||||
@@ -356,7 +350,6 @@ SOURCES += [
|
||||
'ResponsiveImageSelector.cpp',
|
||||
'SameProcessMessageQueue.cpp',
|
||||
'ScreenOrientation.cpp',
|
||||
'ScriptSettings.cpp',
|
||||
'ShadowRoot.cpp',
|
||||
'StructuredCloneHolder.cpp',
|
||||
'StyleSheetList.cpp',
|
||||
@@ -423,7 +416,6 @@ EXTRA_JS_MODULES += [
|
||||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'../battery',
|
||||
'../events',
|
||||
'../media',
|
||||
'../network',
|
||||
|
||||
@@ -29,9 +29,8 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "ScriptSettings.h"
|
||||
|
||||
using mozilla::Unused; // <snicker>
|
||||
using mozilla::Unused;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla;
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
*/
|
||||
|
||||
#include "nsContentSink.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
@@ -49,6 +48,7 @@
|
||||
#include "nsHTMLDNSPrefetch.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "nsParserConstants.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
|
||||
@@ -789,13 +789,14 @@ nsContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
// If this is a fragment parser, we don't want to observe.
|
||||
// We don't support CORS for processing instructions
|
||||
bool isAlternate;
|
||||
bool isExplicitlyEnabled;
|
||||
rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, aAlternate,
|
||||
CORS_NONE, mDocument->GetReferrerPolicy(),
|
||||
integrity, mRunsToCompletion ? nullptr : this,
|
||||
&isAlternate);
|
||||
&isAlternate, &isExplicitlyEnabled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!isAlternate && !mRunsToCompletion) {
|
||||
if ((!isAlternate || isExplicitlyEnabled) && !mRunsToCompletion) {
|
||||
++mPendingSheetCount;
|
||||
mScriptLoader->AddParserBlockingScriptExecutionBlocker();
|
||||
}
|
||||
|
||||
@@ -36,13 +36,16 @@ class nsIAtom;
|
||||
class nsIChannel;
|
||||
class nsIContent;
|
||||
class nsNodeInfoManager;
|
||||
class nsScriptLoader;
|
||||
class nsIApplicationCache;
|
||||
|
||||
namespace mozilla {
|
||||
namespace css {
|
||||
class Loader;
|
||||
} // namespace css
|
||||
|
||||
namespace dom {
|
||||
class ScriptLoader;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -273,7 +276,7 @@ protected:
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
RefPtr<mozilla::css::Loader> mCSSLoader;
|
||||
RefPtr<nsNodeInfoManager> mNodeInfoManager;
|
||||
RefPtr<nsScriptLoader> mScriptLoader;
|
||||
RefPtr<mozilla::dom::ScriptLoader> mScriptLoader;
|
||||
|
||||
// back off timer notification after count
|
||||
int32_t mBackoffCount;
|
||||
|
||||
@@ -5105,6 +5105,14 @@ nsContentUtils::TriggerLink(nsIContent *aContent, nsPresContext *aPresContext,
|
||||
fileName.SetIsVoid(true); // No actionable download attribute was found.
|
||||
}
|
||||
|
||||
// Sanitize fileNames containing control characters by replacing them with
|
||||
// underscores.
|
||||
if (!fileName.IsVoid()) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
fileName.ReplaceChar(char16_t(i), '_');
|
||||
}
|
||||
}
|
||||
|
||||
handler->OnLinkClick(aContent, aLinkURI,
|
||||
fileName.IsVoid() ? aTargetSpec.get() : EmptyString().get(),
|
||||
fileName, nullptr, nullptr, aIsTrusted, aContent->NodePrincipal());
|
||||
|
||||
@@ -3577,7 +3577,8 @@ nsDOMWindowUtils::IsNodeDisabledForEvents(nsIDOMNode* aNode, bool* aRetVal)
|
||||
while (node) {
|
||||
if (node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
|
||||
nsCOMPtr<nsIFormControl> fc = do_QueryInterface(node);
|
||||
if (fc && fc->IsDisabledForEvents(eVoidEvent)) {
|
||||
WidgetEvent event(true, eVoidEvent);
|
||||
if (fc && fc->IsDisabledForEvents(&event)) {
|
||||
*aRetVal = true;
|
||||
break;
|
||||
}
|
||||
|
||||
+23
-9
@@ -1880,7 +1880,7 @@ nsDocument::Init()
|
||||
mScopeObject = do_GetWeakReference(global);
|
||||
MOZ_ASSERT(mScopeObject);
|
||||
|
||||
mScriptLoader = new nsScriptLoader(this);
|
||||
mScriptLoader = new dom::ScriptLoader(this);
|
||||
|
||||
mozilla::HoldJSObjects(this);
|
||||
|
||||
@@ -4685,7 +4685,7 @@ nsDocument::GetWindowInternal() const
|
||||
return win;
|
||||
}
|
||||
|
||||
nsScriptLoader*
|
||||
ScriptLoader*
|
||||
nsDocument::ScriptLoader()
|
||||
{
|
||||
return mScriptLoader;
|
||||
@@ -5709,9 +5709,9 @@ nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx, aObject);
|
||||
|
||||
if (Preferences::GetBool("dom.webcomponents.enabled")) {
|
||||
return true;
|
||||
}
|
||||
//if (Preferences::GetBool("dom.webcomponents.enabled")) {
|
||||
// return true;
|
||||
//}
|
||||
|
||||
// Check for the webcomponents permission. See Bug 1181555.
|
||||
JSAutoCompartment ac(aCx, obj);
|
||||
@@ -5725,9 +5725,9 @@ nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
|
||||
bool
|
||||
nsDocument::IsWebComponentsEnabled(dom::NodeInfo* aNodeInfo)
|
||||
{
|
||||
if (Preferences::GetBool("dom.webcomponents.enabled")) {
|
||||
return true;
|
||||
}
|
||||
//if (Preferences::GetBool("dom.webcomponents.enabled")) {
|
||||
// return true;
|
||||
//}
|
||||
|
||||
nsIDocument* doc = aNodeInfo->GetDocument();
|
||||
// Use GetScopeObject() here so that data documents work the same way as the
|
||||
@@ -5740,6 +5740,7 @@ nsDocument::IsWebComponentsEnabled(dom::NodeInfo* aNodeInfo)
|
||||
bool
|
||||
nsDocument::IsWebComponentsEnabled(nsPIDOMWindowInner* aWindow)
|
||||
{
|
||||
/*
|
||||
if (aWindow) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPermissionManager> permMgr =
|
||||
@@ -5753,7 +5754,7 @@ nsDocument::IsWebComponentsEnabled(nsPIDOMWindowInner* aWindow)
|
||||
|
||||
return perm == nsIPermissionManager::ALLOW_ACTION;
|
||||
}
|
||||
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12744,3 +12745,16 @@ nsIDocument::GetSelection(ErrorResult& aRv)
|
||||
|
||||
return nsGlobalWindow::Cast(window)->GetSelection(aRv);
|
||||
}
|
||||
|
||||
bool
|
||||
nsIDocument::ModuleScriptsEnabled()
|
||||
{
|
||||
static bool sEnabledForContent = false;
|
||||
static bool sCachedPref = false;
|
||||
if (!sCachedPref) {
|
||||
sCachedPref = true;
|
||||
Preferences::AddBoolVarCache(&sEnabledForContent, "dom.moduleScripts.enabled", false);
|
||||
}
|
||||
|
||||
return nsContentUtils::IsChromeDoc(this) || sEnabledForContent;
|
||||
}
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "nsJSThingHashtable.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsIRadioGroupContainer.h"
|
||||
#include "nsILayoutHistoryState.h"
|
||||
#include "nsIRequest.h"
|
||||
@@ -60,6 +59,7 @@
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/PendingAnimationTracker.h"
|
||||
#include "mozilla/dom/DOMImplementation.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/dom/StyleSheetList.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
@@ -674,7 +674,7 @@ public:
|
||||
/**
|
||||
* Get the script loader for this document
|
||||
*/
|
||||
virtual nsScriptLoader* ScriptLoader() override;
|
||||
virtual mozilla::dom::ScriptLoader* ScriptLoader() override;
|
||||
|
||||
/**
|
||||
* Add/Remove an element to the document's id and name hashes
|
||||
@@ -1417,7 +1417,7 @@ public:
|
||||
RefPtr<mozilla::EventListenerManager> mListenerManager;
|
||||
RefPtr<mozilla::dom::StyleSheetList> mDOMStyleSheets;
|
||||
RefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
|
||||
RefPtr<nsScriptLoader> mScriptLoader;
|
||||
RefPtr<mozilla::dom::ScriptLoader> mScriptLoader;
|
||||
nsDocHeaderData* mHeaderData;
|
||||
/* mIdentifierMap works as follows for IDs:
|
||||
* 1) Attribute changes affect the table immediately (removing and adding
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsFrameLoader.h"
|
||||
#include "nsIXULRuntime.h"
|
||||
#include "nsIScriptError.h"
|
||||
@@ -38,6 +37,7 @@
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
#include "mozilla/dom/ProcessGlobal.h"
|
||||
#include "mozilla/dom/SameProcessMessageQueue.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/ipc/BlobChild.h"
|
||||
#include "mozilla/dom/ipc/BlobParent.h"
|
||||
@@ -1786,9 +1786,9 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
|
||||
if (NS_FAILED(NS_ReadInputStreamToString(input, buffer, avail))) {
|
||||
return;
|
||||
}
|
||||
nsScriptLoader::ConvertToUTF16(channel, (uint8_t*)buffer.get(), avail,
|
||||
EmptyString(), nullptr,
|
||||
dataStringBuf, dataStringLength);
|
||||
ScriptLoader::ConvertToUTF16(channel, (uint8_t*)buffer.get(), avail,
|
||||
EmptyString(), nullptr,
|
||||
dataStringBuf, dataStringLength);
|
||||
}
|
||||
|
||||
JS::SourceBufferHolder srcBuf(dataStringBuf, dataStringLength,
|
||||
|
||||
@@ -910,7 +910,9 @@ GK_ATOM(onreadystatechange, "onreadystatechange")
|
||||
GK_ATOM(onreceived, "onreceived")
|
||||
GK_ATOM(onremoteheld, "onremoteheld")
|
||||
GK_ATOM(onremoteresumed, "onremoteresumed")
|
||||
GK_ATOM(onrequestprogress, "onrequestprogress")
|
||||
GK_ATOM(onresourcetimingbufferfull, "onresourcetimingbufferfull")
|
||||
GK_ATOM(onresponseprogress, "onresponseprogress")
|
||||
GK_ATOM(onretrieving, "onretrieving")
|
||||
GK_ATOM(onRequest, "onRequest")
|
||||
GK_ATOM(onrequestmediaplaystatus, "onrequestmediaplaystatus")
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "ScriptSettings.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
|
||||
@@ -91,7 +91,6 @@ class nsIVariant;
|
||||
class nsViewManager;
|
||||
class nsPresContext;
|
||||
class nsRange;
|
||||
class nsScriptLoader;
|
||||
class nsSMILAnimationController;
|
||||
class nsTextNode;
|
||||
class nsWindowSizes;
|
||||
@@ -152,6 +151,7 @@ enum class OrientationType : uint32_t;
|
||||
class ProcessingInstruction;
|
||||
class Promise;
|
||||
class Selection;
|
||||
class ScriptLoader;
|
||||
class StyleSheetList;
|
||||
class SVGDocument;
|
||||
class SVGSVGElement;
|
||||
@@ -1290,7 +1290,7 @@ public:
|
||||
/**
|
||||
* Get the script loader for this document
|
||||
*/
|
||||
virtual nsScriptLoader* ScriptLoader() = 0;
|
||||
virtual mozilla::dom::ScriptLoader* ScriptLoader() = 0;
|
||||
|
||||
/**
|
||||
* Add/Remove an element to the document's id and name hashes
|
||||
@@ -2872,6 +2872,8 @@ public:
|
||||
virtual void ScheduleIntersectionObserverNotification() = 0;
|
||||
virtual void NotifyIntersectionObservers() = 0;
|
||||
|
||||
bool ModuleScriptsEnabled();
|
||||
|
||||
protected:
|
||||
bool GetUseCounter(mozilla::UseCounter aUseCounter)
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ interface nsIImageLoadingContent : imgINotificationObserver
|
||||
* the image was blocked. This status always refers to the
|
||||
* CURRENT_REQUEST load.
|
||||
*/
|
||||
readonly attribute short imageBlockingStatus;
|
||||
[infallible] readonly attribute short imageBlockingStatus;
|
||||
|
||||
/**
|
||||
* Used to register an image decoder observer. Typically, this will
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
#include "GeometryUtils.h"
|
||||
#include "nsIAnimationObserver.h"
|
||||
#include "nsChildContentList.h"
|
||||
#include "mozilla/dom/NodeBinding.h"
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
#include "mozilla/dom/AccessibleNode.h"
|
||||
@@ -250,6 +251,30 @@ nsINode::GetTextEditorRootContent(nsIEditor** aEditor)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsINode* nsINode::GetRootNode(const GetRootNodeOptions& aOptions)
|
||||
{
|
||||
if (aOptions.mComposed) {
|
||||
if (IsInComposedDoc() && GetComposedDoc()) {
|
||||
return OwnerDoc();
|
||||
}
|
||||
|
||||
nsINode* node = this;
|
||||
ShadowRoot* shadowRootParent = nullptr;
|
||||
while(node) {
|
||||
node = node->SubtreeRoot();
|
||||
shadowRootParent = ShadowRoot::FromNode(node);
|
||||
if (!shadowRootParent) {
|
||||
break;
|
||||
}
|
||||
node = shadowRootParent->GetHost();
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
return SubtreeRoot();
|
||||
}
|
||||
|
||||
nsINode*
|
||||
nsINode::SubtreeRoot() const
|
||||
{
|
||||
|
||||
+6
-4
@@ -83,6 +83,7 @@ template<typename> class Sequence;
|
||||
class Text;
|
||||
class TextOrElementOrDocument;
|
||||
struct DOMPointInit;
|
||||
struct GetRootNodeOptions;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
@@ -942,10 +943,11 @@ public:
|
||||
*/
|
||||
nsINode* SubtreeRoot() const;
|
||||
|
||||
nsINode* RootNode() const
|
||||
{
|
||||
return SubtreeRoot();
|
||||
}
|
||||
/*
|
||||
* Get context object's shadow-including root if options's composed is true,
|
||||
* and context object's root otherwise.
|
||||
*/
|
||||
nsINode* GetRootNode(const mozilla::dom::GetRootNodeOptions& aOptions);
|
||||
|
||||
/**
|
||||
* See nsIDOMEventTarget
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsFrameLoader.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsIMozBrowserFrame.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/dom/SameProcessMessageQueue.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "nsXPCOMCIDInternal.h"
|
||||
#include "nsIXULRuntime.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "ScriptSettings.h"
|
||||
|
||||
#include "xpcpublic.h"
|
||||
|
||||
@@ -55,6 +54,7 @@
|
||||
#include "mozilla/dom/DOMException.h"
|
||||
#include "mozilla/dom/DOMExceptionBinding.h"
|
||||
#include "mozilla/dom/ErrorEvent.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "nsAXPCNativeCallContext.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
||||
@@ -306,17 +306,19 @@ nsJSUtils::CompileModule(JSContext* aCx,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJSUtils::ModuleDeclarationInstantiation(JSContext* aCx, JS::Handle<JSObject*> aModule)
|
||||
nsJSUtils::ModuleInstantiate(JSContext* aCx, JS::Handle<JSObject*> aModule)
|
||||
{
|
||||
PROFILER_LABEL("nsJSUtils", "ModuleDeclarationInstantiation",
|
||||
PROFILER_LABEL("nsJSUtils", "ModuleInstantiate",
|
||||
js::ProfileEntry::Category::JS);
|
||||
|
||||
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(CycleCollectedJSContext::Get() &&
|
||||
CycleCollectedJSContext::Get()->MicroTaskLevel());
|
||||
|
||||
NS_ENSURE_TRUE(xpc::Scriptability::Get(aModule).Allowed(), NS_OK);
|
||||
|
||||
if (!JS::ModuleDeclarationInstantiation(aCx, aModule)) {
|
||||
if (!JS::ModuleInstantiate(aCx, aModule)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@@ -324,9 +326,9 @@ nsJSUtils::ModuleDeclarationInstantiation(JSContext* aCx, JS::Handle<JSObject*>
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJSUtils::ModuleEvaluation(JSContext* aCx, JS::Handle<JSObject*> aModule)
|
||||
nsJSUtils::ModuleEvaluate(JSContext* aCx, JS::Handle<JSObject*> aModule)
|
||||
{
|
||||
PROFILER_LABEL("nsJSUtils", "ModuleEvaluation",
|
||||
PROFILER_LABEL("nsJSUtils", "ModuleEvaluate",
|
||||
js::ProfileEntry::Category::JS);
|
||||
|
||||
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
|
||||
@@ -335,7 +337,7 @@ nsJSUtils::ModuleEvaluation(JSContext* aCx, JS::Handle<JSObject*> aModule)
|
||||
|
||||
NS_ENSURE_TRUE(xpc::Scriptability::Get(aModule).Allowed(), NS_OK);
|
||||
|
||||
if (!JS::ModuleEvaluation(aCx, aModule)) {
|
||||
if (!JS::ModuleEvaluate(aCx, aModule)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,11 +116,11 @@ public:
|
||||
JS::CompileOptions &aCompileOptions,
|
||||
JS::MutableHandle<JSObject*> aModule);
|
||||
|
||||
static nsresult ModuleDeclarationInstantiation(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aModule);
|
||||
static nsresult ModuleInstantiate(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aModule);
|
||||
|
||||
static nsresult ModuleEvaluation(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aModule);
|
||||
static nsresult ModuleEvaluate(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aModule);
|
||||
|
||||
// Returns false if an exception got thrown on aCx. Passing a null
|
||||
// aElement is allowed; that wil produce an empty aScopeChain.
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIContentSerializer.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsILineBreaker.h"
|
||||
|
||||
@@ -393,8 +393,9 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
|
||||
nsAutoString title, type, media;
|
||||
bool isScoped;
|
||||
bool isAlternate;
|
||||
bool isExplicitlyEnabled;
|
||||
|
||||
GetStyleSheetInfo(title, type, media, &isScoped, &isAlternate);
|
||||
GetStyleSheetInfo(title, type, media, &isScoped, &isAlternate, &isExplicitlyEnabled);
|
||||
|
||||
if (!type.LowerCaseEqualsLiteral("text/css")) {
|
||||
return NS_OK;
|
||||
@@ -425,7 +426,7 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
|
||||
// Parse the style sheet.
|
||||
rv = doc->CSSLoader()->
|
||||
LoadInlineStyle(thisContent, text, mLineNumber, title, media,
|
||||
scopeElement, aObserver, &doneLoading, &isAlternate);
|
||||
scopeElement, aObserver, &doneLoading, &isAlternate, &isExplicitlyEnabled);
|
||||
}
|
||||
else {
|
||||
nsAutoString integrity;
|
||||
@@ -452,13 +453,14 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
|
||||
rv = doc->CSSLoader()->
|
||||
LoadStyleLink(thisContent, clonedURI, title, media, isAlternate,
|
||||
GetCORSMode(), referrerPolicy, integrity,
|
||||
aObserver, &isAlternate);
|
||||
aObserver, &isAlternate, &isExplicitlyEnabled);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Don't propagate LoadStyleLink() errors further than this, since some
|
||||
// consumers (e.g. nsXMLContentSink) will completely abort on innocuous
|
||||
// things like a stylesheet load being blocked by the security system.
|
||||
doneLoading = true;
|
||||
isAlternate = false;
|
||||
isExplicitlyEnabled = false;
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,8 @@ protected:
|
||||
nsAString& aType,
|
||||
nsAString& aMedia,
|
||||
bool* aIsScoped,
|
||||
bool* aIsAlternate) = 0;
|
||||
bool* aIsAlternate,
|
||||
bool* aIsExplicitlyEnabled) = 0;
|
||||
|
||||
virtual mozilla::CORSMode GetCORSMode() const
|
||||
{
|
||||
|
||||
@@ -4,20 +4,27 @@
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script>
|
||||
var wasRun = false;
|
||||
var hadSyntaxError = false;
|
||||
var errorCount = 0;
|
||||
var syntaxErrorCount = 0;
|
||||
var eventCount = 0;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
window.onerror = handleError;
|
||||
|
||||
function handleError(message, url, line, column, error) {
|
||||
hadSyntaxError = error instanceof SyntaxError;
|
||||
errorCount++;
|
||||
if (error instanceof SyntaxError) {
|
||||
syntaxErrorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
function testError() {
|
||||
ok(!wasRun, 'Check script was not run');
|
||||
ok(hadSyntaxError, 'Check that a SyntaxError was thrown');
|
||||
ok(errorCount == 1, 'Check that an error was reported');
|
||||
ok(syntaxErrorCount == 1, 'Check that a syntax error was reported');
|
||||
ok(eventCount == 0, 'Check that no error event was fired');
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
<script type="module" src="module_badSyntax.js"></script>
|
||||
<script type="module" src="module_badSyntax.js" onerror="eventCount++"></script>
|
||||
<body onload='testError()'></body>
|
||||
@@ -4,20 +4,27 @@
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script>
|
||||
var wasRun = false;
|
||||
var hadSyntaxError = false;
|
||||
var errorCount = 0;
|
||||
var syntaxErrorCount = 0;
|
||||
var eventCount = 0;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
window.onerror = handleError;
|
||||
|
||||
function handleError(message, url, line, column, error) {
|
||||
hadSyntaxError = error instanceof SyntaxError;
|
||||
errorCount++;
|
||||
if (error instanceof SyntaxError) {
|
||||
syntaxErrorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
function testError() {
|
||||
ok(!wasRun, 'Check script was not run');
|
||||
ok(hadSyntaxError, 'Check that a SyntaxError was thrown');
|
||||
ok(errorCount == 1, 'Check that an error was reported');
|
||||
ok(syntaxErrorCount == 1, 'Check that a syntax error was reported');
|
||||
ok(eventCount == 0, 'Check that no error event was fired');
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
<script type="module" src="module_badSyntax.js" async></script>
|
||||
<script type="module" src="module_badSyntax.js" async onerror="eventCount++"></script>
|
||||
<body onload='testError()'></body>
|
||||
@@ -4,22 +4,29 @@
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script>
|
||||
var wasRun = false;
|
||||
var hadSyntaxError = false;
|
||||
var errorCount = 0;
|
||||
var syntaxErrorCount = 0;
|
||||
var eventCount = 0;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
window.onerror = handleError;
|
||||
|
||||
function handleError(message, url, line, column, error) {
|
||||
hadSyntaxError = error instanceof SyntaxError;
|
||||
errorCount++;
|
||||
if (error instanceof SyntaxError) {
|
||||
syntaxErrorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
function testError() {
|
||||
ok(!wasRun, 'Check script was not run');
|
||||
ok(hadSyntaxError, 'Check that a SyntaxError was thrown');
|
||||
ok(errorCount == 1, 'Check that an error was reported');
|
||||
ok(syntaxErrorCount == 1, 'Check that a syntax error was reported');
|
||||
ok(eventCount == 0, 'Check that no error event was fired');
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
<script type="module">
|
||||
<script type="module" onerror="eventCount++">
|
||||
// Module with a syntax error.
|
||||
some invalid js syntax;
|
||||
wasRun = true;
|
||||
|
||||
@@ -4,22 +4,29 @@
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script>
|
||||
var wasRun = false;
|
||||
var hadSyntaxError = false;
|
||||
var errorCount = 0;
|
||||
var syntaxErrorCount = 0;
|
||||
var eventCount = 0;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
window.onerror = handleError;
|
||||
|
||||
function handleError(message, url, line, column, error) {
|
||||
hadSyntaxError = error instanceof SyntaxError;
|
||||
errorCount++;
|
||||
if (error instanceof SyntaxError) {
|
||||
syntaxErrorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
function testError() {
|
||||
ok(!wasRun, 'Check script was not run');
|
||||
ok(hadSyntaxError, 'Check that a SyntaxError was thrown');
|
||||
ok(errorCount == 1, 'Check that an error was reported');
|
||||
ok(syntaxErrorCount == 1, 'Check that a syntax error was reported');
|
||||
ok(eventCount == 0, 'Check that no error event was fired');
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
<script type="module" async>
|
||||
<script type="module" async onerror="eventCount++">
|
||||
// Module with a syntax error.
|
||||
some invalid js syntax;
|
||||
wasRun = true;
|
||||
|
||||
@@ -1,212 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include "BatteryManager.h"
|
||||
#include "Constants.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/Hal.h"
|
||||
#include "mozilla/dom/BatteryManagerBinding.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
/**
|
||||
* We have to use macros here because our leak analysis tool things we are
|
||||
* leaking strings when we have |static const nsString|. Sad :(
|
||||
*/
|
||||
#define LEVELCHANGE_EVENT_NAME NS_LITERAL_STRING("levelchange")
|
||||
#define CHARGINGCHANGE_EVENT_NAME NS_LITERAL_STRING("chargingchange")
|
||||
#define DISCHARGINGTIMECHANGE_EVENT_NAME NS_LITERAL_STRING("dischargingtimechange")
|
||||
#define CHARGINGTIMECHANGE_EVENT_NAME NS_LITERAL_STRING("chargingtimechange")
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace battery {
|
||||
|
||||
BatteryManager::BatteryManager(nsPIDOMWindowInner* aWindow)
|
||||
: DOMEventTargetHelper(aWindow)
|
||||
, mLevel(kDefaultLevel)
|
||||
, mCharging(kDefaultCharging)
|
||||
, mRemainingTime(kDefaultRemainingTime)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BatteryManager::Init()
|
||||
{
|
||||
hal::RegisterBatteryObserver(this);
|
||||
|
||||
hal::BatteryInformation batteryInfo;
|
||||
hal::GetCurrentBatteryInformation(&batteryInfo);
|
||||
|
||||
UpdateFromBatteryInfo(batteryInfo);
|
||||
}
|
||||
|
||||
void
|
||||
BatteryManager::Shutdown()
|
||||
{
|
||||
hal::UnregisterBatteryObserver(this);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
BatteryManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return BatteryManagerBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
bool
|
||||
BatteryManager::Charging() const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
// For testing, unable to report the battery status information
|
||||
if (Preferences::GetBool("dom.battery.test.default", false)) {
|
||||
return true;
|
||||
}
|
||||
if (Preferences::GetBool("dom.battery.test.charging", false)) {
|
||||
return true;
|
||||
}
|
||||
if (Preferences::GetBool("dom.battery.test.discharging", false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mCharging;
|
||||
}
|
||||
|
||||
double
|
||||
BatteryManager::DischargingTime() const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
// For testing, unable to report the battery status information
|
||||
if (Preferences::GetBool("dom.battery.test.default", false)) {
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
if (Preferences::GetBool("dom.battery.test.discharging", false)) {
|
||||
return 42.0;
|
||||
}
|
||||
|
||||
if (Charging() || mRemainingTime == kUnknownRemainingTime) {
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
return mRemainingTime;
|
||||
}
|
||||
|
||||
double
|
||||
BatteryManager::ChargingTime() const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
// For testing, unable to report the battery status information
|
||||
if (Preferences::GetBool("dom.battery.test.default", false)) {
|
||||
return 0.0;
|
||||
}
|
||||
if (Preferences::GetBool("dom.battery.test.charging", false)) {
|
||||
return 42.0;
|
||||
}
|
||||
|
||||
if (!Charging() || mRemainingTime == kUnknownRemainingTime) {
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
return mRemainingTime;
|
||||
}
|
||||
|
||||
double
|
||||
BatteryManager::Level() const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
// For testing, unable to report the battery status information
|
||||
if (Preferences::GetBool("dom.battery.test.default")) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
return mLevel;
|
||||
}
|
||||
|
||||
void
|
||||
BatteryManager::UpdateFromBatteryInfo(const hal::BatteryInformation& aBatteryInfo)
|
||||
{
|
||||
mLevel = aBatteryInfo.level();
|
||||
|
||||
// Round to the nearest ten percent for non-chrome and non-certified apps
|
||||
nsIDocument* doc = GetOwner() ? GetOwner()->GetDoc() : nullptr;
|
||||
uint16_t status = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
|
||||
if (doc) {
|
||||
status = doc->NodePrincipal()->GetAppStatus();
|
||||
}
|
||||
|
||||
mCharging = aBatteryInfo.charging();
|
||||
mRemainingTime = aBatteryInfo.remainingTime();
|
||||
|
||||
if (!nsContentUtils::IsChromeDoc(doc) &&
|
||||
status != nsIPrincipal::APP_STATUS_CERTIFIED)
|
||||
{
|
||||
mLevel = lround(mLevel * 10.0) / 10.0;
|
||||
if (mLevel == 1.0) {
|
||||
mRemainingTime = mCharging ? kDefaultRemainingTime : kUnknownRemainingTime;
|
||||
} else if (mRemainingTime != kUnknownRemainingTime) {
|
||||
// Round the remaining time to a multiple of 15 minutes and never zero
|
||||
const double MINUTES_15 = 15.0 * 60.0;
|
||||
mRemainingTime = fmax(lround(mRemainingTime / MINUTES_15) * MINUTES_15,
|
||||
MINUTES_15);
|
||||
}
|
||||
}
|
||||
|
||||
// Add some guards to make sure the values are coherent.
|
||||
if (mLevel == 1.0 && mCharging == true &&
|
||||
mRemainingTime != kDefaultRemainingTime) {
|
||||
mRemainingTime = kDefaultRemainingTime;
|
||||
NS_ERROR("Battery API: When charging and level at 1.0, remaining time "
|
||||
"should be 0. Please fix your backend!");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BatteryManager::Notify(const hal::BatteryInformation& aBatteryInfo)
|
||||
{
|
||||
double previousLevel = mLevel;
|
||||
bool previousCharging = mCharging;
|
||||
double previousRemainingTime = mRemainingTime;
|
||||
|
||||
UpdateFromBatteryInfo(aBatteryInfo);
|
||||
|
||||
if (previousCharging != mCharging) {
|
||||
DispatchTrustedEvent(CHARGINGCHANGE_EVENT_NAME);
|
||||
}
|
||||
|
||||
if (previousLevel != mLevel) {
|
||||
DispatchTrustedEvent(LEVELCHANGE_EVENT_NAME);
|
||||
}
|
||||
|
||||
/*
|
||||
* There are a few situations that could happen here:
|
||||
* 1. Charging state changed:
|
||||
* a. Previous remaining time wasn't unkwonw, we have to fire an event for
|
||||
* the change.
|
||||
* b. New remaining time isn't unkwonw, we have to fire an event for it.
|
||||
* 2. Charging state didn't change but remainingTime did, we have to fire
|
||||
* the event that correspond to the current charging state.
|
||||
*/
|
||||
if (mCharging != previousCharging) {
|
||||
if (previousRemainingTime != kUnknownRemainingTime) {
|
||||
DispatchTrustedEvent(previousCharging ? CHARGINGTIMECHANGE_EVENT_NAME
|
||||
: DISCHARGINGTIMECHANGE_EVENT_NAME);
|
||||
}
|
||||
if (mRemainingTime != kUnknownRemainingTime) {
|
||||
DispatchTrustedEvent(mCharging ? CHARGINGTIMECHANGE_EVENT_NAME
|
||||
: DISCHARGINGTIMECHANGE_EVENT_NAME);
|
||||
}
|
||||
} else if (previousRemainingTime != mRemainingTime) {
|
||||
DispatchTrustedEvent(mCharging ? CHARGINGTIMECHANGE_EVENT_NAME
|
||||
: DISCHARGINGTIMECHANGE_EVENT_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace battery
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
@@ -1,84 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_battery_BatteryManager_h
|
||||
#define mozilla_dom_battery_BatteryManager_h
|
||||
|
||||
#include "Types.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/Observer.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace hal {
|
||||
class BatteryInformation;
|
||||
} // namespace hal
|
||||
|
||||
namespace dom {
|
||||
namespace battery {
|
||||
|
||||
class BatteryManager : public DOMEventTargetHelper
|
||||
, public BatteryObserver
|
||||
{
|
||||
public:
|
||||
explicit BatteryManager(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
// For IObserver.
|
||||
void Notify(const hal::BatteryInformation& aBatteryInfo) override;
|
||||
|
||||
/**
|
||||
* WebIDL Interface
|
||||
*/
|
||||
|
||||
nsPIDOMWindowInner* GetParentObject() const
|
||||
{
|
||||
return GetOwner();
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
bool Charging() const;
|
||||
|
||||
double ChargingTime() const;
|
||||
|
||||
double DischargingTime() const;
|
||||
|
||||
double Level() const;
|
||||
|
||||
IMPL_EVENT_HANDLER(chargingchange)
|
||||
IMPL_EVENT_HANDLER(chargingtimechange)
|
||||
IMPL_EVENT_HANDLER(dischargingtimechange)
|
||||
IMPL_EVENT_HANDLER(levelchange)
|
||||
|
||||
private:
|
||||
/**
|
||||
* Update the battery information stored in the battery manager object using
|
||||
* a battery information object.
|
||||
*/
|
||||
void UpdateFromBatteryInfo(const hal::BatteryInformation& aBatteryInfo);
|
||||
|
||||
/**
|
||||
* Represents the battery level, ranging from 0.0 (dead or removed?)
|
||||
* to 1.0 (fully charged)
|
||||
*/
|
||||
double mLevel;
|
||||
bool mCharging;
|
||||
/**
|
||||
* Represents the discharging time or the charging time, depending on the
|
||||
* current battery status (charging or not).
|
||||
*/
|
||||
double mRemainingTime;
|
||||
};
|
||||
|
||||
} // namespace battery
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_battery_BatteryManager_h
|
||||
@@ -1,27 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_battery_Constants_h__
|
||||
#define mozilla_dom_battery_Constants_h__
|
||||
|
||||
/**
|
||||
* A set of constants that might need to be used by battery backends.
|
||||
* It's not part of BatteryManager.h to prevent those backends to include it.
|
||||
*/
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace battery {
|
||||
|
||||
static const double kDefaultLevel = 1.0;
|
||||
static const bool kDefaultCharging = true;
|
||||
static const double kDefaultRemainingTime = 0;
|
||||
static const double kUnknownRemainingTime = -1;
|
||||
|
||||
} // namespace battery
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_battery_Constants_h__
|
||||
@@ -1,23 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_battery_Types_h
|
||||
#define mozilla_dom_battery_Types_h
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal {
|
||||
class BatteryInformation;
|
||||
} // namespace hal
|
||||
|
||||
template <class T>
|
||||
class Observer;
|
||||
|
||||
typedef Observer<hal::BatteryInformation> BatteryObserver;
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_battery_Types_h
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
[test_battery_basics.html]
|
||||
[test_battery_charging.html]
|
||||
[test_battery_discharging.html]
|
||||
@@ -1 +0,0 @@
|
||||
[test_battery_unprivileged.html]
|
||||
@@ -1,39 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for Battery API</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
/** Test for Battery API **/
|
||||
ok("getBattery" in navigator, "navigator.getBattery should exist");
|
||||
ok(!("battery" in navigator), "navigator.battery should not exist");
|
||||
|
||||
navigator.getBattery().then(function (battery) {
|
||||
ok(battery.level >= 0.0 && battery.level <= 1.0, "Battery level " + battery.level + " should be in the range [0.0, 1.0]");
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.battery.test.default", true]]}, function () {
|
||||
ok(battery.charging, "Battery should be charging by default");
|
||||
is(battery.chargingTime, 0, "Battery chargingTime " + battery.chargingTime + " should be zero by default");
|
||||
is(battery.dischargingTime, Infinity, "Battery dischargingTime should be Infinity by default");
|
||||
is(battery.level, 1.0, "Battery level " + battery.level + " should be 1.0 by default");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,35 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for Battery API</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
/** Test for Battery API **/
|
||||
navigator.getBattery().then(function (battery) {
|
||||
ok(battery.level >= 0.0 && battery.level <= 1.0, "Battery level " + battery.level + " should be in the range [0.0, 1.0]");
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.battery.test.charging", true]]}, function () {
|
||||
is(battery.charging, true, "Battery should be charging");
|
||||
ok(battery.chargingTime >= 0, "Battery chargingTime " + battery.chargingTime + " should be nonnegative when charging");
|
||||
is(battery.dischargingTime, Infinity, "Battery dischargingTime should be Infinity when charging");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,35 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for Battery API</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
/** Test for Battery API **/
|
||||
navigator.getBattery().then(function (battery) {
|
||||
ok(battery.level >= 0.0 && battery.level <= 1.0, "Battery level " + battery.level + " should be in the range [0.0, 1.0]");
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.battery.test.discharging", true]]}, function () {
|
||||
is(battery.charging, false, "Battery should be discharging");
|
||||
is(battery.chargingTime, Infinity, "Battery chargingTime should be Infinity when discharging");
|
||||
ok(battery.dischargingTime > 0, "Battery dischargingTime " + battery.dischargingTime + " should be positive when discharging");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,24 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for Battery API</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
"use strict";
|
||||
|
||||
/** Test for Battery API **/
|
||||
ok(!("getBattery" in navigator), "navigator.getBattery should not exist for unprivileged web content");
|
||||
ok(!("battery" in navigator), "navigator.battery should not exist");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2487,6 +2487,12 @@ ConstructJSImplementation(const char* aContractId,
|
||||
{
|
||||
AutoNoJSAPI nojsapi;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
|
||||
if (!window->IsCurrentInnerWindow()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the XPCOM component containing the JS implementation.
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupports> implISupports = do_CreateInstance(aContractId, &rv);
|
||||
@@ -2501,7 +2507,6 @@ ConstructJSImplementation(const char* aContractId,
|
||||
// and our global is a window.
|
||||
nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi =
|
||||
do_QueryInterface(implISupports);
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
|
||||
if (gpi) {
|
||||
JS::Rooted<JS::Value> initReturn(RootingCx());
|
||||
rv = gpi->Init(window, &initReturn);
|
||||
|
||||
@@ -64,13 +64,11 @@ LOCAL_INCLUDES += [
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'/dom/base',
|
||||
'/dom/battery',
|
||||
'/dom/canvas',
|
||||
'/dom/geolocation',
|
||||
'/dom/html',
|
||||
'/dom/indexedDB',
|
||||
'/dom/media/webaudio',
|
||||
'/dom/media/webspeech/recognition',
|
||||
'/dom/svg',
|
||||
'/dom/workers',
|
||||
'/dom/xbl',
|
||||
|
||||
Vendored
+3
-3
@@ -253,7 +253,7 @@ TypeUtils::ToResponse(const CacheResponse& aIn)
|
||||
{
|
||||
if (aIn.type() == ResponseType::Error) {
|
||||
RefPtr<InternalResponse> error = InternalResponse::NetworkError();
|
||||
RefPtr<Response> r = new Response(GetGlobalObject(), error);
|
||||
RefPtr<Response> r = new Response(GetGlobalObject(), error, nullptr);
|
||||
return r.forget();
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ TypeUtils::ToResponse(const CacheResponse& aIn)
|
||||
}
|
||||
MOZ_DIAGNOSTIC_ASSERT(ir);
|
||||
|
||||
RefPtr<Response> ref = new Response(GetGlobalObject(), ir);
|
||||
RefPtr<Response> ref = new Response(GetGlobalObject(), ir, nullptr);
|
||||
return ref.forget();
|
||||
}
|
||||
already_AddRefed<InternalRequest>
|
||||
@@ -345,7 +345,7 @@ already_AddRefed<Request>
|
||||
TypeUtils::ToRequest(const CacheRequest& aIn)
|
||||
{
|
||||
RefPtr<InternalRequest> internalRequest = ToInternalRequest(aIn);
|
||||
RefPtr<Request> request = new Request(GetGlobalObject(), internalRequest);
|
||||
RefPtr<Request> request = new Request(GetGlobalObject(), internalRequest, nullptr);
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/FunctionBinding.h"
|
||||
#include "mozilla/dom/Performance.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/StructuredCloneHolder.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/dom/WorkletGlobalScope.h"
|
||||
@@ -22,7 +23,6 @@
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "ScriptSettings.h"
|
||||
#include "WorkerPrivate.h"
|
||||
#include "WorkerRunnable.h"
|
||||
#include "WorkerScope.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "ScriptSettings.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
|
||||
@@ -44,9 +44,6 @@ extern bool IsCurrentThreadRunningChromeWorker();
|
||||
|
||||
static char *sPopupAllowedEvents;
|
||||
|
||||
static bool sReturnHighResTimeStamp = false;
|
||||
static bool sReturnHighResTimeStampIsSet = false;
|
||||
|
||||
Event::Event(EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent)
|
||||
@@ -67,13 +64,6 @@ Event::ConstructorInit(EventTarget* aOwner,
|
||||
SetOwner(aOwner);
|
||||
mIsMainThreadEvent = NS_IsMainThread();
|
||||
|
||||
if (mIsMainThreadEvent && !sReturnHighResTimeStampIsSet) {
|
||||
Preferences::AddBoolVarCache(&sReturnHighResTimeStamp,
|
||||
"dom.event.highrestimestamp.enabled",
|
||||
sReturnHighResTimeStamp);
|
||||
sReturnHighResTimeStampIsSet = true;
|
||||
}
|
||||
|
||||
mPrivateDataDuplicated = false;
|
||||
mWantsPopupControlCheck = false;
|
||||
|
||||
@@ -1109,10 +1099,6 @@ Event::TimeStamp() const
|
||||
double
|
||||
Event::TimeStampImpl() const
|
||||
{
|
||||
if (!sReturnHighResTimeStamp) {
|
||||
return static_cast<double>(mEvent->mTime);
|
||||
}
|
||||
|
||||
if (mEvent->mTimeStamp.IsNull()) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SpeechRecognitionError.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
SpeechRecognitionError::SpeechRecognitionError(
|
||||
mozilla::dom::EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent)
|
||||
: Event(aOwner, aPresContext, aEvent)
|
||||
, mError()
|
||||
{
|
||||
}
|
||||
|
||||
SpeechRecognitionError::~SpeechRecognitionError() {}
|
||||
|
||||
already_AddRefed<SpeechRecognitionError>
|
||||
SpeechRecognitionError::Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const SpeechRecognitionErrorInit& aParam,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
RefPtr<SpeechRecognitionError> e = new SpeechRecognitionError(t, nullptr, nullptr);
|
||||
bool trusted = e->Init(t);
|
||||
e->InitSpeechRecognitionError(aType, aParam.mBubbles, aParam.mCancelable, aParam.mError, aParam.mMessage);
|
||||
e->SetTrusted(trusted);
|
||||
e->SetComposed(aParam.mComposed);
|
||||
return e.forget();
|
||||
}
|
||||
|
||||
void
|
||||
SpeechRecognitionError::InitSpeechRecognitionError(const nsAString& aType,
|
||||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
SpeechRecognitionErrorCode aError,
|
||||
const nsAString& aMessage)
|
||||
{
|
||||
Event::InitEvent(aType, aCanBubble, aCancelable);
|
||||
mError = aError;
|
||||
mMessage = aMessage;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
@@ -1,62 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef SpeechRecognitionError_h__
|
||||
#define SpeechRecognitionError_h__
|
||||
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/SpeechRecognitionErrorBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class SpeechRecognitionError : public Event
|
||||
{
|
||||
public:
|
||||
SpeechRecognitionError(mozilla::dom::EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent);
|
||||
virtual ~SpeechRecognitionError();
|
||||
|
||||
static already_AddRefed<SpeechRecognitionError>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const SpeechRecognitionErrorInit& aParam,
|
||||
ErrorResult& aRv);
|
||||
|
||||
virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
return mozilla::dom::SpeechRecognitionErrorBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void
|
||||
GetMessage(nsAString& aString)
|
||||
{
|
||||
aString = mMessage;
|
||||
}
|
||||
|
||||
SpeechRecognitionErrorCode
|
||||
Error()
|
||||
{
|
||||
return mError;
|
||||
}
|
||||
|
||||
void
|
||||
InitSpeechRecognitionError(const nsAString& aType,
|
||||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
SpeechRecognitionErrorCode aError,
|
||||
const nsAString& aMessage);
|
||||
|
||||
protected:
|
||||
SpeechRecognitionErrorCode mError;
|
||||
nsString mMessage;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // SpeechRecognitionError_h__
|
||||
@@ -73,9 +73,6 @@ EXPORTS.mozilla.dom += [
|
||||
'XULCommandEvent.h',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WEBSPEECH']:
|
||||
EXPORTS.mozilla.dom += ['SpeechRecognitionError.h']
|
||||
|
||||
SOURCES += [
|
||||
'AnimationEvent.cpp',
|
||||
'AsyncEventDispatcher.cpp',
|
||||
@@ -127,9 +124,6 @@ SOURCES += [
|
||||
'XULCommandEvent.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WEBSPEECH']:
|
||||
SOURCES += ['SpeechRecognitionError.cpp']
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
@@ -35,12 +35,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=77992
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.requestFlakyTimeout("untriaged");
|
||||
|
||||
// We don't use SpecialPowers.pushPrefEnv since it can delay the test
|
||||
// function until after the load event has fired which means we can't
|
||||
// test the timestamp of the load event.
|
||||
const kPrefName = "dom.event.highrestimestamp.enabled";
|
||||
var prevPrefValue = SpecialPowers.getBoolPref(kPrefName);
|
||||
SpecialPowers.setBoolPref(kPrefName, true);
|
||||
testRegularEvents();
|
||||
|
||||
// Event.timeStamp should be relative to the time origin which is:
|
||||
|
||||
+285
-33
@@ -39,6 +39,7 @@
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
#include "mozilla/dom/workers/ServiceWorkerManager.h"
|
||||
|
||||
#include "FetchObserver.h"
|
||||
#include "InternalRequest.h"
|
||||
#include "InternalResponse.h"
|
||||
|
||||
@@ -52,38 +53,159 @@ namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
|
||||
// This class helps the proxying of AbortSignal changes cross threads.
|
||||
class AbortSignalProxy final : public AbortSignal::Follower
|
||||
{
|
||||
// This is created and released on the main-thread.
|
||||
RefPtr<AbortSignal> mSignalMainThread;
|
||||
|
||||
// This value is used only for the creation of AbortSignal on the
|
||||
// main-thread. They are not updated.
|
||||
const bool mAborted;
|
||||
|
||||
// This runnable propagates changes from the AbortSignal on workers to the
|
||||
// AbortSignal on main-thread.
|
||||
class AbortSignalProxyRunnable final : public Runnable
|
||||
{
|
||||
RefPtr<AbortSignalProxy> mProxy;
|
||||
|
||||
public:
|
||||
explicit AbortSignalProxyRunnable(AbortSignalProxy* aProxy)
|
||||
: mProxy(aProxy)
|
||||
{}
|
||||
|
||||
NS_IMETHOD
|
||||
Run() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
AbortSignal* signal = mProxy->GetOrCreateSignalForMainThread();
|
||||
signal->Abort();
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AbortSignalProxy)
|
||||
|
||||
explicit AbortSignalProxy(AbortSignal* aSignal)
|
||||
: mAborted(aSignal->Aborted())
|
||||
{
|
||||
Follow(aSignal);
|
||||
}
|
||||
|
||||
void
|
||||
Aborted() override
|
||||
{
|
||||
RefPtr<AbortSignalProxyRunnable> runnable =
|
||||
new AbortSignalProxyRunnable(this);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
GetOrCreateSignalForMainThread()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!mSignalMainThread) {
|
||||
mSignalMainThread = new AbortSignal(mAborted);
|
||||
}
|
||||
return mSignalMainThread;
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
GetSignalForTargetThread()
|
||||
{
|
||||
return mFollowingSignal;
|
||||
}
|
||||
|
||||
void
|
||||
Shutdown()
|
||||
{
|
||||
Unfollow();
|
||||
}
|
||||
|
||||
private:
|
||||
~AbortSignalProxy()
|
||||
{
|
||||
NS_ReleaseOnMainThread(mSignalMainThread.forget());
|
||||
}
|
||||
};
|
||||
|
||||
class WorkerFetchResolver final : public FetchDriverObserver
|
||||
{
|
||||
friend class MainThreadFetchRunnable;
|
||||
friend class WorkerDataAvailableRunnable;
|
||||
friend class WorkerFetchResponseEndBase;
|
||||
friend class WorkerFetchResponseEndRunnable;
|
||||
friend class WorkerFetchResponseRunnable;
|
||||
|
||||
RefPtr<PromiseWorkerProxy> mPromiseProxy;
|
||||
RefPtr<AbortSignalProxy> mSignalProxy;
|
||||
RefPtr<FetchObserver> mFetchObserver;
|
||||
|
||||
public:
|
||||
// Returns null if worker is shutting down.
|
||||
static already_AddRefed<WorkerFetchResolver>
|
||||
Create(workers::WorkerPrivate* aWorkerPrivate, Promise* aPromise)
|
||||
Create(workers::WorkerPrivate* aWorkerPrivate, Promise* aPromise,
|
||||
AbortSignal* aSignal, FetchObserver* aObserver)
|
||||
{
|
||||
MOZ_ASSERT(aWorkerPrivate);
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
RefPtr<PromiseWorkerProxy> proxy = PromiseWorkerProxy::Create(aWorkerPrivate, aPromise);
|
||||
RefPtr<PromiseWorkerProxy> proxy =
|
||||
PromiseWorkerProxy::Create(aWorkerPrivate, aPromise);
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<WorkerFetchResolver> r = new WorkerFetchResolver(proxy);
|
||||
RefPtr<AbortSignalProxy> signalProxy;
|
||||
if (aSignal) {
|
||||
signalProxy = new AbortSignalProxy(aSignal);
|
||||
}
|
||||
|
||||
RefPtr<WorkerFetchResolver> r =
|
||||
new WorkerFetchResolver(proxy, signalProxy, aObserver);
|
||||
return r.forget();
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
GetAbortSignalForMainThread()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!mSignalProxy) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mSignalProxy->GetOrCreateSignalForMainThread();
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
GetAbortSignalForTargetThread()
|
||||
{
|
||||
mPromiseProxy->GetWorkerPrivate()->AssertIsOnWorkerThread();
|
||||
|
||||
if (!mSignalProxy) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mSignalProxy->GetSignalForTargetThread();
|
||||
}
|
||||
|
||||
void
|
||||
OnResponseAvailableInternal(InternalResponse* aResponse) override;
|
||||
|
||||
void
|
||||
OnResponseEnd() override;
|
||||
OnResponseEnd(FetchDriverObserver::EndReason eReason) override;
|
||||
|
||||
void
|
||||
OnDataAvailable() override;
|
||||
|
||||
private:
|
||||
explicit WorkerFetchResolver(PromiseWorkerProxy* aProxy)
|
||||
WorkerFetchResolver(PromiseWorkerProxy* aProxy,
|
||||
AbortSignalProxy* aSignalProxy,
|
||||
FetchObserver* aObserver)
|
||||
: mPromiseProxy(aProxy)
|
||||
, mSignalProxy(aSignalProxy)
|
||||
, mFetchObserver(aObserver)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(mPromiseProxy);
|
||||
@@ -100,12 +222,18 @@ class MainThreadFetchResolver final : public FetchDriverObserver
|
||||
{
|
||||
RefPtr<Promise> mPromise;
|
||||
RefPtr<Response> mResponse;
|
||||
RefPtr<FetchObserver> mFetchObserver;
|
||||
RefPtr<AbortSignal> mSignal;
|
||||
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
|
||||
NS_DECL_OWNINGTHREAD
|
||||
public:
|
||||
explicit MainThreadFetchResolver(Promise* aPromise);
|
||||
MainThreadFetchResolver(Promise* aPromise, FetchObserver* aObserver, AbortSignal* aSignal)
|
||||
: mPromise(aPromise)
|
||||
, mFetchObserver(aObserver)
|
||||
, mSignal(aSignal)
|
||||
{}
|
||||
|
||||
void
|
||||
OnResponseAvailableInternal(InternalResponse* aResponse) override;
|
||||
@@ -115,11 +243,20 @@ public:
|
||||
mDocument = aDocument;
|
||||
}
|
||||
|
||||
virtual void OnResponseEnd() override
|
||||
void OnResponseEnd(FetchDriverObserver::EndReason aReason) override
|
||||
{
|
||||
if (aReason == eAborted) {
|
||||
mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
|
||||
}
|
||||
|
||||
mFetchObserver = nullptr;
|
||||
|
||||
FlushConsoleReport();
|
||||
}
|
||||
|
||||
void
|
||||
OnDataAvailable() override;
|
||||
|
||||
private:
|
||||
~MainThreadFetchResolver();
|
||||
|
||||
@@ -170,9 +307,11 @@ public:
|
||||
fetch->SetWorkerScript(spec);
|
||||
}
|
||||
|
||||
RefPtr<AbortSignal> signal = mResolver->GetAbortSignalForMainThread();
|
||||
|
||||
// ...but release it before calling Fetch, because mResolver's callback can
|
||||
// be called synchronously and they want the mutex, too.
|
||||
return fetch->Fetch(mResolver);
|
||||
return fetch->Fetch(signal, mResolver);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -210,6 +349,20 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
|
||||
|
||||
RefPtr<InternalRequest> r = request->GetInternalRequest();
|
||||
|
||||
RefPtr<AbortSignal> signal = request->GetSignal();
|
||||
|
||||
if (signal && signal->Aborted()) {
|
||||
// An already aborted signal should reject immediately.
|
||||
aRv.Throw(NS_ERROR_DOM_ABORT_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<FetchObserver> observer;
|
||||
if (aInit.mObserve.WasPassed()) {
|
||||
observer = new FetchObserver(aGlobal, signal);
|
||||
aInit.mObserve.Value().HandleEvent(*observer);
|
||||
}
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
@@ -236,11 +389,12 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<MainThreadFetchResolver> resolver = new MainThreadFetchResolver(p);
|
||||
RefPtr<MainThreadFetchResolver> resolver =
|
||||
new MainThreadFetchResolver(p, observer, signal);
|
||||
RefPtr<FetchDriver> fetch = new FetchDriver(r, principal, loadGroup);
|
||||
fetch->SetDocument(doc);
|
||||
resolver->SetDocument(doc);
|
||||
aRv = fetch->Fetch(resolver);
|
||||
aRv = fetch->Fetch(signal, resolver);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -252,7 +406,8 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
|
||||
r->SetSkipServiceWorker();
|
||||
}
|
||||
|
||||
RefPtr<WorkerFetchResolver> resolver = WorkerFetchResolver::Create(worker, p);
|
||||
RefPtr<WorkerFetchResolver> resolver =
|
||||
WorkerFetchResolver::Create(worker, p, signal, observer);
|
||||
if (!resolver) {
|
||||
NS_WARNING("Could not add WorkerFetchResolver workerHolder to worker");
|
||||
aRv.Throw(NS_ERROR_DOM_ABORT_ERR);
|
||||
@@ -266,11 +421,6 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
|
||||
return p.forget();
|
||||
}
|
||||
|
||||
MainThreadFetchResolver::MainThreadFetchResolver(Promise* aPromise)
|
||||
: mPromise(aPromise)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
MainThreadFetchResolver::OnResponseAvailableInternal(InternalResponse* aResponse)
|
||||
{
|
||||
@@ -278,16 +428,39 @@ MainThreadFetchResolver::OnResponseAvailableInternal(InternalResponse* aResponse
|
||||
AssertIsOnMainThread();
|
||||
|
||||
if (aResponse->Type() != ResponseType::Error) {
|
||||
if (mFetchObserver) {
|
||||
mFetchObserver->SetState(FetchState::Complete);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> go = mPromise->GetParentObject();
|
||||
mResponse = new Response(go, aResponse);
|
||||
mResponse = new Response(go, aResponse, mSignal);
|
||||
mPromise->MaybeResolve(mResponse);
|
||||
} else {
|
||||
if (mFetchObserver) {
|
||||
mFetchObserver->SetState(FetchState::Errored);
|
||||
}
|
||||
|
||||
ErrorResult result;
|
||||
result.ThrowTypeError<MSG_FETCH_FAILED>();
|
||||
mPromise->MaybeReject(result);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainThreadFetchResolver::OnDataAvailable()
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(MainThreadFetchResolver);
|
||||
AssertIsOnMainThread();
|
||||
|
||||
if (!mFetchObserver) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mFetchObserver->State() == FetchState::Requesting) {
|
||||
mFetchObserver->SetState(FetchState::Responding);
|
||||
}
|
||||
}
|
||||
|
||||
MainThreadFetchResolver::~MainThreadFetchResolver()
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(MainThreadFetchResolver);
|
||||
@@ -306,6 +479,7 @@ public:
|
||||
, mResolver(aResolver)
|
||||
, mInternalResponse(aResponse)
|
||||
{
|
||||
MOZ_ASSERT(mResolver);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -317,10 +491,18 @@ public:
|
||||
RefPtr<Promise> promise = mResolver->mPromiseProxy->WorkerPromise();
|
||||
|
||||
if (mInternalResponse->Type() != ResponseType::Error) {
|
||||
if (mResolver->mFetchObserver) {
|
||||
mResolver->mFetchObserver->SetState(FetchState::Complete);
|
||||
}
|
||||
|
||||
RefPtr<nsIGlobalObject> global = aWorkerPrivate->GlobalScope();
|
||||
RefPtr<Response> response = new Response(global, mInternalResponse);
|
||||
RefPtr<Response> response = new Response(global, mInternalResponse, mResolver->GetAbortSignalForTargetThread());
|
||||
promise->MaybeResolve(response);
|
||||
} else {
|
||||
if (mResolver->mFetchObserver) {
|
||||
mResolver->mFetchObserver->SetState(FetchState::Errored);
|
||||
}
|
||||
|
||||
ErrorResult result;
|
||||
result.ThrowTypeError<MSG_FETCH_FAILED>();
|
||||
promise->MaybeReject(result);
|
||||
@@ -329,14 +511,42 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class WorkerDataAvailableRunnable final : public MainThreadWorkerRunnable
|
||||
{
|
||||
RefPtr<WorkerFetchResolver> mResolver;
|
||||
public:
|
||||
WorkerDataAvailableRunnable(WorkerPrivate* aWorkerPrivate,
|
||||
WorkerFetchResolver* aResolver)
|
||||
: MainThreadWorkerRunnable(aWorkerPrivate)
|
||||
, mResolver(aResolver)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
MOZ_ASSERT(aWorkerPrivate);
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
if (mResolver->mFetchObserver &&
|
||||
mResolver->mFetchObserver->State() == FetchState::Requesting) {
|
||||
mResolver->mFetchObserver->SetState(FetchState::Responding);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class WorkerFetchResponseEndBase
|
||||
{
|
||||
RefPtr<PromiseWorkerProxy> mPromiseProxy;
|
||||
protected:
|
||||
RefPtr<WorkerFetchResolver> mResolver;
|
||||
|
||||
public:
|
||||
explicit WorkerFetchResponseEndBase(PromiseWorkerProxy* aPromiseProxy)
|
||||
: mPromiseProxy(aPromiseProxy)
|
||||
explicit WorkerFetchResponseEndBase(WorkerFetchResolver* aResolver)
|
||||
: mResolver(aResolver)
|
||||
{
|
||||
MOZ_ASSERT(mPromiseProxy);
|
||||
MOZ_ASSERT(aResolver);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -344,23 +554,41 @@ public:
|
||||
{
|
||||
MOZ_ASSERT(aWorkerPrivate);
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
mPromiseProxy->CleanUp();
|
||||
|
||||
mResolver->mPromiseProxy->CleanUp();
|
||||
|
||||
mResolver->mFetchObserver = nullptr;
|
||||
|
||||
if (mResolver->mSignalProxy) {
|
||||
mResolver->mSignalProxy->Shutdown();
|
||||
mResolver->mSignalProxy = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class WorkerFetchResponseEndRunnable final : public MainThreadWorkerRunnable
|
||||
, public WorkerFetchResponseEndBase
|
||||
{
|
||||
FetchDriverObserver::EndReason mReason;
|
||||
|
||||
public:
|
||||
explicit WorkerFetchResponseEndRunnable(PromiseWorkerProxy* aPromiseProxy)
|
||||
: MainThreadWorkerRunnable(aPromiseProxy->GetWorkerPrivate())
|
||||
, WorkerFetchResponseEndBase(aPromiseProxy)
|
||||
WorkerFetchResponseEndRunnable(WorkerPrivate* aWorkerPrivate,
|
||||
WorkerFetchResolver* aResolver,
|
||||
FetchDriverObserver::EndReason aReason)
|
||||
: MainThreadWorkerRunnable(aWorkerPrivate)
|
||||
, WorkerFetchResponseEndBase(aResolver)
|
||||
, mReason(aReason)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
if (mReason == FetchDriverObserver::eAborted) {
|
||||
RefPtr<Promise> promise = mResolver->mPromiseProxy->WorkerPromise();
|
||||
promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
|
||||
}
|
||||
|
||||
WorkerRunInternal(aWorkerPrivate);
|
||||
return true;
|
||||
}
|
||||
@@ -379,9 +607,10 @@ class WorkerFetchResponseEndControlRunnable final : public MainThreadWorkerContr
|
||||
, public WorkerFetchResponseEndBase
|
||||
{
|
||||
public:
|
||||
explicit WorkerFetchResponseEndControlRunnable(PromiseWorkerProxy* aPromiseProxy)
|
||||
: MainThreadWorkerControlRunnable(aPromiseProxy->GetWorkerPrivate())
|
||||
, WorkerFetchResponseEndBase(aPromiseProxy)
|
||||
WorkerFetchResponseEndControlRunnable(WorkerPrivate* aWorkerPrivate,
|
||||
WorkerFetchResolver* aResolver)
|
||||
: MainThreadWorkerControlRunnable(aWorkerPrivate)
|
||||
, WorkerFetchResponseEndBase(aResolver)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -415,7 +644,22 @@ WorkerFetchResolver::OnResponseAvailableInternal(InternalResponse* aResponse)
|
||||
}
|
||||
|
||||
void
|
||||
WorkerFetchResolver::OnResponseEnd()
|
||||
WorkerFetchResolver::OnDataAvailable()
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
MutexAutoLock lock(mPromiseProxy->Lock());
|
||||
if (mPromiseProxy->CleanedUp()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<WorkerDataAvailableRunnable> r =
|
||||
new WorkerDataAvailableRunnable(mPromiseProxy->GetWorkerPrivate(), this);
|
||||
Unused << r->Dispatch();
|
||||
}
|
||||
|
||||
void
|
||||
WorkerFetchResolver::OnResponseEnd(FetchDriverObserver::EndReason aReason)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MutexAutoLock lock(mPromiseProxy->Lock());
|
||||
@@ -426,11 +670,13 @@ WorkerFetchResolver::OnResponseEnd()
|
||||
FlushConsoleReport();
|
||||
|
||||
RefPtr<WorkerFetchResponseEndRunnable> r =
|
||||
new WorkerFetchResponseEndRunnable(mPromiseProxy);
|
||||
new WorkerFetchResponseEndRunnable(mPromiseProxy->GetWorkerPrivate(),
|
||||
this, aReason);
|
||||
|
||||
if (!r->Dispatch()) {
|
||||
RefPtr<WorkerFetchResponseEndControlRunnable> cr =
|
||||
new WorkerFetchResponseEndControlRunnable(mPromiseProxy);
|
||||
new WorkerFetchResponseEndControlRunnable(mPromiseProxy->GetWorkerPrivate(),
|
||||
this);
|
||||
// This can fail if the worker thread is canceled or killed causing
|
||||
// the PromiseWorkerProxy to give up its WorkerHolder immediately,
|
||||
// allowing the worker thread to become Dead.
|
||||
@@ -697,6 +943,12 @@ template <class Derived>
|
||||
already_AddRefed<Promise>
|
||||
FetchBody<Derived>::ConsumeBody(FetchConsumeType aType, ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<AbortSignal> signal = DerivedClass()->GetSignal();
|
||||
if (signal && signal->Aborted()) {
|
||||
aRv.Throw(NS_ERROR_DOM_ABORT_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (BodyUsed()) {
|
||||
aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>();
|
||||
return nullptr;
|
||||
@@ -706,7 +958,7 @@ FetchBody<Derived>::ConsumeBody(FetchConsumeType aType, ErrorResult& aRv)
|
||||
|
||||
RefPtr<Promise> promise =
|
||||
FetchBodyConsumer<Derived>::Create(DerivedClass()->GetParentObject(),
|
||||
this, aType, aRv);
|
||||
this, signal, aType, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -162,6 +162,9 @@ public:
|
||||
return mMimeType;
|
||||
}
|
||||
|
||||
virtual AbortSignal*
|
||||
GetSignal() const = 0;
|
||||
|
||||
protected:
|
||||
FetchBody();
|
||||
|
||||
|
||||
@@ -284,6 +284,7 @@ template <class Derived>
|
||||
/* static */ already_AddRefed<Promise>
|
||||
FetchBodyConsumer<Derived>::Create(nsIGlobalObject* aGlobal,
|
||||
FetchBody<Derived>* aBody,
|
||||
AbortSignal* aSignal,
|
||||
FetchConsumeType aType,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
@@ -345,6 +346,10 @@ FetchBodyConsumer<Derived>::Create(nsIGlobalObject* aGlobal,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (aSignal) {
|
||||
consumer->Follow(aSignal);
|
||||
}
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
@@ -368,6 +373,8 @@ FetchBodyConsumer<Derived>::ReleaseObject()
|
||||
#ifdef DEBUG
|
||||
mBody = nullptr;
|
||||
#endif
|
||||
|
||||
Unfollow();
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
@@ -684,6 +691,14 @@ FetchBodyConsumer<Derived>::Observe(nsISupports* aSubject,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
void
|
||||
FetchBodyConsumer<Derived>::Aborted()
|
||||
{
|
||||
AssertIsOnTargetThread();
|
||||
ContinueConsumeBody(NS_ERROR_DOM_ABORT_ERR, 0, nullptr);
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
NS_IMPL_ADDREF(FetchBodyConsumer<Derived>)
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "mozilla/dom/AbortSignal.h"
|
||||
#include "mozilla/dom/MutableBlobStorage.h"
|
||||
|
||||
class nsIThread;
|
||||
@@ -34,6 +35,7 @@ template <class Derived> class FetchBody;
|
||||
template <class Derived>
|
||||
class FetchBodyConsumer final : public nsIObserver
|
||||
, public nsSupportsWeakReference
|
||||
, public AbortSignal::Follower
|
||||
{
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
@@ -42,6 +44,7 @@ public:
|
||||
static already_AddRefed<Promise>
|
||||
Create(nsIGlobalObject* aGlobal,
|
||||
FetchBody<Derived>* aBody,
|
||||
AbortSignal* aSignal,
|
||||
FetchConsumeType aType,
|
||||
ErrorResult& aRv);
|
||||
|
||||
@@ -73,6 +76,9 @@ public:
|
||||
mConsumeBodyPump = nullptr;
|
||||
}
|
||||
|
||||
// Override AbortSignal::Follower::Aborted
|
||||
void Aborted() override;
|
||||
|
||||
private:
|
||||
FetchBodyConsumer(nsIGlobalObject* aGlobalObject,
|
||||
workers::WorkerPrivate* aWorkerPrivate,
|
||||
|
||||
@@ -67,7 +67,7 @@ FetchDriver::~FetchDriver()
|
||||
}
|
||||
|
||||
nsresult
|
||||
FetchDriver::Fetch(FetchDriverObserver* aObserver)
|
||||
FetchDriver::Fetch(AbortSignal* aSignal, FetchDriverObserver* aObserver)
|
||||
{
|
||||
workers::AssertIsOnMainThread();
|
||||
#ifdef DEBUG
|
||||
@@ -90,6 +90,18 @@ FetchDriver::Fetch(FetchDriverObserver* aObserver)
|
||||
}
|
||||
|
||||
mRequest->SetPrincipalInfo(Move(principalInfo));
|
||||
|
||||
// If the signal is aborted, it's time to inform the observer and terminate
|
||||
// the operation.
|
||||
if (aSignal) {
|
||||
if (aSignal->Aborted()) {
|
||||
Aborted();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Follow(aSignal);
|
||||
}
|
||||
|
||||
if (NS_FAILED(HttpFetch())) {
|
||||
FailWithNetworkError();
|
||||
}
|
||||
@@ -114,11 +126,7 @@ FetchDriver::HttpFetch()
|
||||
nsAutoCString url;
|
||||
mRequest->GetURL(url);
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri),
|
||||
url,
|
||||
nullptr,
|
||||
nullptr,
|
||||
ios);
|
||||
rv = NS_NewURI(getter_AddRefs(uri), url, nullptr, nullptr, ios);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Unsafe requests aren't allowed with when using no-core mode.
|
||||
@@ -380,6 +388,8 @@ FetchDriver::HttpFetch()
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Step 4 onwards of "HTTP Fetch" is handled internally by Necko.
|
||||
|
||||
mChannel = chan;
|
||||
return NS_OK;
|
||||
}
|
||||
already_AddRefed<InternalResponse>
|
||||
@@ -433,9 +443,11 @@ FetchDriver::FailWithNetworkError()
|
||||
#ifdef DEBUG
|
||||
mResponseAvailableCalled = true;
|
||||
#endif
|
||||
mObserver->OnResponseEnd();
|
||||
mObserver->OnResponseEnd(FetchDriverObserver::eByNetworking);
|
||||
mObserver = nullptr;
|
||||
}
|
||||
|
||||
mChannel = nullptr;
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -487,6 +499,11 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest,
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!mChannel) {
|
||||
MOZ_ASSERT(!mObserver);
|
||||
return NS_BINDING_ABORTED;
|
||||
}
|
||||
|
||||
// We should only get to the following code once.
|
||||
MOZ_ASSERT(!mPipeOutputStream);
|
||||
MOZ_ASSERT(mObserver);
|
||||
@@ -655,6 +672,31 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// Runnable to call the observer OnDataAvailable on the main-thread.
|
||||
class DataAvailableRunnable final : public Runnable
|
||||
{
|
||||
RefPtr<FetchDriverObserver> mObserver;
|
||||
|
||||
public:
|
||||
explicit DataAvailableRunnable(FetchDriverObserver* aObserver)
|
||||
: mObserver(aObserver)
|
||||
{
|
||||
MOZ_ASSERT(aObserver);
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
Run() override
|
||||
{
|
||||
mObserver->OnDataAvailable();
|
||||
mObserver = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
NS_IMETHODIMP
|
||||
FetchDriver::OnDataAvailable(nsIRequest* aRequest,
|
||||
nsISupports* aContext,
|
||||
@@ -666,6 +708,18 @@ FetchDriver::OnDataAvailable(nsIRequest* aRequest,
|
||||
// called between OnStartRequest and OnStopRequest, so we don't need to worry
|
||||
// about races.
|
||||
|
||||
if (mObserver) {
|
||||
if (NS_IsMainThread()) {
|
||||
mObserver->OnDataAvailable();
|
||||
} else {
|
||||
RefPtr<Runnable> runnable = new DataAvailableRunnable(mObserver);
|
||||
nsresult rv = NS_DispatchToMainThread(runnable);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t aRead;
|
||||
MOZ_ASSERT(mResponse);
|
||||
MOZ_ASSERT(mPipeOutputStream);
|
||||
@@ -777,10 +831,11 @@ FetchDriver::OnStopRequest(nsIRequest* aRequest,
|
||||
#endif
|
||||
}
|
||||
|
||||
mObserver->OnResponseEnd();
|
||||
mObserver->OnResponseEnd(FetchDriverObserver::eByNetworking);
|
||||
mObserver = nullptr;
|
||||
}
|
||||
|
||||
mChannel = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -921,5 +976,21 @@ FetchDriver::SetRequestHeaders(nsIHttpChannel* aChannel) const
|
||||
}
|
||||
}
|
||||
|
||||
void FetchDriver::Aborted()
|
||||
{
|
||||
if (mObserver) {
|
||||
#ifdef DEBUG
|
||||
mResponseAvailableCalled = true;
|
||||
#endif
|
||||
mObserver->OnResponseEnd(FetchDriverObserver::eAborted);
|
||||
mObserver = nullptr;
|
||||
}
|
||||
|
||||
if (mChannel) {
|
||||
mChannel->Cancel(NS_BINDING_ABORTED);
|
||||
mChannel = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
+26
-5
@@ -12,6 +12,7 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIThreadRetargetableStreamListener.h"
|
||||
#include "mozilla/ConsoleReportCollector.h"
|
||||
#include "mozilla/dom/AbortSignal.h"
|
||||
#include "mozilla/dom/SRIMetadata.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
@@ -49,7 +50,14 @@ public:
|
||||
mGotResponseAvailable = true;
|
||||
OnResponseAvailableInternal(aResponse);
|
||||
}
|
||||
virtual void OnResponseEnd()
|
||||
|
||||
enum EndReason
|
||||
{
|
||||
eAborted,
|
||||
eByNetworking,
|
||||
};
|
||||
|
||||
virtual void OnResponseEnd(EndReason aReason)
|
||||
{ };
|
||||
|
||||
nsIConsoleReportCollector* GetReporter() const
|
||||
@@ -58,6 +66,9 @@ public:
|
||||
}
|
||||
|
||||
virtual void FlushConsoleReport() = 0;
|
||||
|
||||
virtual void OnDataAvailable() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~FetchDriverObserver()
|
||||
{ };
|
||||
@@ -72,7 +83,8 @@ private:
|
||||
class FetchDriver final : public nsIStreamListener,
|
||||
public nsIChannelEventSink,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIThreadRetargetableStreamListener
|
||||
public nsIThreadRetargetableStreamListener,
|
||||
public AbortSignal::Follower
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@@ -82,9 +94,12 @@ public:
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
|
||||
|
||||
explicit FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
|
||||
nsILoadGroup* aLoadGroup);
|
||||
NS_IMETHOD Fetch(FetchDriverObserver* aObserver);
|
||||
FetchDriver(InternalRequest* aRequest,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsILoadGroup* aLoadGroup);
|
||||
|
||||
nsresult Fetch(AbortSignal* aSignal,
|
||||
FetchDriverObserver* aObserver);
|
||||
|
||||
void
|
||||
SetDocument(nsIDocument* aDocument);
|
||||
@@ -96,6 +111,11 @@ public:
|
||||
mWorkerScript = aWorkerScirpt;
|
||||
}
|
||||
|
||||
// AbortSignal::Follower
|
||||
|
||||
void
|
||||
Aborted() override;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
@@ -104,6 +124,7 @@ private:
|
||||
nsCOMPtr<nsIOutputStream> mPipeOutputStream;
|
||||
RefPtr<FetchDriverObserver> mObserver;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
nsAutoPtr<SRICheckDataVerifier> mSRIDataVerifier;
|
||||
SRIMetadata mSRIMetadata;
|
||||
nsCString mWorkerScript;
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "FetchObserver.h"
|
||||
#include "WorkerPrivate.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(FetchObserver)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(FetchObserver,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(FetchObserver,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FetchObserver)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(FetchObserver, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(FetchObserver, DOMEventTargetHelper)
|
||||
|
||||
/* static */ bool
|
||||
FetchObserver::IsEnabled(JSContext* aCx, JSObject* aGlobal)
|
||||
{
|
||||
if (NS_IsMainThread()) {
|
||||
return Preferences::GetBool("dom.fetchObserver.enabled", false);
|
||||
}
|
||||
|
||||
using namespace workers;
|
||||
|
||||
// Otherwise, check the pref via the WorkerPrivate
|
||||
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
||||
if (!workerPrivate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return workerPrivate->FetchObserverEnabled();
|
||||
}
|
||||
|
||||
FetchObserver::FetchObserver(nsIGlobalObject* aGlobal,
|
||||
AbortSignal* aSignal)
|
||||
: DOMEventTargetHelper(aGlobal)
|
||||
, mState(FetchState::Requesting)
|
||||
{
|
||||
if (aSignal) {
|
||||
Follow(aSignal);
|
||||
}
|
||||
}
|
||||
|
||||
JSObject*
|
||||
FetchObserver::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return FetchObserverBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
FetchState
|
||||
FetchObserver::State() const
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
|
||||
void
|
||||
FetchObserver::Aborted()
|
||||
{
|
||||
SetState(FetchState::Aborted);
|
||||
}
|
||||
|
||||
void
|
||||
FetchObserver::SetState(FetchState aState)
|
||||
{
|
||||
MOZ_ASSERT(mState < aState);
|
||||
|
||||
if (mState == FetchState::Aborted ||
|
||||
mState == FetchState::Errored ||
|
||||
mState == FetchState::Complete) {
|
||||
// We are already in a final state.
|
||||
return;
|
||||
}
|
||||
|
||||
// We cannot pass from Requesting to Complete directly.
|
||||
if (mState == FetchState::Requesting &&
|
||||
aState == FetchState::Complete) {
|
||||
SetState(FetchState::Responding);
|
||||
}
|
||||
|
||||
mState = aState;
|
||||
|
||||
if (mState == FetchState::Aborted ||
|
||||
mState == FetchState::Errored ||
|
||||
mState == FetchState::Complete) {
|
||||
Unfollow();
|
||||
}
|
||||
|
||||
EventInit init;
|
||||
init.mBubbles = false;
|
||||
init.mCancelable = false;
|
||||
|
||||
// TODO which kind of event should we dispatch here?
|
||||
|
||||
RefPtr<Event> event =
|
||||
Event::Constructor(this, NS_LITERAL_STRING("statechange"), init);
|
||||
event->SetTrusted(true);
|
||||
|
||||
bool dummy;
|
||||
DispatchEvent(event, &dummy);
|
||||
}
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
@@ -0,0 +1,54 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_FetchObserver_h
|
||||
#define mozilla_dom_FetchObserver_h
|
||||
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/FetchObserverBinding.h"
|
||||
#include "mozilla/dom/AbortSignal.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class FetchObserver final : public DOMEventTargetHelper
|
||||
, public AbortSignal::Follower
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FetchObserver, DOMEventTargetHelper)
|
||||
|
||||
static bool
|
||||
IsEnabled(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
FetchObserver(nsIGlobalObject* aGlobal, AbortSignal* aSignal);
|
||||
|
||||
JSObject*
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
FetchState
|
||||
State() const;
|
||||
|
||||
IMPL_EVENT_HANDLER(statechange);
|
||||
IMPL_EVENT_HANDLER(requestprogress);
|
||||
IMPL_EVENT_HANDLER(responseprogress);
|
||||
|
||||
void
|
||||
Aborted() override;
|
||||
|
||||
void
|
||||
SetState(FetchState aState);
|
||||
|
||||
private:
|
||||
~FetchObserver() = default;
|
||||
|
||||
FetchState mState;
|
||||
};
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
|
||||
#endif // mozilla_dom_FetchObserver_h
|
||||
+30
-4
@@ -37,15 +37,18 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Request)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
Request::Request(nsIGlobalObject* aOwner, InternalRequest* aRequest)
|
||||
Request::Request(nsIGlobalObject* aOwner, InternalRequest* aRequest, AbortSignal* aSignal)
|
||||
: FetchBody<Request>()
|
||||
, mOwner(aOwner)
|
||||
, mRequest(aRequest)
|
||||
, mSignal(aSignal)
|
||||
{
|
||||
MOZ_ASSERT(aRequest->Headers()->Guard() == HeadersGuardEnum::Immutable ||
|
||||
aRequest->Headers()->Guard() == HeadersGuardEnum::Request ||
|
||||
aRequest->Headers()->Guard() == HeadersGuardEnum::Request_no_cors);
|
||||
SetMimeType();
|
||||
|
||||
// aSignal can be null.
|
||||
}
|
||||
|
||||
Request::~Request()
|
||||
@@ -286,6 +289,8 @@ Request::Constructor(const GlobalObject& aGlobal,
|
||||
RefPtr<InternalRequest> request;
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
|
||||
RefPtr<AbortSignal> signal;
|
||||
|
||||
if (aInput.IsRequest()) {
|
||||
RefPtr<Request> inputReq = &aInput.GetAsRequest();
|
||||
@@ -300,6 +305,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
||||
}
|
||||
|
||||
request = inputReq->GetInternalRequest();
|
||||
signal = inputReq->GetOrCreateSignal();
|
||||
} else {
|
||||
// aInput is USVString.
|
||||
// We need to get url before we create a InternalRequest.
|
||||
@@ -418,6 +424,10 @@ Request::Constructor(const GlobalObject& aGlobal,
|
||||
request->SetReferrerPolicy(aInit.mReferrerPolicy.Value());
|
||||
}
|
||||
|
||||
if (aInit.mSignal.WasPassed()) {
|
||||
signal = aInit.mSignal.Value();
|
||||
}
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(global);
|
||||
if (window) {
|
||||
@@ -579,7 +589,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<Request> domRequest = new Request(global, request);
|
||||
RefPtr<Request> domRequest = new Request(global, request, signal);
|
||||
domRequest->SetMimeType();
|
||||
|
||||
if (aInput.IsRequest()) {
|
||||
@@ -595,7 +605,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
||||
}
|
||||
|
||||
already_AddRefed<Request>
|
||||
Request::Clone(ErrorResult& aRv) const
|
||||
Request::Clone(ErrorResult& aRv)
|
||||
{
|
||||
if (BodyUsed()) {
|
||||
aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>();
|
||||
@@ -608,7 +618,7 @@ Request::Clone(ErrorResult& aRv) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<Request> request = new Request(mOwner, ir);
|
||||
RefPtr<Request> request = new Request(mOwner, ir, GetOrCreateSignal());
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
@@ -622,5 +632,21 @@ Request::Headers_()
|
||||
return mHeaders;
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
Request::GetOrCreateSignal()
|
||||
{
|
||||
if (!mSignal) {
|
||||
mSignal = new AbortSignal(false);
|
||||
}
|
||||
|
||||
return mSignal;
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
Request::GetSignal() const
|
||||
{
|
||||
return mSignal;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
+12
-2
@@ -12,6 +12,7 @@
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
#include "mozilla/dom/Fetch.h"
|
||||
#include "mozilla/dom/AbortSignal.h"
|
||||
#include "mozilla/dom/InternalRequest.h"
|
||||
// Required here due to certain WebIDL enums/classes being declared in both
|
||||
// files.
|
||||
@@ -32,7 +33,7 @@ class Request final : public nsISupports
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Request)
|
||||
|
||||
public:
|
||||
Request(nsIGlobalObject* aOwner, InternalRequest* aRequest);
|
||||
Request(nsIGlobalObject* aOwner, InternalRequest* aRequest, AbortSignal* aSignal);
|
||||
|
||||
static bool
|
||||
RequestContextEnabled(JSContext* aCx, JSObject* aObj);
|
||||
@@ -141,7 +142,7 @@ public:
|
||||
}
|
||||
|
||||
already_AddRefed<Request>
|
||||
Clone(ErrorResult& aRv) const;
|
||||
Clone(ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<InternalRequest>
|
||||
GetInternalRequest();
|
||||
@@ -152,13 +153,22 @@ public:
|
||||
return mRequest->GetPrincipalInfo();
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
GetOrCreateSignal();
|
||||
|
||||
// This can return a null AbortSignal.
|
||||
AbortSignal*
|
||||
GetSignal() const override;
|
||||
|
||||
private:
|
||||
~Request();
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> mOwner;
|
||||
RefPtr<InternalRequest> mRequest;
|
||||
|
||||
// Lazily created.
|
||||
RefPtr<Headers> mHeaders;
|
||||
RefPtr<AbortSignal> mSignal;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
||||
@@ -34,10 +34,11 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Response)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
Response::Response(nsIGlobalObject* aGlobal, InternalResponse* aInternalResponse)
|
||||
Response::Response(nsIGlobalObject* aGlobal, InternalResponse* aInternalResponse, AbortSignal* aSignal)
|
||||
: FetchBody<Response>()
|
||||
, mOwner(aGlobal)
|
||||
, mInternalResponse(aInternalResponse)
|
||||
, mSignal(aSignal)
|
||||
{
|
||||
MOZ_ASSERT(aInternalResponse->Headers()->Guard() == HeadersGuardEnum::Immutable ||
|
||||
aInternalResponse->Headers()->Guard() == HeadersGuardEnum::Response);
|
||||
@@ -53,7 +54,7 @@ Response::Error(const GlobalObject& aGlobal)
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
RefPtr<InternalResponse> error = InternalResponse::NetworkError();
|
||||
RefPtr<Response> r = new Response(global, error);
|
||||
RefPtr<Response> r = new Response(global, error, nullptr);
|
||||
return r.forget();
|
||||
}
|
||||
|
||||
@@ -173,7 +174,7 @@ Response::Constructor(const GlobalObject& aGlobal,
|
||||
internalResponse->InitChannelInfo(worker->GetChannelInfo());
|
||||
}
|
||||
|
||||
RefPtr<Response> r = new Response(global, internalResponse);
|
||||
RefPtr<Response> r = new Response(global, internalResponse, nullptr);
|
||||
|
||||
if (aInit.mHeaders.WasPassed()) {
|
||||
internalResponse->Headers()->Clear();
|
||||
@@ -236,7 +237,7 @@ Response::Clone(ErrorResult& aRv) const
|
||||
}
|
||||
|
||||
RefPtr<InternalResponse> ir = mInternalResponse->Clone();
|
||||
RefPtr<Response> response = new Response(mOwner, ir);
|
||||
RefPtr<Response> response = new Response(mOwner, ir, mSignal);
|
||||
return response.forget();
|
||||
}
|
||||
|
||||
@@ -250,7 +251,7 @@ Response::CloneUnfiltered(ErrorResult& aRv) const
|
||||
|
||||
RefPtr<InternalResponse> clone = mInternalResponse->Clone();
|
||||
RefPtr<InternalResponse> ir = clone->Unfiltered();
|
||||
RefPtr<Response> ref = new Response(mOwner, ir);
|
||||
RefPtr<Response> ref = new Response(mOwner, ir, mSignal);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class Response final : public nsISupports
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Response)
|
||||
|
||||
public:
|
||||
Response(nsIGlobalObject* aGlobal, InternalResponse* aInternalResponse);
|
||||
Response(nsIGlobalObject* aGlobal, InternalResponse* aInternalResponse, AbortSignal* aSignal);
|
||||
|
||||
Response(const Response& aOther) = delete;
|
||||
|
||||
@@ -134,13 +134,21 @@ public:
|
||||
already_AddRefed<InternalResponse>
|
||||
GetInternalResponse() const;
|
||||
|
||||
AbortSignal*
|
||||
GetSignal() const override
|
||||
{
|
||||
return mSignal;
|
||||
}
|
||||
|
||||
private:
|
||||
~Response();
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> mOwner;
|
||||
RefPtr<InternalResponse> mInternalResponse;
|
||||
|
||||
// Lazily created
|
||||
RefPtr<Headers> mHeaders;
|
||||
RefPtr<AbortSignal> mSignal;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
||||
@@ -9,6 +9,7 @@ EXPORTS.mozilla.dom += [
|
||||
'Fetch.h',
|
||||
'FetchDriver.h',
|
||||
'FetchIPCTypes.h',
|
||||
'FetchObserver.h',
|
||||
'FetchUtil.h',
|
||||
'Headers.h',
|
||||
'InternalHeaders.h',
|
||||
@@ -28,6 +29,7 @@ UNIFIED_SOURCES += [
|
||||
SOURCES += [
|
||||
'ChannelInfo.cpp',
|
||||
'FetchDriver.cpp',
|
||||
'FetchObserver.cpp',
|
||||
'FetchUtil.cpp',
|
||||
'Headers.cpp',
|
||||
'InternalHeaders.cpp',
|
||||
|
||||
@@ -199,18 +199,18 @@ HTMLButtonElement::ParseAttribute(int32_t aNamespaceID,
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLButtonElement::IsDisabledForEvents(EventMessage aMessage)
|
||||
HTMLButtonElement::IsDisabledForEvents(WidgetEvent* aEvent)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = GetFormControlFrame(false);
|
||||
nsIFrame* formFrame = do_QueryFrame(formControlFrame);
|
||||
return IsElementDisabledForEvents(aMessage, formFrame);
|
||||
return IsElementDisabledForEvents(aEvent, formFrame);
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLButtonElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
|
||||
{
|
||||
aVisitor.mCanHandle = false;
|
||||
if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) {
|
||||
if (IsDisabledForEvents(aVisitor.mEvent)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
|
||||
NS_IMETHOD SaveState() override;
|
||||
bool RestoreState(nsPresState* aState) override;
|
||||
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
|
||||
virtual bool IsDisabledForEvents(WidgetEvent* aEvent) override;
|
||||
|
||||
virtual void FieldSetDisabledChanged(bool aNotify) override;
|
||||
|
||||
|
||||
@@ -63,9 +63,9 @@ NS_IMPL_STRING_ATTR(HTMLFieldSetElement, Name, name)
|
||||
NS_IMPL_NSICONSTRAINTVALIDATION(HTMLFieldSetElement)
|
||||
|
||||
bool
|
||||
HTMLFieldSetElement::IsDisabledForEvents(EventMessage aMessage)
|
||||
HTMLFieldSetElement::IsDisabledForEvents(WidgetEvent* aEvent)
|
||||
{
|
||||
return IsElementDisabledForEvents(aMessage, nullptr);
|
||||
return IsElementDisabledForEvents(aEvent, nullptr);
|
||||
}
|
||||
|
||||
// nsIContent
|
||||
@@ -74,7 +74,7 @@ HTMLFieldSetElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
|
||||
{
|
||||
// Do not process any DOM events if the element is disabled.
|
||||
aVisitor.mCanHandle = false;
|
||||
if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) {
|
||||
if (IsDisabledForEvents(aVisitor.mEvent)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
NS_IMETHOD_(uint32_t) GetType() const override { return NS_FORM_FIELDSET; }
|
||||
NS_IMETHOD Reset() override;
|
||||
NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
|
||||
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
|
||||
virtual bool IsDisabledForEvents(WidgetEvent* aEvent) override;
|
||||
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
||||
|
||||
const nsIContent* GetFirstLegend() const { return mFirstLegend; }
|
||||
|
||||
@@ -324,7 +324,7 @@ HTMLImageElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||
nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapImageBorderAttributeInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
|
||||
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData, true);
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
||||
}
|
||||
|
||||
|
||||
@@ -206,6 +206,11 @@ public:
|
||||
return GetReferrerPolicyAsEnum();
|
||||
}
|
||||
|
||||
bool IsAwaitingLoad() const
|
||||
{
|
||||
return !!mPendingImageLoadTask;
|
||||
}
|
||||
|
||||
int32_t X();
|
||||
int32_t Y();
|
||||
// Uses XPCOM GetLowsrc.
|
||||
|
||||
@@ -3732,9 +3732,9 @@ HTMLInputElement::NeedToInitializeEditorForEvent(
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLInputElement::IsDisabledForEvents(EventMessage aMessage)
|
||||
HTMLInputElement::IsDisabledForEvents(WidgetEvent* aEvent)
|
||||
{
|
||||
return IsElementDisabledForEvents(aMessage, GetPrimaryFrame());
|
||||
return IsElementDisabledForEvents(aEvent, GetPrimaryFrame());
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -3742,7 +3742,7 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
|
||||
{
|
||||
// Do not process any DOM events if the element is disabled
|
||||
aVisitor.mCanHandle = false;
|
||||
if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) {
|
||||
if (IsDisabledForEvents(aVisitor.mEvent)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
NS_IMETHOD SaveState() override;
|
||||
virtual bool RestoreState(nsPresState* aState) override;
|
||||
virtual bool AllowDrop() override;
|
||||
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
|
||||
virtual bool IsDisabledForEvents(WidgetEvent* aEvent) override;
|
||||
|
||||
virtual void FieldSetDisabledChanged(bool aNotify) override;
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ public:
|
||||
using nsGenericHTMLElement::Focus;
|
||||
virtual void Focus(mozilla::ErrorResult& aError) override;
|
||||
|
||||
virtual bool IsDisabled() const override { return false; }
|
||||
|
||||
// nsIContent
|
||||
virtual nsresult PostHandleEvent(
|
||||
EventChainPostVisitor& aVisitor) override;
|
||||
|
||||
Loaded 100 of 1156 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user