diff options
Diffstat (limited to 'dom')
40 files changed, 200 insertions, 668 deletions
diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index a544f23c1..53ce2b30f 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -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) { diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 4ddaaabab..bcc67589e 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -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 diff --git a/dom/base/moz.build b/dom/base/moz.build index ded203c50..fe65453fe 100755 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -419,7 +419,6 @@ EXTRA_JS_MODULES += [ ] LOCAL_INCLUDES += [ - '../battery', '../events', '../media', '../network', diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 61d10e022..3568ced90 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -5123,6 +5123,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()); diff --git a/dom/battery/BatteryManager.cpp b/dom/battery/BatteryManager.cpp deleted file mode 100644 index 271fa373d..000000000 --- a/dom/battery/BatteryManager.cpp +++ /dev/null @@ -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 diff --git a/dom/battery/BatteryManager.h b/dom/battery/BatteryManager.h deleted file mode 100644 index 4094c40d4..000000000 --- a/dom/battery/BatteryManager.h +++ /dev/null @@ -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 diff --git a/dom/battery/Constants.h b/dom/battery/Constants.h deleted file mode 100644 index f642e2a46..000000000 --- a/dom/battery/Constants.h +++ /dev/null @@ -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__ diff --git a/dom/battery/Types.h b/dom/battery/Types.h deleted file mode 100644 index ee55a26d3..000000000 --- a/dom/battery/Types.h +++ /dev/null @@ -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 - diff --git a/dom/battery/moz.build b/dom/battery/moz.build deleted file mode 100644 index e3743c40b..000000000 --- a/dom/battery/moz.build +++ /dev/null @@ -1,21 +0,0 @@ -# -*- 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/. - -EXPORTS.mozilla.dom.battery += [ - 'Constants.h', - 'Types.h', -] - -SOURCES += [ - 'BatteryManager.cpp', -] - -include('/ipc/chromium/chromium-config.mozbuild') - -FINAL_LIBRARY = 'xul' - -MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini'] -MOCHITEST_MANIFESTS += ['test/mochitest.ini'] diff --git a/dom/battery/test/chrome.ini b/dom/battery/test/chrome.ini deleted file mode 100644 index ced199bff..000000000 --- a/dom/battery/test/chrome.ini +++ /dev/null @@ -1,3 +0,0 @@ -[test_battery_basics.html] -[test_battery_charging.html] -[test_battery_discharging.html] diff --git a/dom/battery/test/mochitest.ini b/dom/battery/test/mochitest.ini deleted file mode 100644 index 4d8307930..000000000 --- a/dom/battery/test/mochitest.ini +++ /dev/null @@ -1 +0,0 @@ -[test_battery_unprivileged.html] diff --git a/dom/battery/test/test_battery_basics.html b/dom/battery/test/test_battery_basics.html deleted file mode 100644 index 96f7f3368..000000000 --- a/dom/battery/test/test_battery_basics.html +++ /dev/null @@ -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> diff --git a/dom/battery/test/test_battery_charging.html b/dom/battery/test/test_battery_charging.html deleted file mode 100644 index 5d1e83284..000000000 --- a/dom/battery/test/test_battery_charging.html +++ /dev/null @@ -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> diff --git a/dom/battery/test/test_battery_discharging.html b/dom/battery/test/test_battery_discharging.html deleted file mode 100644 index 26a0359d3..000000000 --- a/dom/battery/test/test_battery_discharging.html +++ /dev/null @@ -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> diff --git a/dom/battery/test/test_battery_unprivileged.html b/dom/battery/test/test_battery_unprivileged.html deleted file mode 100644 index e56db8ac7..000000000 --- a/dom/battery/test/test_battery_unprivileged.html +++ /dev/null @@ -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> diff --git a/dom/bindings/moz.build b/dom/bindings/moz.build index fae0fd15a..14abc6d88 100644 --- a/dom/bindings/moz.build +++ b/dom/bindings/moz.build @@ -62,7 +62,6 @@ LOCAL_INCLUDES += [ LOCAL_INCLUDES += [ '/dom/base', - '/dom/battery', '/dom/canvas', '/dom/geolocation', '/dom/html', diff --git a/dom/cache/TypeUtils.cpp b/dom/cache/TypeUtils.cpp index f8c5cd7be..5c3661d66 100644 --- a/dom/cache/TypeUtils.cpp +++ b/dom/cache/TypeUtils.cpp @@ -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(); } diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp index 191f4cfc3..f0350fbce 100644 --- a/dom/fetch/Fetch.cpp +++ b/dom/fetch/Fetch.cpp @@ -111,6 +111,12 @@ public: return mSignalMainThread; } + AbortSignal* + GetSignalForTargetThread() + { + return mFollowingSignal; + } + void Shutdown() { @@ -161,7 +167,7 @@ public: } AbortSignal* - GetAbortSignal() + GetAbortSignalForMainThread() { MOZ_ASSERT(NS_IsMainThread()); @@ -172,6 +178,18 @@ public: return mSignalProxy->GetOrCreateSignalForMainThread(); } + AbortSignal* + GetAbortSignalForTargetThread() + { + mPromiseProxy->GetWorkerPrivate()->AssertIsOnWorkerThread(); + + if (!mSignalProxy) { + return nullptr; + } + + return mSignalProxy->GetSignalForTargetThread(); + } + void OnResponseAvailableInternal(InternalResponse* aResponse) override; @@ -205,14 +223,16 @@ class MainThreadFetchResolver final : public FetchDriverObserver RefPtr<Promise> mPromise; RefPtr<Response> mResponse; RefPtr<FetchObserver> mFetchObserver; + RefPtr<AbortSignal> mSignal; nsCOMPtr<nsIDocument> mDocument; NS_DECL_OWNINGTHREAD public: - MainThreadFetchResolver(Promise* aPromise, FetchObserver* aObserver) + MainThreadFetchResolver(Promise* aPromise, FetchObserver* aObserver, AbortSignal* aSignal) : mPromise(aPromise) , mFetchObserver(aObserver) + , mSignal(aSignal) {} void @@ -287,7 +307,7 @@ public: fetch->SetWorkerScript(spec); } - RefPtr<AbortSignal> signal = mResolver->GetAbortSignal(); + 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. @@ -329,10 +349,7 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput, RefPtr<InternalRequest> r = request->GetInternalRequest(); - RefPtr<AbortSignal> signal; - if (aInit.mSignal.WasPassed()) { - signal = &aInit.mSignal.Value(); - } + RefPtr<AbortSignal> signal = request->GetSignal(); if (signal && signal->Aborted()) { // An already aborted signal should reject immediately. @@ -373,7 +390,7 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput, } RefPtr<MainThreadFetchResolver> resolver = - new MainThreadFetchResolver(p, observer); + new MainThreadFetchResolver(p, observer, signal); RefPtr<FetchDriver> fetch = new FetchDriver(r, principal, loadGroup); fetch->SetDocument(doc); resolver->SetDocument(doc); @@ -416,7 +433,7 @@ MainThreadFetchResolver::OnResponseAvailableInternal(InternalResponse* aResponse } nsCOMPtr<nsIGlobalObject> go = mPromise->GetParentObject(); - mResponse = new Response(go, aResponse); + mResponse = new Response(go, aResponse, mSignal); mPromise->MaybeResolve(mResponse); } else { if (mFetchObserver) { @@ -479,7 +496,7 @@ public: } 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) { @@ -926,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; @@ -935,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; } diff --git a/dom/fetch/Fetch.h b/dom/fetch/Fetch.h index fc50d3fda..842066152 100644 --- a/dom/fetch/Fetch.h +++ b/dom/fetch/Fetch.h @@ -162,6 +162,9 @@ public: return mMimeType; } + virtual AbortSignal* + GetSignal() const = 0; + protected: FetchBody(); diff --git a/dom/fetch/FetchConsumer.cpp b/dom/fetch/FetchConsumer.cpp index e82e5ec51..d2d07eaa2 100644 --- a/dom/fetch/FetchConsumer.cpp +++ b/dom/fetch/FetchConsumer.cpp @@ -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>) diff --git a/dom/fetch/FetchConsumer.h b/dom/fetch/FetchConsumer.h index 2b5725342..77af09d9b 100644 --- a/dom/fetch/FetchConsumer.h +++ b/dom/fetch/FetchConsumer.h @@ -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, diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp index 067e32db4..fd1e99a2b 100644 --- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -499,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); diff --git a/dom/fetch/Request.cpp b/dom/fetch/Request.cpp index 6a7885b1a..76f3ce5c5 100644 --- a/dom/fetch/Request.cpp +++ b/dom/fetch/Request.cpp @@ -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 diff --git a/dom/fetch/Request.h b/dom/fetch/Request.h index f6fe9be7b..34cbc52cf 100644 --- a/dom/fetch/Request.h +++ b/dom/fetch/Request.h @@ -33,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); @@ -142,7 +142,7 @@ public: } already_AddRefed<Request> - Clone(ErrorResult& aRv) const; + Clone(ErrorResult& aRv); already_AddRefed<InternalRequest> GetInternalRequest(); @@ -153,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 diff --git a/dom/fetch/Response.cpp b/dom/fetch/Response.cpp index e35de0e12..241614286 100644 --- a/dom/fetch/Response.cpp +++ b/dom/fetch/Response.cpp @@ -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(); } diff --git a/dom/fetch/Response.h b/dom/fetch/Response.h index de367bef6..ca86c3458 100644 --- a/dom/fetch/Response.h +++ b/dom/fetch/Response.h @@ -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 diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp index 444c352e2..d042a9fe6 100644 --- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -325,7 +325,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); } diff --git a/dom/html/HTMLImageElement.h b/dom/html/HTMLImageElement.h index bb4a09882..23cac4afb 100644 --- a/dom/html/HTMLImageElement.h +++ b/dom/html/HTMLImageElement.h @@ -196,6 +196,11 @@ public: return GetReferrerPolicyAsEnum(); } + bool IsAwaitingLoad() const + { + return !!mPendingImageLoadTask; + } + int32_t X(); int32_t Y(); // Uses XPCOM GetLowsrc. diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index b52e61ce6..35ce8533b 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -1449,29 +1449,57 @@ nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAtt void nsGenericHTMLElement::MapImageSizeAttributesInto(const nsMappedAttributes* aAttributes, - nsRuleData* aData) + nsRuleData* aData, + bool aMapAspectRatio) { if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Position))) return; + auto* aWidth = aAttributes->GetAttr(nsGkAtoms::width); + auto* aHeight = aAttributes->GetAttr(nsGkAtoms::height); + // width: value - nsCSSValue* width = aData->ValueForWidth(); - if (width->GetUnit() == eCSSUnit_Null) { - const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width); - if (value && value->Type() == nsAttrValue::eInteger) - width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel); - else if (value && value->Type() == nsAttrValue::ePercent) - width->SetPercentValue(value->GetPercentValue()); + if (aWidth) { + nsCSSValue* cWidth = aData->ValueForWidth(); + if (cWidth->GetUnit() == eCSSUnit_Null) { + if (aWidth->Type() == nsAttrValue::eInteger) + cWidth->SetFloatValue((float)aWidth->GetIntegerValue(), eCSSUnit_Pixel); + else if (aWidth->Type() == nsAttrValue::ePercent) + cWidth->SetPercentValue(aWidth->GetPercentValue()); + } } // height: value - nsCSSValue* height = aData->ValueForHeight(); - if (height->GetUnit() == eCSSUnit_Null) { - const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height); - if (value && value->Type() == nsAttrValue::eInteger) - height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel); - else if (value && value->Type() == nsAttrValue::ePercent) - height->SetPercentValue(value->GetPercentValue()); + if (aHeight) { + nsCSSValue* cHeight = aData->ValueForHeight(); + if (cHeight->GetUnit() == eCSSUnit_Null) { + if (aHeight->Type() == nsAttrValue::eInteger) + cHeight->SetFloatValue((float)aHeight->GetIntegerValue(), eCSSUnit_Pixel); + else if (aHeight->Type() == nsAttrValue::ePercent) + cHeight->SetPercentValue(aHeight->GetPercentValue()); + } + } + + if (Preferences::GetBool("layout.css.intrinsic-aspect-ratio.enabled") && + aMapAspectRatio && aWidth && aHeight) { + Maybe<double> w; + if (aWidth->Type() == nsAttrValue::eInteger) { + w.emplace(aWidth->GetIntegerValue()); + } else if (aWidth->Type() == nsAttrValue::eDoubleValue) { + w.emplace(aWidth->GetDoubleValue()); + } + + Maybe<double> h; + if (aHeight->Type() == nsAttrValue::eInteger) { + h.emplace(aHeight->GetIntegerValue()); + } else if (aHeight->Type() == nsAttrValue::eDoubleValue) { + h.emplace(aHeight->GetDoubleValue()); + } + + if (w && h && *w != 0 && *h != 0) { + nsCSSValue* aspect_ratio = aData->ValueForAspectRatio(); + aspect_ratio->SetFloatValue((float(*w) / float(*h)), eCSSUnit_Number); + } } } diff --git a/dom/html/nsGenericHTMLElement.h b/dom/html/nsGenericHTMLElement.h index c9169df11..8412ea0dc 100644 --- a/dom/html/nsGenericHTMLElement.h +++ b/dom/html/nsGenericHTMLElement.h @@ -702,10 +702,12 @@ public: * * @param aAttributes the list of attributes to map * @param aData the returned rule data [INOUT] + * @param aMapAspectRatio map width and height attributes on aspect-ratio * @see GetAttributeMappingFunction */ static void MapImageSizeAttributesInto(const nsMappedAttributes* aAttributes, - nsRuleData* aData); + nsRuleData* aData, + bool = false); /** * Helper to map the background attribute * into a style struct. diff --git a/dom/moz.build b/dom/moz.build index 7888ccd69..e232f3443 100644 --- a/dom/moz.build +++ b/dom/moz.build @@ -43,7 +43,6 @@ DIRS += [ 'base', 'archivereader', 'bindings', - 'battery', 'browser-element', 'cache', 'canvas', diff --git a/dom/quota/QuotaManagerService.cpp b/dom/quota/QuotaManagerService.cpp index bd811dc9b..22b5d17b1 100644 --- a/dom/quota/QuotaManagerService.cpp +++ b/dom/quota/QuotaManagerService.cpp @@ -432,30 +432,6 @@ QuotaManagerService::PerformIdleMaintenance() MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); - // If we're running on battery power then skip all idle maintenance since we - // would otherwise be doing lots of disk I/O. - BatteryInformation batteryInfo; - -#ifdef MOZ_WIDGET_ANDROID - // Android XPCShell doesn't load the AndroidBridge that is needed to make - // GetCurrentBatteryInformation work... - if (!QuotaManager::IsRunningXPCShellTests()) -#endif - { - GetCurrentBatteryInformation(&batteryInfo); - } - - // If we're running XPCShell because we always want to be able to test this - // code so pretend that we're always charging. - if (QuotaManager::IsRunningXPCShellTests()) { - batteryInfo.level() = 100; - batteryInfo.charging() = true; - } - - if (NS_WARN_IF(!batteryInfo.charging())) { - return; - } - if (QuotaManager::IsRunningXPCShellTests()) { // We don't want user activity to impact this code if we're running tests. Unused << Observe(nullptr, OBSERVER_TOPIC_IDLE, nullptr); diff --git a/dom/webidl/BatteryManager.webidl b/dom/webidl/BatteryManager.webidl deleted file mode 100644 index a964f3b0b..000000000 --- a/dom/webidl/BatteryManager.webidl +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://www.w3.org/TR/battery-status/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. - */ - -interface BatteryManager : EventTarget { - readonly attribute boolean charging; - readonly attribute unrestricted double chargingTime; - readonly attribute unrestricted double dischargingTime; - readonly attribute double level; - - attribute EventHandler onchargingchange; - attribute EventHandler onchargingtimechange; - attribute EventHandler ondischargingtimechange; - attribute EventHandler onlevelchange; -}; diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index 4536d7d25..f34429de7 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -7,7 +7,6 @@ * http://www.whatwg.org/specs/web-apps/current-work/#the-navigator-object * http://www.w3.org/TR/tracking-dnt/ * http://www.w3.org/TR/geolocation-API/#geolocation_interface - * http://www.w3.org/TR/battery-status/#navigatorbattery-interface * http://www.w3.org/TR/vibration/#vibration-interface * http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1 * https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension @@ -125,13 +124,6 @@ interface NavigatorGeolocation { }; Navigator implements NavigatorGeolocation; -// http://www.w3.org/TR/battery-status/#navigatorbattery-interface -partial interface Navigator { - // ChromeOnly to prevent web content from fingerprinting users' batteries. - [Throws, ChromeOnly, Pref="dom.battery.enabled"] - Promise<BatteryManager> getBattery(); -}; - // http://www.w3.org/TR/vibration/#vibration-interface partial interface Navigator { // We don't support sequences in unions yet diff --git a/dom/webidl/Node.webidl b/dom/webidl/Node.webidl index c9fb7e77e..bf2c1c4de 100644 --- a/dom/webidl/Node.webidl +++ b/dom/webidl/Node.webidl @@ -38,7 +38,7 @@ interface Node : EventTarget { readonly attribute boolean isConnected; [Pure] readonly attribute Document? ownerDocument; - [Pure] + [Pure, Pref="dom.getRootNode.enabled"] Node getRootNode(optional GetRootNodeOptions options); [Pure] readonly attribute Node? parentNode; diff --git a/dom/webidl/Request.webidl b/dom/webidl/Request.webidl index fe6a63ec0..9140543e7 100644 --- a/dom/webidl/Request.webidl +++ b/dom/webidl/Request.webidl @@ -27,6 +27,10 @@ interface Request { readonly attribute RequestRedirect redirect; readonly attribute DOMString integrity; + [Func="AbortController::IsEnabled", + BinaryName="getOrCreateSignal"] + readonly attribute AbortSignal signal; + [Throws, NewObject] Request clone(); @@ -49,7 +53,7 @@ dictionary RequestInit { DOMString integrity; [Func="AbortController::IsEnabled"] - AbortSignal signal; + AbortSignal? signal; [Func="FetchObserver::IsEnabled"] ObserverCallback observe; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index acdc392be..c56a9b984 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -50,7 +50,6 @@ WEBIDL_FILES = [ 'AutocompleteInfo.webidl', 'BarProp.webidl', 'BaseKeyframeTypes.webidl', - 'BatteryManager.webidl', 'BeforeAfterKeyboardEvent.webidl', 'BeforeUnloadEvent.webidl', 'BiquadFilterNode.webidl', diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp index bcec94dcb..8f2023609 100644 --- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -694,7 +694,7 @@ private: ir->SetPrincipalInfo(Move(principalInfo)); RefPtr<mozilla::dom::Response> response = - new mozilla::dom::Response(mCacheCreator->Global(), ir); + new mozilla::dom::Response(mCacheCreator->Global(), ir, nullptr); mozilla::dom::RequestOrUSVString request; @@ -1101,14 +1101,16 @@ private: rv = NS_GetFinalChannelURI(channel, getter_AddRefs(finalURI)); NS_ENSURE_SUCCESS(rv, rv); - nsCString filename; - rv = finalURI->GetSpec(filename); - NS_ENSURE_SUCCESS(rv, rv); + if (principal->Subsumes(channelPrincipal)) { + nsCString filename; + rv = finalURI->GetSpec(filename); + NS_ENSURE_SUCCESS(rv, rv); - if (!filename.IsEmpty()) { - // This will help callers figure out what their script url resolved to in - // case of errors. - aLoadInfo.mURL.Assign(NS_ConvertUTF8toUTF16(filename)); + if (!filename.IsEmpty()) { + // This will help callers figure out what their script url resolved to in + // case of errors. + aLoadInfo.mURL.Assign(NS_ConvertUTF8toUTF16(filename)); + } } nsCOMPtr<nsILoadInfo> chanLoadInfo = channel->GetLoadInfo(); diff --git a/dom/workers/ServiceWorkerPrivate.cpp b/dom/workers/ServiceWorkerPrivate.cpp index 23ae3b366..571ceca37 100644 --- a/dom/workers/ServiceWorkerPrivate.cpp +++ b/dom/workers/ServiceWorkerPrivate.cpp @@ -1510,7 +1510,7 @@ private: if (NS_WARN_IF(!global)) { return false; } - RefPtr<Request> request = new Request(global, internalReq); + RefPtr<Request> request = new Request(global, internalReq, nullptr); MOZ_ASSERT_IF(internalReq->IsNavigationRequest(), request->Redirect() == RequestRedirect::Manual); diff --git a/dom/workers/ServiceWorkerScriptCache.cpp b/dom/workers/ServiceWorkerScriptCache.cpp index 707b689e8..3db58e694 100644 --- a/dom/workers/ServiceWorkerScriptCache.cpp +++ b/dom/workers/ServiceWorkerScriptCache.cpp @@ -554,7 +554,7 @@ private: ir->SetPrincipalInfo(Move(mPrincipalInfo)); } - RefPtr<Response> response = new Response(aCache->GetGlobalObject(), ir); + RefPtr<Response> response = new Response(aCache->GetGlobalObject(), ir, nullptr); RequestOrUSVString request; request.SetAsUSVString().Rebind(URL().Data(), URL().Length()); |