diff options
author | Moonchild <moonchild@palemoon.org> | 2020-11-20 09:47:03 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-11-20 09:47:03 +0000 |
commit | 5165ed02285315cc0bed7977c7bac6d0a90ca43c (patch) | |
tree | 9b761a21eb924915e51c2d803208e6c01b505a45 /dom | |
parent | e1db27e19989db11fef70f439cf95821316535b3 (diff) | |
parent | ca9abcdf1702c37bf00048dab3f460b2252873a3 (diff) | |
download | UXP-5165ed02285315cc0bed7977c7bac6d0a90ca43c.tar UXP-5165ed02285315cc0bed7977c7bac6d0a90ca43c.tar.gz UXP-5165ed02285315cc0bed7977c7bac6d0a90ca43c.tar.lz UXP-5165ed02285315cc0bed7977c7bac6d0a90ca43c.tar.xz UXP-5165ed02285315cc0bed7977c7bac6d0a90ca43c.zip |
Merge branch 'redwood' into releaseRELBASE_20201124RELBASE_20201120RC_20201120
Diffstat (limited to 'dom')
-rw-r--r-- | dom/animation/test/mozilla/file_discrete-animations.html | 5 | ||||
-rw-r--r-- | dom/base/Navigator.cpp | 193 | ||||
-rw-r--r-- | dom/base/Navigator.h | 3 | ||||
-rw-r--r-- | dom/base/nsTreeSanitizer.cpp | 13 | ||||
-rw-r--r-- | dom/base/nsTreeSanitizer.h | 6 | ||||
-rwxr-xr-x | dom/tests/mochitest/general/mochitest.ini | 1 | ||||
-rw-r--r-- | dom/tests/mochitest/general/test_vibrator.html | 93 | ||||
-rw-r--r-- | dom/webidl/Navigator.webidl | 25 |
8 files changed, 23 insertions, 316 deletions
diff --git a/dom/animation/test/mozilla/file_discrete-animations.html b/dom/animation/test/mozilla/file_discrete-animations.html index 35e818a90..eeaaa33c4 100644 --- a/dom/animation/test/mozilla/file_discrete-animations.html +++ b/dom/animation/test/mozilla/file_discrete-animations.html @@ -75,11 +75,6 @@ const gMozillaSpecificProperties = { from: "ignore", to: "stretch-to-fit" }, - "-moz-tab-size": { - // https://drafts.csswg.org/css-text-3/#propdef-tab-size - from: "1", - to: "5" - }, "-moz-text-size-adjust": { // https://drafts.csswg.org/css-size-adjust/#propdef-text-size-adjust from: "none", diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 53ce2b30f..977b07538 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -98,11 +98,6 @@ namespace mozilla { namespace dom { -static bool sVibratorEnabled = false; -static uint32_t sMaxVibrateMS = 0; -static uint32_t sMaxVibrateListLen = 0; -static const char* kVibrationPermissionType = "vibration"; - static void AddPermission(nsIPrincipal* aPrincipal, const char* aType, uint32_t aPermission, uint32_t aExpireType, int64_t aExpireTime) @@ -153,12 +148,7 @@ GetPermission(nsIPrincipal* aPrincipal, const char* aType) void Navigator::Init() { - Preferences::AddBoolVarCache(&sVibratorEnabled, - "dom.vibrator.enabled", true); - Preferences::AddUintVarCache(&sMaxVibrateMS, - "dom.vibrator.max_vibrate_ms", 10000); - Preferences::AddUintVarCache(&sMaxVibrateListLen, - "dom.vibrator.max_vibrate_list_len", 128); + // Add any Preferences::Add*VarCache(&sPref, "pref", default) here if needed. } Navigator::Navigator(nsPIDOMWindowInner* aWindow) @@ -706,82 +696,6 @@ Navigator::RefreshMIMEArray() } } -namespace { - -class VibrateWindowListener : public nsIDOMEventListener -{ -public: - VibrateWindowListener(nsPIDOMWindowInner* aWindow, nsIDocument* aDocument) - { - mWindow = do_GetWeakReference(aWindow); - mDocument = do_GetWeakReference(aDocument); - - NS_NAMED_LITERAL_STRING(visibilitychange, "visibilitychange"); - aDocument->AddSystemEventListener(visibilitychange, - this, /* listener */ - true, /* use capture */ - false /* wants untrusted */); - } - - void RemoveListener(); - - NS_DECL_ISUPPORTS - NS_DECL_NSIDOMEVENTLISTENER - -private: - virtual ~VibrateWindowListener() - { - } - - nsWeakPtr mWindow; - nsWeakPtr mDocument; -}; - -NS_IMPL_ISUPPORTS(VibrateWindowListener, nsIDOMEventListener) - -StaticRefPtr<VibrateWindowListener> gVibrateWindowListener; - -static bool -MayVibrate(nsIDocument* doc) { - // Hidden documents cannot start or stop a vibration. - return (doc && !doc->Hidden()); -} - -NS_IMETHODIMP -VibrateWindowListener::HandleEvent(nsIDOMEvent* aEvent) -{ - nsCOMPtr<nsIDocument> doc = - do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget()); - - if (!MayVibrate(doc)) { - // It's important that we call CancelVibrate(), not Vibrate() with an - // empty list, because Vibrate() will fail if we're no longer focused, but - // CancelVibrate() will succeed, so long as nobody else has started a new - // vibration pattern. - nsCOMPtr<nsPIDOMWindowInner> window = do_QueryReferent(mWindow); - hal::CancelVibrate(window); - RemoveListener(); - gVibrateWindowListener = nullptr; - // Careful: The line above might have deleted |this|! - } - - return NS_OK; -} - -void -VibrateWindowListener::RemoveListener() -{ - nsCOMPtr<EventTarget> target = do_QueryReferent(mDocument); - if (!target) { - return; - } - NS_NAMED_LITERAL_STRING(visibilitychange, "visibilitychange"); - target->RemoveSystemEventListener(visibilitychange, this, - true /* use capture */); -} - -} // namespace - void Navigator::AddIdleObserver(MozIdleObserver& aIdleObserver, ErrorResult& aRv) { @@ -810,111 +724,6 @@ Navigator::RemoveIdleObserver(MozIdleObserver& aIdleObserver, ErrorResult& aRv) } } -void -Navigator::SetVibrationPermission(bool aPermitted, bool aPersistent) -{ - MOZ_ASSERT(NS_IsMainThread()); - - nsTArray<uint32_t> pattern; - pattern.SwapElements(mRequestedVibrationPattern); - - if (!mWindow) { - return; - } - - nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc(); - - if (!MayVibrate(doc)) { - return; - } - - if (aPermitted) { - // Add a listener to cancel the vibration if the document becomes hidden, - // and remove the old visibility listener, if there was one. - if (!gVibrateWindowListener) { - // If gVibrateWindowListener is null, this is the first time we've vibrated, - // and we need to register a listener to clear gVibrateWindowListener on - // shutdown. - ClearOnShutdown(&gVibrateWindowListener); - } else { - gVibrateWindowListener->RemoveListener(); - } - gVibrateWindowListener = new VibrateWindowListener(mWindow, doc); - hal::Vibrate(pattern, mWindow); - } - - if (aPersistent) { - AddPermission(doc->NodePrincipal(), kVibrationPermissionType, - aPermitted ? nsIPermissionManager::ALLOW_ACTION : - nsIPermissionManager::DENY_ACTION, - nsIPermissionManager::EXPIRE_SESSION, 0); - } -} - -bool -Navigator::Vibrate(uint32_t aDuration) -{ - AutoTArray<uint32_t, 1> pattern; - pattern.AppendElement(aDuration); - return Vibrate(pattern); -} - -bool -Navigator::Vibrate(const nsTArray<uint32_t>& aPattern) -{ - MOZ_ASSERT(NS_IsMainThread()); - - if (!mWindow) { - return false; - } - - nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc(); - - if (!MayVibrate(doc)) { - return false; - } - - nsTArray<uint32_t> pattern(aPattern); - - if (pattern.Length() > sMaxVibrateListLen) { - pattern.SetLength(sMaxVibrateListLen); - } - - for (size_t i = 0; i < pattern.Length(); ++i) { - pattern[i] = std::min(sMaxVibrateMS, pattern[i]); - } - - // The spec says we check sVibratorEnabled after we've done the sanity - // checking on the pattern. - if (!sVibratorEnabled) { - return true; - } - - mRequestedVibrationPattern.SwapElements(pattern); - uint32_t permission = GetPermission(mWindow, kVibrationPermissionType); - - if (permission == nsIPermissionManager::ALLOW_ACTION || - mRequestedVibrationPattern.IsEmpty() || - (mRequestedVibrationPattern.Length() == 1 && - mRequestedVibrationPattern[0] == 0)) { - // Always allow cancelling vibration and respect session permissions. - SetVibrationPermission(true /* permitted */, false /* persistent */); - return true; - } - - nsCOMPtr<nsIObserverService> obs = services::GetObserverService(); - if (!obs || permission == nsIPermissionManager::DENY_ACTION) { - // Abort without observer service or on denied session permission. - SetVibrationPermission(false /* permitted */, false /* persistent */); - return true; - } - - // Request user permission. - obs->NotifyObservers(ToSupports(this), "Vibration:Request", nullptr); - - return true; -} - //***************************************************************************** // Pointer Events interface //***************************************************************************** diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index bcc67589e..efecdbd0d 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -150,9 +150,6 @@ public: // NavigatorBinding::ClearCachedUserAgentValue(this); void ClearUserAgentCache(); - bool Vibrate(uint32_t aDuration); - bool Vibrate(const nsTArray<uint32_t>& aDuration); - void SetVibrationPermission(bool aPermitted, bool aPersistent); uint32_t MaxTouchPoints(); void GetAppCodeName(nsString& aAppCodeName, ErrorResult& aRv) { diff --git a/dom/base/nsTreeSanitizer.cpp b/dom/base/nsTreeSanitizer.cpp index 323c851c1..471956443 100644 --- a/dom/base/nsTreeSanitizer.cpp +++ b/dom/base/nsTreeSanitizer.cpp @@ -1385,6 +1385,8 @@ nsTreeSanitizer::SanitizeChildren(nsINode* aRoot) nsAutoString styleText; nsContentUtils::GetNodeTextContent(node, false, styleText); + RemoveAllAttributesFromDescendants(elt); + nsAutoString sanitizedStyle; nsCOMPtr<nsIURI> baseURI = node->GetBaseURI(); if (SanitizeStyleSheet(styleText, @@ -1480,6 +1482,17 @@ nsTreeSanitizer::RemoveAllAttributes(nsIContent* aElement) } } +void nsTreeSanitizer::RemoveAllAttributesFromDescendants(mozilla::dom::Element* aElement) { + nsIContent* node = aElement->GetFirstChild(); + while (node) { + if (node->IsElement()) { + mozilla::dom::Element* elt = node->AsElement(); + RemoveAllAttributes(elt); + } + node = node->GetNextNode(aElement); + } +} + void nsTreeSanitizer::InitializeStatics() { diff --git a/dom/base/nsTreeSanitizer.h b/dom/base/nsTreeSanitizer.h index b8700d775..b4a333f61 100644 --- a/dom/base/nsTreeSanitizer.h +++ b/dom/base/nsTreeSanitizer.h @@ -184,6 +184,12 @@ class MOZ_STACK_CLASS nsTreeSanitizer { void RemoveAllAttributes(nsIContent* aElement); /** + * Removes all attributes from the descendants of an element but not from + * the element itself. + */ + void RemoveAllAttributesFromDescendants(mozilla::dom::Element* aElement); + + /** * The whitelist of HTML elements. */ static nsTHashtable<nsISupportsHashKey>* sElementsHTML; diff --git a/dom/tests/mochitest/general/mochitest.ini b/dom/tests/mochitest/general/mochitest.ini index 9f2fad785..67c35f01a 100755 --- a/dom/tests/mochitest/general/mochitest.ini +++ b/dom/tests/mochitest/general/mochitest.ini @@ -122,7 +122,6 @@ run-if = e10s [test_storagePermissionsReject.html] [test_storagePermissionsRejectForeign.html] [test_stylesheetPI.html] -[test_vibrator.html] [test_WebKitCSSMatrix.html] [test_windowedhistoryframes.html] [test_windowProperties.html] diff --git a/dom/tests/mochitest/general/test_vibrator.html b/dom/tests/mochitest/general/test_vibrator.html deleted file mode 100644 index 2874c783b..000000000 --- a/dom/tests/mochitest/general/test_vibrator.html +++ /dev/null @@ -1,93 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test for Vibrator</title> - <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> - -<!-- Although we can't test that the vibrator works properly, we can test that - navigator.vibrate throws an exception where appropriate. --> - -<script class="testbody" type="text/javascript;version=1.7"> -SimpleTest.waitForExplicitFinish(); -var result; -function expectFailure(param) { - result = navigator.vibrate(param); - is(result, false, 'vibrate(' + param + ') should have failed.'); -} - -function expectSuccess(param) { - result = navigator.vibrate(param); - is(result, true, 'vibrate(' + param + ') must succeed.'); -} - -function tests(aEnabled) { - // Some edge cases that the bindings should handle for us. - expectSuccess(null); - expectSuccess(undefined); - // -1 will be converted to the highest unsigned long then clamped. - expectSuccess(-1); - expectSuccess('a'); - // -1 will be converted to the highest unsigned long then clamped. - expectSuccess([100, -1]); - expectSuccess([100, 'a']); - - var maxVibrateMs = SpecialPowers.getIntPref('dom.vibrator.max_vibrate_ms'); - var maxVibrateListLen = SpecialPowers.getIntPref('dom.vibrator.max_vibrate_list_len'); - - // If we pass a vibration pattern with a value higher than max_vibrate_ms or a - // pattern longer than max_vibrate_list_len, the call should succeed but the - // pattern should be modified to match the restrictions. - - // Values will be clamped to dom.vibrator.max_vibrate_ms. - expectSuccess(maxVibrateMs + 1); - expectSuccess([maxVibrateMs + 1]); - - var arr = []; - for (var i = 0; i < maxVibrateListLen + 1; i++) { - arr[i] = 0; - } - // The array will be truncated to have a length equal to dom.vibrator.max_vibrate_list_len. - expectSuccess(arr); - - - expectSuccess(0); - expectSuccess([]); - expectSuccess('1000'); - expectSuccess(1000); - expectSuccess(1000.1); - expectSuccess([0, 0, 0]); - expectSuccess(['1000', 1000]); - expectSuccess([1000, 1000]); - expectSuccess([1000, 1000.1]); - - // The following loop shouldn't cause us to crash. See bug 701716. - for (var i = 0; i < 10000; i++) { - navigator.vibrate([100, 100]); - } - ok(true, "Didn't crash after issuing a lot of vibrate() calls."); - if(!aEnabled) - SimpleTest.finish(); -} - -SpecialPowers.pushPermissions([ - {type: 'vibration', allow: true, context: document} - ], function() { - // Test with the vibrator pref enabled. - SpecialPowers.pushPrefEnv({"set": [['dom.vibrator.enabled', true]]}, function() { - tests(true); - SpecialPowers.pushPrefEnv({"set": [['dom.vibrator.enabled', false]]}, tests(false)); - }); - // Everything should be the same when the vibrator is disabled -- in - // particular, a disabled vibrator shouldn't eat failures we'd otherwise - // observe. - } -); - -</script> -</body> - -</html> diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index f34429de7..43d53cbac 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -13,9 +13,9 @@ * http://www.w3.org/TR/beacon/#sec-beacon-method * https://html.spec.whatwg.org/#navigatorconcurrenthardware * - * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and - * Opera Software ASA. You are granted a license to use, reproduce - * and create derivative works of this document. + * © Copyright 2004-2020 Apple Computer, Inc., Mozilla Foundation, + * Opera Software ASA and Moonchild Productions. You are granted a license to use, + * reproduce and create derivative works of this document. */ // http://www.whatwg.org/specs/web-apps/current-work/#the-navigator-object @@ -124,14 +124,6 @@ interface NavigatorGeolocation { }; Navigator implements NavigatorGeolocation; -// http://www.w3.org/TR/vibration/#vibration-interface -partial interface Navigator { - // We don't support sequences in unions yet - //boolean vibrate ((unsigned long or sequence<unsigned long>) pattern); - boolean vibrate(unsigned long duration); - boolean vibrate(sequence<unsigned long> pattern); -}; - // http://www.w3.org/TR/pointerevents/#extensions-to-the-navigator-interface partial interface Navigator { [Pref="dom.w3c_pointer_events.enabled"] @@ -140,17 +132,6 @@ partial interface Navigator { // Mozilla-specific extensions -// Chrome-only interface for Vibration API permission handling. -partial interface Navigator { - /* Set permission state to device vibration. - * @param permitted permission state (true for allowing vibration) - * @param persistent make the permission session-persistent - */ - [ChromeOnly] - void setVibrationPermission(boolean permitted, - optional boolean persistent = true); -}; - callback interface MozIdleObserver { // Time is in seconds and is read only when idle observers are added // and removed. |