import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1040668 part 2 - Parse and compute text emphasis properties. r=dbaron (0fb79d4709)
- Bug 1040668 part 3 - Add helper function gfxTextRun::GetAdvanceForGlyph. r=jfkthame (f1cf02f5ff)
- Bug 1216427 - Tests for backspacing over a character with variation selector, and over Regional Indicator flag symbols. r=emk (18957bfe77)
- Bug 1216427 - part 1 - Ensure a character+VS sequence or a ligated Regional-Indicator flag symbol is deleted as a single unit when backspacing. r=emk (2776ff8f4a)
- Bug 1216427 - part 2 - Ensure mouse selection does not split up a Regional Indicator flag symbol. r=emk (58eb82e6a1)
- Bug 1040668 part 4 - Add helper function for ensuring a glyph is a complex glyph. r=jfkthame (ba17f7d0c4)
- Bug 1040668 part 5 - Avoid unnecessary allocation inside EnsureComplexGlyph helper function. r=jfkthame (4968a7c68e)
- Bug 1040668 part 6 - Add some specifier on gfxTextRun and gfxShapedWord so that compilers are able to reason out certain optimizations. r=jfkthame (69ca3eb959)
- Bug 1040668 part 7 - Add NO_EMPHASIS_MARK flag in CompressedGlyph. r=jfkthame (34e9d8a6a6)
- Bug 1227001 part 1 - Remove SetupBreakSinksFlags from BuildTextRunsScanner. r=jfkthame (520b1ba111)
- Bug 1227001 part 2 - Remove no longer used mExistingTextRun from BreaSink. r=jfkthame (201782a78c)
- Bug 1227001 part 3 - Remove no longer used mChangedBreaks from BreakSink. r=jfkthame (e754e2b13f)
- Bug 1040668 part 8 - Setup text emphasis for text run. r=jfkthame (376377180e)
- Bug 1040668 part 9 - Compute overflow from text-shadow after text decorations. r=dbaron (05c9bd08c2)
- Bug 1040668 part 10 - Implement emphasis mark rendering. r=jfkthame (4d270afca8)
- Bug 1040668 part 11 - Move line leadings adjusting code into a separate function in nsLineLayout. r=dholbert (fd4dd20ca5)
- Bug 1040668 part 12 - Add line leadings for emphasis marks if necessary. r=dholbert (138add5ff7)
- Bug 1040668 part 13 - Move first part of nsStyleFont::GetLanguage to nsPresContext::GetContentLanguage. r=dbaron (1e872d2a58)
- Bug 1040668 part 14 - Add helper function nsStyleUtil::MatchesLanguagePrefix for doing simple language matching. r=dbaron (9322a02369)
- Bug 1040668 part 15 - Make the default value of text-emphasis-position aware of the language. r=dbaron (6587c628da)
- Bug 1040668 part 16 - Add reftests for text-emphasis. r=dbaron (9940d65182)
- Bug 1040668 followup - Use monospace for text-emphasis reftests. rs=dbaron on a CLOSED TREE (fb7598c3ea)
- Bug 1040668 followup 2 - Disable failing reftests of text-emphasis on Windows XP. (7c3f24ac22)
- Bug 1040668 followup 3 - Wrap lang attribute mapping code in NS_STYLE_INHERIT_BIT test. r=dbaron (640e3b7b8f)
- Bug 1219145 - nsRefreshDriver::IsJankCritical(). r=hiro To refine its alerts, Performance Stats API needs to be able to know whether a long-running operation is actually causing user-visible jank in the current process. This patch introduces a trivial API that lets clients ask the refresh driver whether any kind of animation is ongoing. (7c0868d7c4)
- more missing XP theme stuff (637af0c6a0)
- Bug 1210261. Tick root refresh driver last. r=mattwoodrow (dae1a325fa)
- Bug 1221674 Part 2: Correct for negative content delay values. r=avih (9b9811c41c)
- Bug 1211334 - Check if presshell is still available after dispatching transition events; r=mats (8a044a462c)
- Bug 1211599 - Only allow whitelisted histograms to have > 100 buckets. r=nfroyd (d467e84130)
- Bug 1219733 - Allow a 'bug_numbers' field in Histograms.json entries. r=vladan (8e63a713ec)
- Bug 1222044 - Only allow lists of alert_emails r=vladan (1d5fcb009d)
- Bug 1168263 - Add a flags parameter to GetResultingTransformMatrix instead of using bools. r=roc (ec5224f9af)
- Bug 1168263 - Remove TransformRectOut since it's unused. r=roc (d20a79ae0e)
- Bug 1215406 - Part 1: Remove NS_STYLE_ANIMATION_DIRECTION_XXX and NS_STYLE_ANIMATION_FILL_MODE_XXX. r=heycam (4bd7f8116b)
- Bug 1215406 - Part 2: Change the types of direction and fillmode in StyleAnimation. r=heycam (e06323c81b)
- Bug 1215406 - Part 3: Change the types of direction and fillmode in AnimationTiming. r=heycam (e5454d3ea5)
- Bug 1215406 - Part 4: Add KeyframeEffectOptions. r=smaug Add KeyframeEffectOptions in KeyframeEffect.webidl (0ce3372fd1)
- Bug 1215406 - Part 5: Implement KeyframeEffectOptions in KeyframeEffectReadOnly constructor. r=birtles (a472e9ac5f)
- tch 2 - Use an enum class for NS_STYLE_BOX_SIZING_*. r=heycam (4897b7b8ff)
- Bug 1218195, mark MutationObserver as observing in all the nested DOM mutations, r=bz (48a4aa8a91)
- Bug 1172870 - Part 3 - Fix openWindow mochitest to work on e10s (574cc6fa4d)
- Bug 1223265 - Fix -Wunreachable-code and -Wimplicit-fallthrough warnings in dom/bindings and dom/ipc. r=khuey (9eab632140)
- Bug 1189195 - Fix PContentPermissionRequest shutdown () r=fabrice (6bc1a681f5)
- Bug 1210508 - Handle null OriginAttributes from JS-implemented nsILoadContext. r=me (2f71edb9d7)
- Bug 1224596 part 1. Add a version of WorkerMainThreadRunnable::Dispatch that takes an ErrorResult to report failure to dispatch on. r=khuey (e60a0fb115)
- Bug 1224596 part 2. Switch Navigator to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey (d9298a4763)
- Bug 1224596 part 3. Make some WebSocket(Impl) methods whose return value is totally ignored void. r=khuey (1d04b52d44)
- Bug 1224596 part 4. Switch WebSocket to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey (aa06e6417b)
- Bug 1224596 part 5. Switch nsPerformance to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey (0303b7de09)
- Bug 1224596 part 6. Switch BroadcastChannel to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey (feacc21f63)
- Bug 1224636. Fix some code in ImageBitmap that rejects a promise with an ErrorResult, then keeps trying to use that ErrorResult. r=kaku (89b769fe07)
- Bug 1224596 part 7. Switch ImageBitmap to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey (e21b0a4a0a)
- Bug 1183954, Don't leak nsStructuredCloneContainer (use of 'auto' is error prone), r=leak (1a9b30f2ca)
- Bug 1114554 - Patch 9 - Fixed crash in b2g-desktop tests. r=nsm (6b12c6d121)
- Bug 1189090 - Rework the nsISupports implementation in the ScopeCheckingGetCallback and its subclasses; r=nsm (6bea544597)
- Bug 1187018 - Ensure feature is nulled out if it does not get added. r=khuey (9d7439498a)
- Bug 1224596 part 8. Switch Notification to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey (03f0f6877f)
- Bug 1196079 - Always try to release Notification via normal WorkerRunnable first. r=wchen (c093253d6f)
- Bug 1203324 - disable notifications on serviceworkers. r=ehsan,wchen (aa39310dc1)
- Bug 1199901 - GetOrigin() fails cleanly instead of asserting principal. r=wchen (148c634a4f)
- Bug 1199901 - Clear mObserver when WorkerNotificationObserver is destroyed. r=wchen (6d5cd99183)
- Bug 1199901 - Bustage fix due to rebase. a=bustage (344bd62af5)
- Bug 1225470 Report a message to the console when a service worker waitUntil() is rejected. r=baku (610da2eec6)
- Bug 1217909 P1 Report service worker exceptions to controlled documents. r=catalinb (f8bd4677d5)
- Bug 1216566 - Fix a bug in nsIServiceWorkerManager.getAllRegistrations;r=catalinb (ed3e14ab43)
- Bug 1219205 - ServiceWorkerInfo should be an XPCOM object;r=catalinb (677a6f1ffd)
- Bug 1217909 P2 Track registering documents as weak reference so SWM can report errors to them. r=catalinb (4233dc3edc)
- Bug 1217909 P3 Refactor service worker register()/update() to reject only with SecurityErr or TypeErr. r=catalinb (c6891a7fae)
- Bug 1220740 - nsIServiceWorkerRegistrationInfo should emit an event when its scriptSpec property changes;r=amarchesini (5772bb5914)
- Bug 1207727 - Add WPT tests for service worker update algorithm. r=bkelly (a4812571a1)
- Bug 1217367 - Service workers update algorithm optimization. r=bkelly (e377debad1)
- Bug 1226479. Change ErrorResult::ThrowTypeError/ThrowRangeError to take string references, not pointers. r=mccr8 (0804899666)
- Bug 1224659 - Worker DataStore code should not use ErrorResult cross threads, r=bz (aef03b0fdd)
- Bug 1224596 part 9. Switch DataStore to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey (1eb1c427f2)
- Bug 1224596 part 10. Switch DataStoreCursor to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey (114af8021b)
- Bug 1224596 part 11. Switch WorkerNavigator to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey (b2347a0c49)
- Bug 1224596 part 12. Switch ServiceWorkerRegistration to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey (d1ff076836)
- Bug 1224596 part 13. Switch gfxUtils to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey (a523997588)
- Bug 1224007 part 1. Rename ThrowMethodFailed to MaybeSetPendingException and make it an ErrorResult instance method. r=peterv (bdf0891f54)
- Bug 1224007 part 2. Make the various ErrorResult::Report* methods private, so consumers all go through MaybeSetPendingException and rename them to more clearly indicate what they're actually doing. r=peterv (48f483c153)
- Bug 1203151 - Allow disabling of screen wakelocks for video elements. r=baku (6bd9ff6916)
- Bug 1224007 part 4. Fix some cases in which ErrorResult instances are destroyed without doing anything useful with exceptions on them. r=peterv (e328785e5d)
- Bug 1224007 part 5. Get rid of ErrorResult::StealJSException. r=peterv (db19cfb31e)
- Bug 1224007 part 3. Push down WouldReportJSException into MaybeSetPendingException, since anyone calling the latter will propagate the JS exception as needed. r=peterv (1d3b7b415d)
- Bug 1224007 part 6. Change MaybeSetPendingException to set the ErrorResult state to "not failed", just like SuppressException and StealNSResult already do, and assert in the destructor that the ErrorResult is not Failed(). (a028838e8d)
- Bug 1213815 - Update URLSearchParams and URLUtils in webidl files, r=bz (28fb8f7de5)
- Bug 1213815 - dom/webidl/HTMLHyperlinkElementUtils and URL don't need to throw exceptions as we did before, r=bz (b13dc3bcb9)
- Bug 1224596 part 14. Switch URL to using the new WorkerMainThreadRunnable::Dispatch signature. r=baku (232677e50e)
- fix updating the backport (9e958da5ca)
- Bug 1224596 part 16. Switch Fetch to using the new WorkerMainThreadRunnable::Dispatch signature. r=bkelly (939e338f22)
- Bug 1224596 part 17. Remove the old WorkerMainThreadRunnable::Dispatch signature. r=khuey (5a70429ec8)
- Bug 1143575. Don't report negative frame delays. r=cpearce (7d8bc0f753)
- Bug 1187371 - Get rid of dom.broadcastChannel.enabled pref, r=bz (9335b7ae90)
- Bug 1196514 - remove dom.messagechannel.enabled pref, r=smaug (31e06119b4)
- Bug 1166356 - Properly detect double-caching in nsXULPrototypeCache; r=ehsan (29df9ffb2d)
- Bug 1168916 - Get rid of redundant pref callback in nsXULPrototypeCache; r=janv (9f37fff405)
- Bug 1139099: Dispatch DOMDocElementInserted to match the document-element-inserted observer notification. r=mrbkap (6565e4b924)
- Bug 1187068 - Tell the cycle collector about nsContentSink::mCSSLoader. r=heycam (4ae23eb26c)
- Bug 1172189 - Fix overflow in nsXULContentSink.cpp. r=ehsan (cc6330f5de)
- Bug 1126010 - XULContentSinkImpl::mParser should be an nsRefPtr. r=smaug (d6bb567692)
- Bug 1147946, part 7 - Remove trailing whitespace from nsXULContentSink.cpp. r=baku (cdcadbfeeb)
- Bug 1147946, part 1 - Tuck elses in nsXULContentSink.cpp. r=baku (26fd806676)
- Bug 1147946, part 2 - Move body of check inside prior if in XULContentSinkImpl::OpenScript(). r=baku (b509455bdb)
- Bug 1147946, part 3 - Eliminate unused case for non-JS scripting languages in XULContentSinkImpl::OpenScript(). r=baku (4136933cc2)
- Bug 1147946, part 4 - Use an early return in XULContentSinkImpl::OpenScript(). r=baku (c3e293474b)
- Bug 1147946, part 5 - Don't use the generic nsIProgrammingLanguage enum in XULContentSinkImpl::OpenScript(). r=baku (89a124e23f)
- Bug 1147946, part 6 - Remove some useless null checks on infallible new in XULContentSinkImpl. r=baku (1ac57e8c3a)
- Bug 1221351 P1 ServiceWorkerContainer and ServiceWorkerRegistration should not crash for null window owner. r=catalinb (1a72748632)
- Bug 1212867 - Node.isEqualNode() should ignore internal subsets; r=bzBug (99b166ffee)
- Bug 492933 - getElementsByTagName should match on localName not tagName, r=smaug (d0c6ceabf1)
- Bug 912470 part 1 - Implement Encoding Standard-compliant big5 decoder. r=emk. (c680b0ae9b)
- Bug 1170932: Test handling of unmapped characters in unicode-to-codepage encoders (ca36bcbd35)
- fix style (95a90bfe3a)
- Bug 1170794 - patch 2 - Improve the length check of the input in nsUnicode*::GetMaxLength, r=dveditz (aa864d656f)
- Bug 1170794 followup: Add 'override' annotations to Convert() & Reset() methods in intl/uconv. rs=ehsan (bb3e6e492e)
- Bug 1176462 - Remove nsTableDecoderSupport. r=smontagu (f4a86c44b3)
- Bug 1169248 - Fix GBK/GB18030 encoders. r=smontagu (ed946e1ee1)
- Bug 1155539 - Remove obsolete encoding decoder telemetry probes. r=emk. (44e15bfb40)
- Bug 912470 part 2 - Implement Encoding Standard-compliant big5 encoder. r=emk. (5cca2dc4a0)
- Bug 912470 addendum - Pass override static analysis. r=emk. (c163bffeb4)
- Bug 1170932: Improve error handling for the gbk encoder, r=emk (30e95b34a5)
- Bug 1202366 - Implement the encoder error mode "HTML" for nsFormSubmission without nsISaveAsCharset. r=NOT_emk. (ebc8b542dd)
- update manifest (6cc19172cc)
- Bug 1197309 - remove PR_snprintf calls in intl/; r=froydnj (79fcdfa845)
- Bug 1214619 - Remove nsISaveAsCharset as much as possible without breaking extensions in popular use. r=emk. (89b71b3d87)
- Bug 1214857. Store the document-is-HTML state directly in nsContentList instead of refetching from the node being matched. r=smaug (4c4fbf469e)
- Bug 1221351 P2 Add a web-platform-test to check for crash when calling .register() on closed window. r=catalinb (eeb30c1bba)
- Bug 1221351 P3 Fix test name in register-closed-window.https.html. a=testonly (5bfa840044)
- Bug 1224436: Remove enumerator usage in ServiceWorkerManager.cpp. r=njn (b8cb094d3c)
- Bug 1223716. Make HTMLCollection check for the element being HTML before checking for its name inside its named getter. r=bkelly (977e0bff5a)
- Bug 1180737 - Add update-test.py and update test to latest version. r=bkelly. (59faa36d5c)
- Bug 1217909 P4 Extend wpt tests to verify update() promise values for different script failures. r=catalinb (a2f7352a3a)
- Bug 1217909 P5 Add wpt test case for fetch event handlers that throw. r=catalinb (56a77f611c)
- Bug 1217909 P6 Fix wpt registration.https.html to expect TypeError for script evaluation errors. r=catalinb (3de8a45688)
- Bug 1217909 P7 Fix mochitest to expect TypeError when serviceWorker.register() rejects. r=catalinb (6e8841c41e)
- Bug 1217909 P8 Track navigation interceptions per scope in ServiceWorkerManager. r=catalinb (6705ba8337)
- Bug 1217909 P9 Report exceptions to windows performing an intercepted navigation. r=catalinb (52f9fece14)
- Bug 1217909 P10 Remove stale nsTArray when the last registering document for a scope is removed. r=catalinb (b739bcc3b2)
- Bug 1217909 P11 Only report errors to documents that are active and not in the bfcache. r=catalinb (5ffd633af2)
- Bug 1223378 Tighten service worker register() principal checks. r=baku (478785f2cc)
- Bug 1189685 - Part 1: Ensure that the state of all ServiceWorker instances is up to date when dispatching statechange events; r=bkelly (2bd9b78c58)
- Bug 1189685 - Part 2: Make synced-state.https.html pass; r=bkelly (029f942d8c)
- Bug 1220740 - nsIServiceWorkerRegistrationInfo should emit an event when its worker properties change;r=amarchesini (8243a3debc)
- Bug 1186856 ServiceWorker .register() should always stop current registration from uninstalling. r=jdm (ec7d6e0e7c)
- Bug 1224941 Don't crash during ServiceWorker life cycle event dispatch if window is gone. r=baku (a3f45af3e4)
- Bug 1180754 - Get serviceworkerobject-scripturl test passing. r=bkelly (c7979bef47)
- Bug 1201498 - Service worker update should compare scriptURL to worker URL without fragment, r=bkelly (914f630528)
- Bug 594505 - Remove obsolete comment since this bug has now been fixed. r=me DONTBUILD (44f3a15b91)
- Bug 1221840. Support repeating images in 1 axis. r=seth (449ea3e97e)
- const-var (5433688051)
- Bug 1574573 - Disambiguate a use of Handle in XPCShellEnvironment.cpp r=Ehsan (15b44177d1)
- clean up warnings (6e64313d0c)
This commit is contained in:
2023-02-14 09:56:52 +08:00
parent 1c5d25a761
commit fffeb135bb
501 changed files with 31667 additions and 48362 deletions
-3
View File
@@ -1074,9 +1074,6 @@ pref("services.mobileid.server.uri", "https://msisdn.services.mozilla.com");
pref("dom.mapped_arraybuffer.enabled", true);
#endif
// BroadcastChannel API
pref("dom.broadcastChannel.enabled", true);
// SystemUpdate API
pref("dom.system_update.enabled", true);
+2 -2
View File
@@ -109,9 +109,9 @@ this.AboutServiceWorkers = {
let registrations = [];
for (let i = 0; i < data.length; i++) {
let info = data.queryElementAt(i, Ci.nsIServiceWorkerInfo);
let info = data.queryElementAt(i, Ci.nsIServiceWorkerRegistrationInfo);
if (!info) {
dump("AboutServiceWorkers: Invalid nsIServiceWorkerInfo " +
dump("AboutServiceWorkers: Invalid nsIServiceWorkerRegistrationInfo " +
"interface.\n");
continue;
}
+2 -2
View File
@@ -23,7 +23,7 @@ interface nsIDOMElement;
* can be queried for various information about where the load is
* happening.
*/
[scriptable, uuid(1220e340-b337-4c35-aaa1-f51362763621)]
[scriptable, uuid(96014778-d30b-4fee-8902-a3481788907b)]
interface nsILoadContext : nsISupports
{
/**
@@ -148,7 +148,7 @@ interface nsILoadContext : nsISupports
JS::Rooted<JS::Value> v(jsapi.cx());
nsresult rv = GetOriginAttributes(&v);
NS_ENSURE_SUCCESS(rv, false);
MOZ_ASSERT(v.isObject());
NS_ENSURE_TRUE(v.isObject(), false);
JS::Rooted<JSObject*> obj(jsapi.cx(), &v.toObject());
// If we're JS-implemented, the object will be left in a different (System-Principaled)
+76 -56
View File
@@ -5,6 +5,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/KeyframeEffect.h"
#include "mozilla/dom/AnimationEffectReadOnlyBinding.h"
#include "mozilla/dom/KeyframeEffectBinding.h"
#include "mozilla/dom/PropertyIndexedKeyframesBinding.h"
@@ -22,43 +23,21 @@
namespace mozilla {
bool
AnimationTiming::FillsForwards() const
{
return mFillMode == dom::FillMode::Both ||
mFillMode == dom::FillMode::Forwards;
}
bool
AnimationTiming::FillsBackwards() const
{
return mFillMode == dom::FillMode::Both ||
mFillMode == dom::FillMode::Backwards;
}
// Helper functions for generating a ComputedTimingProperties dictionary
static dom::FillMode
ConvertFillMode(uint8_t aFill)
{
switch (aFill) {
case NS_STYLE_ANIMATION_FILL_MODE_NONE:
return dom::FillMode::None;
case NS_STYLE_ANIMATION_FILL_MODE_FORWARDS:
return dom::FillMode::Forwards;
case NS_STYLE_ANIMATION_FILL_MODE_BACKWARDS:
return dom::FillMode::Backwards;
case NS_STYLE_ANIMATION_FILL_MODE_BOTH:
return dom::FillMode::Both;
default:
MOZ_ASSERT(false, "The mapping of FillMode is not correct");
return dom::FillMode::None;
}
}
static dom::PlaybackDirection
ConvertPlaybackDirection(uint8_t aDirection)
{
switch (aDirection) {
case NS_STYLE_ANIMATION_DIRECTION_NORMAL:
return dom::PlaybackDirection::Normal;
case NS_STYLE_ANIMATION_DIRECTION_REVERSE:
return dom::PlaybackDirection::Reverse;
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE:
return dom::PlaybackDirection::Alternate;
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE_REVERSE:
return dom::PlaybackDirection::Alternate_reverse;
default:
MOZ_ASSERT(false, "The mapping of PlaybackDirection is not correct");
return dom::PlaybackDirection::Normal;
}
}
static void
GetComputedTimingDictionary(const ComputedTiming& aComputedTiming,
const Nullable<TimeDuration>& aLocalTime,
@@ -67,10 +46,10 @@ GetComputedTimingDictionary(const ComputedTiming& aComputedTiming,
{
// AnimationEffectTimingProperties
aRetVal.mDelay = aTiming.mDelay.ToMilliseconds();
aRetVal.mFill = ConvertFillMode(aTiming.mFillMode);
aRetVal.mFill = aTiming.mFillMode;
aRetVal.mIterations = aTiming.mIterationCount;
aRetVal.mDuration.SetAsUnrestrictedDouble() = aTiming.mIterationDuration.ToMilliseconds();
aRetVal.mDirection = ConvertPlaybackDirection(aTiming.mDirection);
aRetVal.mDirection = aTiming.mDirection;
// ComputedTimingProperties
aRetVal.mActiveDuration = aComputedTiming.mActiveDuration.ToMilliseconds();
@@ -126,6 +105,18 @@ KeyframeEffectReadOnly::WrapObject(JSContext* aCx,
return KeyframeEffectReadOnlyBinding::Wrap(aCx, this, aGivenProto);
}
IterationCompositeOperation
KeyframeEffectReadOnly::IterationComposite() const
{
return IterationCompositeOperation::Replace;
}
CompositeOperation
KeyframeEffectReadOnly::Composite() const
{
return CompositeOperation::Replace;
}
void
KeyframeEffectReadOnly::SetTiming(const AnimationTiming& aTiming)
{
@@ -271,18 +262,20 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
bool thisIterationReverse = false;
switch (aTiming.mDirection) {
case NS_STYLE_ANIMATION_DIRECTION_NORMAL:
case PlaybackDirection::Normal:
thisIterationReverse = false;
break;
case NS_STYLE_ANIMATION_DIRECTION_REVERSE:
case PlaybackDirection::Reverse:
thisIterationReverse = true;
break;
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE:
case PlaybackDirection::Alternate:
thisIterationReverse = (result.mCurrentIteration & 1) == 1;
break;
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE_REVERSE:
case PlaybackDirection::Alternate_reverse:
thisIterationReverse = (result.mCurrentIteration & 1) == 0;
break;
default:
MOZ_ASSERT(true, "Unknown PlaybackDirection type");
}
if (thisIterationReverse) {
result.mProgress.SetValue(1.0 - result.mProgress.Value());
@@ -554,25 +547,52 @@ DumpAnimationProperties(nsTArray<AnimationProperty>& aAnimationProperties)
}
#endif
// Extract an iteration duration from an UnrestrictedDoubleOrXXX object.
template <typename T>
static TimeDuration
GetIterationDuration(const T& aDuration) {
// Always return the same object to benefit from return-value optimization.
TimeDuration result;
if (aDuration.IsUnrestrictedDouble()) {
double durationMs = aDuration.GetAsUnrestrictedDouble();
if (!IsNaN(durationMs) && durationMs >= 0.0f) {
result = TimeDuration::FromMilliseconds(durationMs);
}
}
// else, aDuration should be zero
return result;
}
/* static */ AnimationTiming
KeyframeEffectReadOnly::ConvertKeyframeEffectOptions(
const Optional<double>& aOptions)
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions)
{
AnimationTiming animationTiming;
// The spec says to treat auto durations as 0 until a later version of
// the spec says otherwise. Bug 1215406 is for handling a
// KeyframeEffectOptions object and not just an offset.
if (aOptions.WasPassed()) {
animationTiming.mIterationDuration =
TimeDuration::FromMilliseconds(aOptions.Value());
} else {
animationTiming.mIterationDuration = TimeDuration(0);
}
animationTiming.mIterationCount = 1.0f;
animationTiming.mDirection = NS_STYLE_ANIMATION_DIRECTION_NORMAL;
animationTiming.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_NONE;
if (aOptions.IsKeyframeEffectOptions()) {
const KeyframeEffectOptions& opt = aOptions.GetAsKeyframeEffectOptions();
animationTiming.mIterationDuration = GetIterationDuration(opt.mDuration);
animationTiming.mDelay = TimeDuration::FromMilliseconds(opt.mDelay);
// FIXME: Covert mIterationCount to a valid value.
// Bug 1214536 should revise this and keep the original value, so
// AnimationTimingEffectReadOnly can get the original iterations.
animationTiming.mIterationCount = (IsNaN(opt.mIterations) ||
opt.mIterations < 0.0f) ?
1.0f :
opt.mIterations;
animationTiming.mDirection = opt.mDirection;
// FIXME: We should store original value.
animationTiming.mFillMode = (opt.mFill == FillMode::Auto) ?
FillMode::None :
opt.mFill;
} else {
animationTiming.mIterationDuration = GetIterationDuration(aOptions);
animationTiming.mDelay = TimeDuration(0);
animationTiming.mIterationCount = 1.0f;
animationTiming.mDirection = PlaybackDirection::Normal;
animationTiming.mFillMode = FillMode::None;
}
return animationTiming;
}
@@ -1600,7 +1620,7 @@ KeyframeEffectReadOnly::Constructor(
const GlobalObject& aGlobal,
Element* aTarget,
const Optional<JS::Handle<JSObject*>>& aFrames,
const Optional<double>& aOptions,
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
ErrorResult& aRv)
{
if (!aTarget) {
+22 -22
View File
@@ -37,6 +37,9 @@ class AnimValuesStyleRule;
namespace dom {
struct ComputedTimingProperties;
class UnrestrictedDoubleOrKeyframeEffectOptions;
enum class IterationCompositeOperation : uint32_t;
enum class CompositeOperation : uint32_t;
}
/**
@@ -51,17 +54,11 @@ struct AnimationTiming
TimeDuration mIterationDuration;
TimeDuration mDelay;
float mIterationCount; // mozilla::PositiveInfinity<float>() means infinite
uint8_t mDirection;
uint8_t mFillMode;
dom::PlaybackDirection mDirection;
dom::FillMode mFillMode;
bool FillsForwards() const {
return mFillMode == NS_STYLE_ANIMATION_FILL_MODE_BOTH ||
mFillMode == NS_STYLE_ANIMATION_FILL_MODE_FORWARDS;
}
bool FillsBackwards() const {
return mFillMode == NS_STYLE_ANIMATION_FILL_MODE_BOTH ||
mFillMode == NS_STYLE_ANIMATION_FILL_MODE_BACKWARDS;
}
bool FillsForwards() const;
bool FillsBackwards() const;
bool operator==(const AnimationTiming& aOther) const {
return mIterationDuration == aOther.mIterationDuration &&
mDelay == aOther.mDelay &&
@@ -183,7 +180,7 @@ public:
Constructor(const GlobalObject& aGlobal,
Element* aTarget,
const Optional<JS::Handle<JSObject*>>& aFrames,
const Optional<double>& aOptions,
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
ErrorResult& aRv);
Element* GetTarget() const {
// Currently we never return animations from the API whose effect
@@ -206,12 +203,14 @@ public:
aPseudoType = mPseudoType;
}
const AnimationTiming& Timing() const {
return mTiming;
}
AnimationTiming& Timing() {
return mTiming;
IterationCompositeOperation IterationComposite() const;
CompositeOperation Composite() const;
void GetSpacing(nsString& aRetVal) const {
aRetVal.AssignLiteral("distribute");
}
const AnimationTiming& Timing() const { return mTiming; }
AnimationTiming& Timing() { return mTiming; }
void SetTiming(const AnimationTiming& aTiming);
Nullable<TimeDuration> GetLocalTime() const;
@@ -292,13 +291,14 @@ protected:
void ResetIsRunningOnCompositor();
static AnimationTiming ConvertKeyframeEffectOptions(
const Optional<double>& aOptions);
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions);
static void BuildAnimationPropertyList(
JSContext* aCx,
Element* aTarget,
const Optional<JS::Handle<JSObject*>>& aFrames,
InfallibleTArray<AnimationProperty>& aResult,
ErrorResult& aRv);
JSContext* aCx,
Element* aTarget,
const Optional<JS::Handle<JSObject*>>& aFrames,
InfallibleTArray<AnimationProperty>& aResult,
ErrorResult& aRv);
nsCOMPtr<Element> mTarget;
RefPtr<Animation> mAnimation;
+1 -1
View File
@@ -37,7 +37,7 @@ ArchiveReader::Constructor(const GlobalObject& aGlobal,
nsAutoCString encoding;
if (!EncodingUtils::FindEncodingForLabelNoReplacement(aOptions.mEncoding,
encoding)) {
aError.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(&aOptions.mEncoding);
aError.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(aOptions.mEncoding);
return nullptr;
}
+1 -5
View File
@@ -37,6 +37,7 @@
#include "mozilla/dom/WindowBinding.h"
#include "mozilla/dom/ElementBinding.h"
#include "Units.h"
#include "nsContentListDeclarations.h"
class nsIFrame;
class nsIDOMMozNamedAttrMap;
@@ -61,11 +62,6 @@ namespace dom {
} // namespace mozilla
already_AddRefed<nsContentList>
NS_GetContentList(nsINode* aRootNode,
int32_t aMatchNameSpaceId,
const nsAString& aTagname);
#define ELEMENT_FLAG_BIT(n_) NODE_FLAG_BIT(NODE_TYPE_SPECIFIC_BITS_OFFSET + (n_))
// Element-specific flags
+19 -90
View File
@@ -130,7 +130,7 @@ Link::GetURI() const
}
void
Link::SetProtocol(const nsAString &aProtocol, ErrorResult& aError)
Link::SetProtocol(const nsAString &aProtocol)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@@ -149,7 +149,7 @@ Link::SetProtocol(const nsAString &aProtocol, ErrorResult& aError)
}
void
Link::SetPassword(const nsAString &aPassword, ErrorResult& aError)
Link::SetPassword(const nsAString &aPassword)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@@ -162,7 +162,7 @@ Link::SetPassword(const nsAString &aPassword, ErrorResult& aError)
}
void
Link::SetUsername(const nsAString &aUsername, ErrorResult& aError)
Link::SetUsername(const nsAString &aUsername)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@@ -175,7 +175,7 @@ Link::SetUsername(const nsAString &aUsername, ErrorResult& aError)
}
void
Link::SetHost(const nsAString &aHost, ErrorResult& aError)
Link::SetHost(const nsAString &aHost)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@@ -188,7 +188,7 @@ Link::SetHost(const nsAString &aHost, ErrorResult& aError)
}
void
Link::SetHostname(const nsAString &aHostname, ErrorResult& aError)
Link::SetHostname(const nsAString &aHostname)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@@ -201,7 +201,7 @@ Link::SetHostname(const nsAString &aHostname, ErrorResult& aError)
}
void
Link::SetPathname(const nsAString &aPathname, ErrorResult& aError)
Link::SetPathname(const nsAString &aPathname)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
@@ -215,14 +215,7 @@ Link::SetPathname(const nsAString &aPathname, ErrorResult& aError)
}
void
Link::SetSearch(const nsAString& aSearch, ErrorResult& aError)
{
SetSearchInternal(aSearch);
UpdateURLSearchParams();
}
void
Link::SetSearchInternal(const nsAString& aSearch)
Link::SetSearch(const nsAString& aSearch)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
@@ -236,7 +229,7 @@ Link::SetSearchInternal(const nsAString& aSearch)
}
void
Link::SetPort(const nsAString &aPort, ErrorResult& aError)
Link::SetPort(const nsAString &aPort)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@@ -261,7 +254,7 @@ Link::SetPort(const nsAString &aPort, ErrorResult& aError)
}
void
Link::SetHash(const nsAString &aHash, ErrorResult& aError)
Link::SetHash(const nsAString &aHash)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@@ -274,7 +267,7 @@ Link::SetHash(const nsAString &aHash, ErrorResult& aError)
}
void
Link::GetOrigin(nsAString &aOrigin, ErrorResult& aError)
Link::GetOrigin(nsAString &aOrigin)
{
aOrigin.Truncate();
@@ -289,7 +282,7 @@ Link::GetOrigin(nsAString &aOrigin, ErrorResult& aError)
}
void
Link::GetProtocol(nsAString &_protocol, ErrorResult& aError)
Link::GetProtocol(nsAString &_protocol)
{
nsCOMPtr<nsIURI> uri(GetURI());
if (!uri) {
@@ -301,11 +294,10 @@ Link::GetProtocol(nsAString &_protocol, ErrorResult& aError)
CopyASCIItoUTF16(scheme, _protocol);
}
_protocol.Append(char16_t(':'));
return;
}
void
Link::GetUsername(nsAString& aUsername, ErrorResult& aError)
Link::GetUsername(nsAString& aUsername)
{
aUsername.Truncate();
@@ -320,7 +312,7 @@ Link::GetUsername(nsAString& aUsername, ErrorResult& aError)
}
void
Link::GetPassword(nsAString &aPassword, ErrorResult& aError)
Link::GetPassword(nsAString &aPassword)
{
aPassword.Truncate();
@@ -335,7 +327,7 @@ Link::GetPassword(nsAString &aPassword, ErrorResult& aError)
}
void
Link::GetHost(nsAString &_host, ErrorResult& aError)
Link::GetHost(nsAString &_host)
{
_host.Truncate();
@@ -353,7 +345,7 @@ Link::GetHost(nsAString &_host, ErrorResult& aError)
}
void
Link::GetHostname(nsAString &_hostname, ErrorResult& aError)
Link::GetHostname(nsAString &_hostname)
{
_hostname.Truncate();
@@ -367,7 +359,7 @@ Link::GetHostname(nsAString &_hostname, ErrorResult& aError)
}
void
Link::GetPathname(nsAString &_pathname, ErrorResult& aError)
Link::GetPathname(nsAString &_pathname)
{
_pathname.Truncate();
@@ -387,7 +379,7 @@ Link::GetPathname(nsAString &_pathname, ErrorResult& aError)
}
void
Link::GetSearch(nsAString &_search, ErrorResult& aError)
Link::GetSearch(nsAString &_search)
{
_search.Truncate();
@@ -407,7 +399,7 @@ Link::GetSearch(nsAString &_search, ErrorResult& aError)
}
void
Link::GetPort(nsAString &_port, ErrorResult& aError)
Link::GetPort(nsAString &_port)
{
_port.Truncate();
@@ -429,7 +421,7 @@ Link::GetPort(nsAString &_port, ErrorResult& aError)
}
void
Link::GetHash(nsAString &_hash, ErrorResult& aError)
Link::GetHash(nsAString &_hash)
{
_hash.Truncate();
@@ -482,7 +474,6 @@ Link::ResetLinkState(bool aNotify, bool aHasHref)
// If we've cached the URI, reset always invalidates it.
mCachedURI = nullptr;
UpdateURLSearchParams();
// Update our state back to the default.
mLinkState = defaultState;
@@ -571,67 +562,5 @@ Link::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
return n;
}
URLSearchParams*
Link::SearchParams()
{
CreateSearchParamsIfNeeded();
return mSearchParams;
}
void
Link::URLSearchParamsUpdated(URLSearchParams* aSearchParams)
{
MOZ_ASSERT(mSearchParams);
MOZ_ASSERT(mSearchParams == aSearchParams);
nsString search;
mSearchParams->Serialize(search);
SetSearchInternal(search);
}
void
Link::UpdateURLSearchParams()
{
if (!mSearchParams) {
return;
}
nsAutoCString search;
nsCOMPtr<nsIURI> uri(GetURI());
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
if (url) {
nsresult rv = url->GetQuery(search);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to get the query from a nsIURL.");
}
}
mSearchParams->ParseInput(search);
}
void
Link::CreateSearchParamsIfNeeded()
{
if (!mSearchParams) {
mSearchParams = new URLSearchParams(this, this);
UpdateURLSearchParams();
}
}
void
Link::Unlink()
{
if (mSearchParams) {
mSearchParams = nullptr;
}
}
void
Link::Traverse(nsCycleCollectionTraversalCallback &cb)
{
Link* tmp = this;
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSearchParams);
}
} // namespace dom
} // namespace mozilla
+20 -38
View File
@@ -13,7 +13,6 @@
#include "mozilla/IHistory.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/dom/URLSearchParams.h"
#include "nsIContent.h" // for nsLinkState
namespace mozilla {
@@ -28,7 +27,7 @@ class Element;
{ 0xb25edee6, 0xdd35, 0x4f8b, \
{ 0xab, 0x90, 0x66, 0xd0, 0xbd, 0x3c, 0x22, 0xd5 } }
class Link : public URLSearchParamsObserver
class Link : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_LINK_IMPLEMENTATION_IID)
@@ -57,26 +56,25 @@ public:
/**
* Helper methods for modifying and obtaining parts of the URI of the Link.
*/
void SetProtocol(const nsAString &aProtocol, ErrorResult& aError);
void SetUsername(const nsAString &aUsername, ErrorResult& aError);
void SetPassword(const nsAString &aPassword, ErrorResult& aError);
void SetHost(const nsAString &aHost, ErrorResult& aError);
void SetHostname(const nsAString &aHostname, ErrorResult& aError);
void SetPathname(const nsAString &aPathname, ErrorResult& aError);
void SetSearch(const nsAString &aSearch, ErrorResult& aError);
void SetPort(const nsAString &aPort, ErrorResult& aError);
void SetHash(const nsAString &aHash, ErrorResult& aError);
void GetOrigin(nsAString &aOrigin, ErrorResult& aError);
void GetProtocol(nsAString &_protocol, ErrorResult& aError);
void GetUsername(nsAString &aUsername, ErrorResult& aError);
void GetPassword(nsAString &aPassword, ErrorResult& aError);
void GetHost(nsAString &_host, ErrorResult& aError);
void GetHostname(nsAString &_hostname, ErrorResult& aError);
void GetPathname(nsAString &_pathname, ErrorResult& aError);
void GetSearch(nsAString &_search, ErrorResult& aError);
URLSearchParams* SearchParams();
void GetPort(nsAString &_port, ErrorResult& aError);
void GetHash(nsAString &_hash, ErrorResult& aError);
void SetProtocol(const nsAString &aProtocol);
void SetUsername(const nsAString &aUsername);
void SetPassword(const nsAString &aPassword);
void SetHost(const nsAString &aHost);
void SetHostname(const nsAString &aHostname);
void SetPathname(const nsAString &aPathname);
void SetSearch(const nsAString &aSearch);
void SetPort(const nsAString &aPort);
void SetHash(const nsAString &aHash);
void GetOrigin(nsAString &aOrigin);
void GetProtocol(nsAString &_protocol);
void GetUsername(nsAString &aUsername);
void GetPassword(nsAString &aPassword);
void GetHost(nsAString &_host);
void GetHostname(nsAString &_hostname);
void GetPathname(nsAString &_pathname);
void GetSearch(nsAString &_search);
void GetPort(nsAString &_port);
void GetHash(nsAString &_hash);
/**
* Invalidates any link caching, and resets the state to the default.
@@ -113,9 +111,6 @@ public:
bool ElementHasHref() const;
// URLSearchParamsObserver
void URLSearchParamsUpdated(URLSearchParams* aSearchParams) override;
protected:
virtual ~Link();
@@ -134,12 +129,6 @@ protected:
nsIURI* GetCachedURI() const { return mCachedURI; }
bool HasCachedURI() const { return !!mCachedURI; }
void UpdateURLSearchParams();
// CC methods
void Unlink();
void Traverse(nsCycleCollectionTraversalCallback &cb);
private:
/**
* Unregisters from History so this node no longer gets notifications about
@@ -150,10 +139,6 @@ private:
already_AddRefed<nsIURI> GetURIToMutate();
void SetHrefAttribute(nsIURI *aURI);
void CreateSearchParamsIfNeeded();
void SetSearchInternal(const nsAString& aSearch);
mutable nsCOMPtr<nsIURI> mCachedURI;
Element * const mElement;
@@ -167,9 +152,6 @@ private:
bool mNeedsRegistration;
bool mRegistered;
protected:
RefPtr<URLSearchParams> mSearchParams;
};
NS_DEFINE_STATIC_IID_ACCESSOR(Link, MOZILLA_DOM_LINK_IMPLEMENTATION_IID)
+3 -5
View File
@@ -2488,13 +2488,13 @@ Navigator::HasDataStoreSupport(nsIPrincipal* aPrincipal)
// A WorkerMainThreadRunnable to synchronously dispatch the call of
// HasDataStoreSupport() from the worker thread to the main thread.
class HasDataStoreSupportRunnable final
: public workers::WorkerMainThreadRunnable
: public workers::WorkerCheckAPIExposureOnMainThreadRunnable
{
public:
bool mResult;
explicit HasDataStoreSupportRunnable(workers::WorkerPrivate* aWorkerPrivate)
: workers::WorkerMainThreadRunnable(aWorkerPrivate)
: workers::WorkerCheckAPIExposureOnMainThreadRunnable(aWorkerPrivate)
, mResult(false)
{
MOZ_ASSERT(aWorkerPrivate);
@@ -2525,9 +2525,7 @@ Navigator::HasDataStoreSupport(JSContext* aCx, JSObject* aGlobal)
RefPtr<HasDataStoreSupportRunnable> runnable =
new HasDataStoreSupportRunnable(workerPrivate);
runnable->Dispatch(aCx);
return runnable->mResult;
return runnable->Dispatch() && runnable->mResult;
}
workers::AssertIsOnMainThread();
+23 -24
View File
@@ -78,7 +78,7 @@ URL::Constructor(nsISupports* aParent, const nsAString& aUrl,
nsresult rv = NS_NewURI(getter_AddRefs(baseUri), aBase, nullptr, nullptr,
nsContentUtils::GetIOService());
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.ThrowTypeError<MSG_INVALID_URL>(&aBase);
aRv.ThrowTypeError<MSG_INVALID_URL>(aBase);
return nullptr;
}
@@ -94,7 +94,7 @@ URL::Constructor(nsISupports* aParent, const nsAString& aUrl, nsIURI* aBase,
nsresult rv = NS_NewURI(getter_AddRefs(uri), aUrl, nullptr, aBase,
nsContentUtils::GetIOService());
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.ThrowTypeError<MSG_INVALID_URL>(&aUrl);
aRv.ThrowTypeError<MSG_INVALID_URL>(aUrl);
return nullptr;
}
@@ -203,7 +203,7 @@ URL::RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aURL,
}
void
URL::GetHref(nsAString& aHref, ErrorResult& aRv) const
URL::GetHref(nsAString& aHref) const
{
aHref.Truncate();
@@ -229,8 +229,7 @@ URL::SetHref(const nsAString& aHref, ErrorResult& aRv)
nsCOMPtr<nsIURI> uri;
rv = ioService->NewURI(href, nullptr, nullptr, getter_AddRefs(uri));
if (NS_FAILED(rv)) {
nsAutoString label(aHref);
aRv.ThrowTypeError<MSG_INVALID_URL>(&label);
aRv.ThrowTypeError<MSG_INVALID_URL>(aHref);
return;
}
@@ -239,13 +238,13 @@ URL::SetHref(const nsAString& aHref, ErrorResult& aRv)
}
void
URL::GetOrigin(nsAString& aOrigin, ErrorResult& aRv) const
URL::GetOrigin(nsAString& aOrigin) const
{
nsContentUtils::GetUTFOrigin(mURI, aOrigin);
}
void
URL::GetProtocol(nsAString& aProtocol, ErrorResult& aRv) const
URL::GetProtocol(nsAString& aProtocol) const
{
nsAutoCString protocol;
if (NS_SUCCEEDED(mURI->GetScheme(protocol))) {
@@ -257,7 +256,7 @@ URL::GetProtocol(nsAString& aProtocol, ErrorResult& aRv) const
}
void
URL::SetProtocol(const nsAString& aProtocol, ErrorResult& aRv)
URL::SetProtocol(const nsAString& aProtocol)
{
nsAString::const_iterator start, end;
aProtocol.BeginReading(start);
@@ -304,37 +303,37 @@ URL::SetProtocol(const nsAString& aProtocol, ErrorResult& aRv)
}
void
URL::GetUsername(nsAString& aUsername, ErrorResult& aRv) const
URL::GetUsername(nsAString& aUsername) const
{
URL_GETTER(aUsername, GetUsername);
}
void
URL::SetUsername(const nsAString& aUsername, ErrorResult& aRv)
URL::SetUsername(const nsAString& aUsername)
{
mURI->SetUsername(NS_ConvertUTF16toUTF8(aUsername));
}
void
URL::GetPassword(nsAString& aPassword, ErrorResult& aRv) const
URL::GetPassword(nsAString& aPassword) const
{
URL_GETTER(aPassword, GetPassword);
}
void
URL::SetPassword(const nsAString& aPassword, ErrorResult& aRv)
URL::SetPassword(const nsAString& aPassword)
{
mURI->SetPassword(NS_ConvertUTF16toUTF8(aPassword));
}
void
URL::GetHost(nsAString& aHost, ErrorResult& aRv) const
URL::GetHost(nsAString& aHost) const
{
URL_GETTER(aHost, GetHostPort);
}
void
URL::SetHost(const nsAString& aHost, ErrorResult& aRv)
URL::SetHost(const nsAString& aHost)
{
mURI->SetHostPort(NS_ConvertUTF16toUTF8(aHost));
}
@@ -370,14 +369,14 @@ URL::UpdateURLSearchParams()
}
void
URL::GetHostname(nsAString& aHostname, ErrorResult& aRv) const
URL::GetHostname(nsAString& aHostname) const
{
aHostname.Truncate();
nsContentUtils::GetHostOrIPv6WithBrackets(mURI, aHostname);
}
void
URL::SetHostname(const nsAString& aHostname, ErrorResult& aRv)
URL::SetHostname(const nsAString& aHostname)
{
// nsStandardURL returns NS_ERROR_UNEXPECTED for an empty hostname
// The return code is silently ignored
@@ -385,7 +384,7 @@ URL::SetHostname(const nsAString& aHostname, ErrorResult& aRv)
}
void
URL::GetPort(nsAString& aPort, ErrorResult& aRv) const
URL::GetPort(nsAString& aPort) const
{
aPort.Truncate();
@@ -399,7 +398,7 @@ URL::GetPort(nsAString& aPort, ErrorResult& aRv) const
}
void
URL::SetPort(const nsAString& aPort, ErrorResult& aRv)
URL::SetPort(const nsAString& aPort)
{
nsresult rv;
nsAutoString portStr(aPort);
@@ -417,7 +416,7 @@ URL::SetPort(const nsAString& aPort, ErrorResult& aRv)
}
void
URL::GetPathname(nsAString& aPathname, ErrorResult& aRv) const
URL::GetPathname(nsAString& aPathname) const
{
aPathname.Truncate();
@@ -443,7 +442,7 @@ URL::GetPathname(nsAString& aPathname, ErrorResult& aRv) const
}
void
URL::SetPathname(const nsAString& aPathname, ErrorResult& aRv)
URL::SetPathname(const nsAString& aPathname)
{
nsCOMPtr<nsIURL> url(do_QueryInterface(mURI));
if (!url) {
@@ -455,7 +454,7 @@ URL::SetPathname(const nsAString& aPathname, ErrorResult& aRv)
}
void
URL::GetSearch(nsAString& aSearch, ErrorResult& aRv) const
URL::GetSearch(nsAString& aSearch) const
{
aSearch.Truncate();
@@ -474,7 +473,7 @@ URL::GetSearch(nsAString& aSearch, ErrorResult& aRv) const
}
void
URL::SetSearch(const nsAString& aSearch, ErrorResult& aRv)
URL::SetSearch(const nsAString& aSearch)
{
SetSearchInternal(aSearch);
UpdateURLSearchParams();
@@ -500,7 +499,7 @@ URL::SearchParams()
}
void
URL::GetHash(nsAString& aHash, ErrorResult& aRv) const
URL::GetHash(nsAString& aHash) const
{
aHash.Truncate();
@@ -516,7 +515,7 @@ URL::GetHash(nsAString& aHash, ErrorResult& aRv) const
}
void
URL::SetHash(const nsAString& aHash, ErrorResult& aRv)
URL::SetHash(const nsAString& aHash)
{
mURI->SetRef(NS_ConvertUTF16toUTF8(aHash));
}
+23 -23
View File
@@ -88,59 +88,59 @@ public:
const nsAString& aURL,
ErrorResult& aRv);
void GetHref(nsAString& aHref, ErrorResult& aRv) const;
void GetHref(nsAString& aHref) const;
void SetHref(const nsAString& aHref, ErrorResult& aRv);
void GetOrigin(nsAString& aOrigin, ErrorResult& aRv) const;
void GetOrigin(nsAString& aOrigin) const;
void GetProtocol(nsAString& aProtocol, ErrorResult& aRv) const;
void GetProtocol(nsAString& aProtocol) const;
void SetProtocol(const nsAString& aProtocol, ErrorResult& aRv);
void SetProtocol(const nsAString& aProtocol);
void GetUsername(nsAString& aUsername, ErrorResult& aRv) const;
void GetUsername(nsAString& aUsername) const;
void SetUsername(const nsAString& aUsername, ErrorResult& aRv);
void SetUsername(const nsAString& aUsername);
void GetPassword(nsAString& aPassword, ErrorResult& aRv) const;
void GetPassword(nsAString& aPassword) const;
void SetPassword(const nsAString& aPassword, ErrorResult& aRv);
void SetPassword(const nsAString& aPassword);
void GetHost(nsAString& aHost, ErrorResult& aRv) const;
void GetHost(nsAString& aHost) const;
void SetHost(const nsAString& aHost, ErrorResult& aRv);
void SetHost(const nsAString& aHost);
void GetHostname(nsAString& aHostname, ErrorResult& aRv) const;
void GetHostname(nsAString& aHostname) const;
void SetHostname(const nsAString& aHostname, ErrorResult& aRv);
void SetHostname(const nsAString& aHostname);
void GetPort(nsAString& aPort, ErrorResult& aRv) const;
void GetPort(nsAString& aPort) const;
void SetPort(const nsAString& aPort, ErrorResult& aRv);
void SetPort(const nsAString& aPort);
void GetPathname(nsAString& aPathname, ErrorResult& aRv) const;
void GetPathname(nsAString& aPathname) const;
void SetPathname(const nsAString& aPathname, ErrorResult& aRv);
void SetPathname(const nsAString& aPathname);
void GetSearch(nsAString& aRetval, ErrorResult& aRv) const;
void GetSearch(nsAString& aRetval) const;
void SetSearch(const nsAString& aArg, ErrorResult& aRv);
void SetSearch(const nsAString& aArg);
URLSearchParams* SearchParams();
void GetHash(nsAString& aRetval, ErrorResult& aRv) const;
void GetHash(nsAString& aRetval) const;
void SetHash(const nsAString& aArg, ErrorResult& aRv);
void SetHash(const nsAString& aArg);
void Stringify(nsAString& aRetval, ErrorResult& aRv) const
void Stringify(nsAString& aRetval) const
{
GetHref(aRetval, aRv);
GetHref(aRetval);
}
void
ToJSON(nsString& aResult, ErrorResult& aRv) const
{
GetHref(aResult, aRv);
GetHref(aResult);
}
// URLSearchParamsObserver
+32 -33
View File
@@ -140,14 +140,14 @@ public:
const nsACString& aReasonString = EmptyCString());
nsresult CloseConnection(uint16_t reasonCode,
const nsACString& aReasonString = EmptyCString());
nsresult Disconnect();
void Disconnect();
void DisconnectInternal();
nsresult ConsoleError();
nsresult PrintErrorOnConsole(const char* aBundleURI,
const char16_t* aError,
const char16_t** aFormatStrings,
uint32_t aFormatStringsLen);
void PrintErrorOnConsole(const char* aBundleURI,
const char16_t* aError,
const char16_t** aFormatStrings,
uint32_t aFormatStringsLen);
nsresult DoOnMessageAvailable(const nsACString& aMsg,
bool isBinary);
@@ -303,21 +303,15 @@ public:
, mError(aError)
, mFormatStrings(aFormatStrings)
, mFormatStringsLen(aFormatStringsLen)
, mRv(NS_ERROR_FAILURE)
{ }
bool MainThreadRun() override
{
mRv = mImpl->PrintErrorOnConsole(mBundleURI, mError, mFormatStrings,
mFormatStringsLen);
mImpl->PrintErrorOnConsole(mBundleURI, mError, mFormatStrings,
mFormatStringsLen);
return true;
}
nsresult ErrorCode() const
{
return mRv;
}
private:
// Raw pointer because this runnable is sync.
WebSocketImpl* mImpl;
@@ -326,12 +320,11 @@ private:
const char16_t* mError;
const char16_t** mFormatStrings;
uint32_t mFormatStringsLen;
nsresult mRv;
};
} // namespace
nsresult
void
WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI,
const char16_t *aError,
const char16_t **aFormatStrings,
@@ -345,26 +338,32 @@ WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI,
RefPtr<PrintErrorOnConsoleRunnable> runnable =
new PrintErrorOnConsoleRunnable(this, aBundleURI, aError, aFormatStrings,
aFormatStringsLen);
runnable->Dispatch(mWorkerPrivate->GetJSContext());
return runnable->ErrorCode();
ErrorResult rv;
runnable->Dispatch(rv);
// XXXbz this seems totally broken. We should be propagating this out, but
// none of our callers really propagate anything usefully. Come to think of
// it, why is this a syncrunnable anyway? Can't this be a fire-and-forget
// runnable??
rv.SuppressException();
return;
}
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
nsCOMPtr<nsIStringBundle> strBundle;
rv = bundleService->CreateBundle(aBundleURI, getter_AddRefs(strBundle));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
nsCOMPtr<nsIConsoleService> console(
do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
nsCOMPtr<nsIScriptError> errorObject(
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
// Localize the error message
nsXPIDLString message;
@@ -375,7 +374,7 @@ WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI,
} else {
rv = strBundle->GetStringFromName(aError, getter_Copies(message));
}
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
if (mInnerWindowID) {
rv = errorObject->InitWithWindowID(message,
@@ -391,13 +390,11 @@ WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI,
nsIScriptError::errorFlag, "Web Socket");
}
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
// print the error message directly to the JS console
rv = console->LogMessage(errorObject);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
NS_ENSURE_SUCCESS_VOID(rv);
}
namespace {
@@ -605,11 +602,11 @@ private:
} // namespace
nsresult
void
WebSocketImpl::Disconnect()
{
if (mDisconnectingOrDisconnected) {
return NS_OK;
return;
}
AssertIsOnTargetThread();
@@ -628,7 +625,11 @@ WebSocketImpl::Disconnect()
} else {
RefPtr<DisconnectInternalRunnable> runnable =
new DisconnectInternalRunnable(this);
runnable->Dispatch(mWorkerPrivate->GetJSContext());
ErrorResult rv;
runnable->Dispatch(rv);
// XXXbz this seems totally broken. We should be propagating this out, but
// where to, exactly?
rv.SuppressException();
}
// DontKeepAliveAnyMore() can release the object. So hold a reference to this
@@ -647,8 +648,6 @@ WebSocketImpl::Disconnect()
// We want to release the WebSocket in the correct thread.
mWebSocket = nullptr;
return NS_OK;
}
void
@@ -1272,7 +1271,7 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
new InitRunnable(webSocket->mImpl, aUrl, protocolArray,
nsAutoCString(file.get()), lineno, column, aRv,
&connectionFailed);
runnable->Dispatch(aGlobal.Context());
runnable->Dispatch(aRv);
}
if (NS_WARN_IF(aRv.Failed())) {
@@ -1352,7 +1351,7 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
} else {
RefPtr<AsyncOpenRunnable> runnable =
new AsyncOpenRunnable(webSocket->mImpl, aRv);
runnable->Dispatch(aGlobal.Context());
runnable->Dispatch(aRv);
}
if (NS_WARN_IF(aRv.Failed())) {
+1 -1
View File
@@ -162,7 +162,7 @@ WindowNamedPropertiesHandler::defineProperty(JSContext* aCx,
{
ErrorResult rv;
rv.ThrowTypeError<MSG_DEFINEPROPERTY_ON_GSP>();
rv.ReportErrorWithMessage(aCx);
rv.MaybeSetPendingException(aCx);
return false;
}
+18 -19
View File
@@ -199,7 +199,8 @@ NS_GetContentList(nsINode* aRootNode,
NS_ASSERTION(aRootNode, "content list has to have a root");
RefPtr<nsContentList> list;
nsContentListKey hashKey(aRootNode, aMatchNameSpaceId, aTagname);
nsContentListKey hashKey(aRootNode, aMatchNameSpaceId, aTagname,
aRootNode->OwnerDoc()->IsHTMLDocument());
uint32_t recentlyUsedCacheIndex = RecentlyUsedCacheIndex(hashKey);
nsContentList* cachedList = sRecentlyUsedContentLists[recentlyUsedCacheIndex];
if (cachedList && cachedList->MatchesKey(hashKey)) {
@@ -399,7 +400,8 @@ nsContentList::nsContentList(nsINode* aRootNode,
mData(nullptr),
mState(LIST_DIRTY),
mDeep(aDeep),
mFuncMayDependOnAttr(false)
mFuncMayDependOnAttr(false),
mIsHTMLDocument(aRootNode->OwnerDoc()->IsHTMLDocument())
{
NS_ASSERTION(mRootNode, "Must have root");
if (nsGkAtoms::_asterisk == mHTMLMatchAtom) {
@@ -439,7 +441,8 @@ nsContentList::nsContentList(nsINode* aRootNode,
mState(LIST_DIRTY),
mMatchAll(false),
mDeep(aDeep),
mFuncMayDependOnAttr(aFuncMayDependOnAttr)
mFuncMayDependOnAttr(aFuncMayDependOnAttr),
mIsHTMLDocument(false)
{
NS_ASSERTION(mRootNode, "Must have root");
mRootNode->AddMutationObserver(this);
@@ -525,8 +528,9 @@ nsContentList::NamedItem(const nsAString& aName, bool aDoFlush)
nsIContent *content = mElements[i];
// XXX Should this pass eIgnoreCase?
if (content &&
(content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
name, eCaseMatters) ||
((content->IsHTMLElement() &&
content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
name, eCaseMatters)) ||
content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id,
name, eCaseMatters))) {
return content->AsElement();
@@ -851,25 +855,20 @@ nsContentList::Match(Element *aElement)
if (!mXMLMatchAtom)
return false;
mozilla::dom::NodeInfo *ni = aElement->NodeInfo();
bool unknown = mMatchNameSpaceId == kNameSpaceID_Unknown;
bool wildcard = mMatchNameSpaceId == kNameSpaceID_Wildcard;
NodeInfo *ni = aElement->NodeInfo();
bool wildcard = mMatchNameSpaceId == kNameSpaceID_Wildcard ||
mMatchNameSpaceId == kNameSpaceID_Unknown;
bool toReturn = mMatchAll;
if (!unknown && !wildcard)
if (!wildcard)
toReturn &= ni->NamespaceEquals(mMatchNameSpaceId);
if (toReturn)
return toReturn;
bool matchHTML = aElement->GetNameSpaceID() == kNameSpaceID_XHTML &&
aElement->OwnerDoc()->IsHTMLDocument();
if (unknown) {
return matchHTML ? ni->QualifiedNameEquals(mHTMLMatchAtom) :
ni->QualifiedNameEquals(mXMLMatchAtom);
}
bool matchHTML =
mIsHTMLDocument && aElement->GetNameSpaceID() == kNameSpaceID_XHTML;
if (wildcard) {
return matchHTML ? ni->Equals(mHTMLMatchAtom) :
ni->Equals(mXMLMatchAtom);
@@ -974,7 +973,7 @@ nsContentList::RemoveFromHashtable()
}
nsDependentAtomString str(mXMLMatchAtom);
nsContentListKey key(mRootNode, mMatchNameSpaceId, str);
nsContentListKey key(mRootNode, mMatchNameSpaceId, str, mIsHTMLDocument);
uint32_t recentlyUsedCacheIndex = RecentlyUsedCacheIndex(key);
if (sRecentlyUsedContentLists[recentlyUsedCacheIndex] == this) {
sRecentlyUsedContentLists[recentlyUsedCacheIndex] = nullptr;
+24 -6
View File
@@ -145,14 +145,21 @@ private:
*/
struct nsContentListKey
{
// We have to take an aIsHTMLDocument arg for two reasons:
// 1) We don't want to include nsIDocument.h in this header.
// 2) We need to do that to make nsContentList::RemoveFromHashtable
// work, because by the time it's called the document of the
// list's root node might have changed.
nsContentListKey(nsINode* aRootNode,
int32_t aMatchNameSpaceId,
const nsAString& aTagname)
const nsAString& aTagname,
bool aIsHTMLDocument)
: mRootNode(aRootNode),
mMatchNameSpaceId(aMatchNameSpaceId),
mTagname(aTagname),
mIsHTMLDocument(aIsHTMLDocument),
mHash(mozilla::AddToHash(mozilla::HashString(aTagname), mRootNode,
mMatchNameSpaceId))
mMatchNameSpaceId, mIsHTMLDocument))
{
}
@@ -160,6 +167,7 @@ struct nsContentListKey
: mRootNode(aContentListKey.mRootNode),
mMatchNameSpaceId(aContentListKey.mMatchNameSpaceId),
mTagname(aContentListKey.mTagname),
mIsHTMLDocument(aContentListKey.mIsHTMLDocument),
mHash(aContentListKey.mHash)
{
}
@@ -172,6 +180,7 @@ struct nsContentListKey
nsINode* const mRootNode; // Weak ref
const int32_t mMatchNameSpaceId;
const nsAString& mTagname;
bool mIsHTMLDocument;
const uint32_t mHash;
};
@@ -212,7 +221,7 @@ public:
* The special value "*" always matches whatever aMatchAtom
* is matched against.
* @param aMatchNameSpaceId If kNameSpaceID_Unknown, then aMatchAtom is the
* tagName to match.
* localName to match.
* If kNameSpaceID_Wildcard, then aMatchAtom is the
* localName to match.
* Otherwise we match nodes whose namespace is
@@ -240,7 +249,8 @@ public:
* deeper. If true, then look at the whole subtree rooted at
* our root.
* @param aMatchAtom an atom to be passed back to aFunc
* @param aMatchNameSpaceId a namespace id to be passed back to aFunc
* @param aMatchNameSpaceId a namespace id to be passed back to aFunc. Is
allowed to be kNameSpaceID_Unknown.
* @param aFuncMayDependOnAttr a boolean that indicates whether this list is
* sensitive to attribute changes.
*/
@@ -321,13 +331,15 @@ public:
{
// The root node is most commonly the same: the document. And the
// most common namespace id is kNameSpaceID_Unknown. So check the
// string first.
// string first. Cases in which whether our root's ownerDocument
// is HTML changes are extremely rare, so check those last.
NS_PRECONDITION(mXMLMatchAtom,
"How did we get here with a null match atom on our list?");
return
mXMLMatchAtom->Equals(aKey.mTagname) &&
mRootNode == aKey.mRootNode &&
mMatchNameSpaceId == aKey.mMatchNameSpaceId;
mMatchNameSpaceId == aKey.mMatchNameSpaceId &&
mIsHTMLDocument == aKey.mIsHTMLDocument;
}
/**
@@ -450,6 +462,12 @@ protected:
* Whether we actually need to flush to get our state correct.
*/
uint8_t mFlushesNeeded : 1;
/**
* Whether the ownerDocument of our root node at list creation time was an
* HTML document. Only needed when we're doing a namespace/atom match, not
* when doing function matching, always false otherwise.
*/
uint8_t mIsHTMLDocument : 1;
#ifdef DEBUG_CONTENT_LIST
void AssertInSync();
+6 -3
View File
@@ -9,12 +9,14 @@
#include <stdint.h>
#include "nsCOMPtr.h"
#include "nsStringFwd.h"
class nsContentList;
class nsIAtom;
class nsIContent;
class nsINode;
// Can't use nsStringFwd.h because that's internal-API-only.
class nsString;
class nsAString;
// Magic namespace id that means "match all namespaces". This is
// negative so it won't collide with actual namespace constants.
@@ -42,8 +44,9 @@ typedef void* (*nsFuncStringContentListDataAllocator)(nsINode* aRootNode,
// If aMatchNameSpaceId is kNameSpaceID_Unknown, this will return a
// content list which matches ASCIIToLower(aTagname) against HTML
// elements in HTML documents and aTagname against everything else.
// For any other value of aMatchNameSpaceId, the list will match
// aTagname against all elements.
// The comparison is done to the element's localName. For any
// other value of aMatchNameSpaceId, the list will match aTagname
// against all elements, again comparing to the localName.
already_AddRefed<nsContentList>
NS_GetContentList(nsINode* aRootNode,
int32_t aMatchNameSpaceId,
+59 -7
View File
@@ -126,6 +126,7 @@ class ContentPermissionRequestParent : public PContentPermissionRequestParent
private:
virtual bool Recvprompt();
virtual bool RecvNotifyVisibility(const bool& aIsVisible);
virtual bool RecvDestroy();
virtual void ActorDestroy(ActorDestroyReason why);
};
@@ -166,6 +167,13 @@ ContentPermissionRequestParent::RecvNotifyVisibility(const bool& aIsVisible)
return true;
}
bool
ContentPermissionRequestParent::RecvDestroy()
{
Unused << PContentPermissionRequestParent::Send__delete__(this);
return true;
}
void
ContentPermissionRequestParent::ActorDestroy(ActorDestroyReason why)
{
@@ -300,6 +308,14 @@ ContentPermissionRequestParentMap()
return sPermissionRequestParentMap;
}
static std::map<PContentPermissionRequestChild*, TabId>&
ContentPermissionRequestChildMap()
{
MOZ_ASSERT(NS_IsMainThread());
static std::map<PContentPermissionRequestChild*, TabId> sPermissionRequestChildMap;
return sPermissionRequestChildMap;
}
/* static */ nsresult
nsContentPermissionUtils::CreatePermissionArray(const nsACString& aType,
const nsACString& aAccess,
@@ -363,6 +379,7 @@ nsContentPermissionUtils::AskPermission(nsIContentPermissionRequest* aRequest, n
permArray,
IPC::Principal(principal),
child->GetTabId());
ContentPermissionRequestChildMap()[req.get()] = child->GetTabId();
req->Sendprompt();
return NS_OK;
@@ -402,6 +419,29 @@ nsContentPermissionUtils::NotifyRemoveContentPermissionRequestParent(
ContentPermissionRequestParentMap().erase(it);
}
/* static */ nsTArray<PContentPermissionRequestChild*>
nsContentPermissionUtils::GetContentPermissionRequestChildById(const TabId& aTabId)
{
nsTArray<PContentPermissionRequestChild*> childArray;
for (auto& it : ContentPermissionRequestChildMap()) {
if (it.second == aTabId) {
childArray.AppendElement(it.first);
}
}
return Move(childArray);
}
/* static */ void
nsContentPermissionUtils::NotifyRemoveContentPermissionRequestChild(
PContentPermissionRequestChild* aChild)
{
auto it = ContentPermissionRequestChildMap().find(aChild);
MOZ_ASSERT(it != ContentPermissionRequestChildMap().end());
ContentPermissionRequestChildMap().erase(it);
}
NS_IMPL_ISUPPORTS(nsContentPermissionRequester, nsIContentPermissionRequester)
nsContentPermissionRequester::nsContentPermissionRequester(nsPIDOMWindow* aWindow)
@@ -608,7 +648,7 @@ nsContentPermissionRequestProxy::Cancel()
nsTArray<PermissionChoice> emptyChoices;
Unused << ContentPermissionRequestParent::Send__delete__(mParent, false, emptyChoices);
Unused << mParent->SendNotifyResult(false, emptyChoices);
mParent = nullptr;
return NS_OK;
}
@@ -672,7 +712,7 @@ nsContentPermissionRequestProxy::Allow(JS::HandleValue aChoices)
return NS_ERROR_FAILURE;
}
Unused << ContentPermissionRequestParent::Send__delete__(mParent, true, choices);
Unused << mParent->SendNotifyResult(true, choices);
mParent = nullptr;
return NS_OK;
}
@@ -705,6 +745,7 @@ RemotePermissionRequest::RemotePermissionRequest(
: mRequest(aRequest)
, mWindow(aWindow)
, mIPCOpen(false)
, mDestroyed(false)
{
mListener = new VisibilityChangeListener(mWindow);
mListener->SetCallback(this);
@@ -726,11 +767,10 @@ RemotePermissionRequest::DoAllow(JS::HandleValue aChoices)
// PContentPermissionRequestChild
bool
RemotePermissionRequest::Recv__delete__(const bool& aAllow,
InfallibleTArray<PermissionChoice>&& aChoices)
RemotePermissionRequest::RecvNotifyResult(const bool& aAllow,
InfallibleTArray<PermissionChoice>&& aChoices)
{
mListener->RemoveListener();
mListener = nullptr;
Destroy();
if (aAllow && mWindow->IsCurrentInnerWindow()) {
// Use 'undefined' if no choice is provided.
@@ -780,10 +820,22 @@ RemotePermissionRequest::RecvGetVisibility()
return true;
}
void
RemotePermissionRequest::Destroy()
{
if (!IPCOpen()) {
return;
}
Unused << this->SendDestroy();
mListener->RemoveListener();
mListener = nullptr;
mDestroyed = true;
}
NS_IMETHODIMP
RemotePermissionRequest::NotifyVisibility(bool isVisible)
{
if (!mIPCOpen) {
if (!IPCOpen()) {
return NS_OK;
}
+13 -2
View File
@@ -108,6 +108,12 @@ public:
static void
NotifyRemoveContentPermissionRequestParent(PContentPermissionRequestParent* aParent);
static nsTArray<PContentPermissionRequestChild*>
GetContentPermissionRequestChildById(const TabId& aTabId);
static void
NotifyRemoveContentPermissionRequestChild(PContentPermissionRequestChild* aChild);
};
class nsContentPermissionRequester final : public nsIContentPermissionRequester
@@ -188,8 +194,8 @@ public:
nsPIDOMWindow* aWindow);
// It will be called when prompt dismissed.
virtual bool Recv__delete__(const bool &aAllow,
InfallibleTArray<PermissionChoice>&& aChoices) override;
virtual bool RecvNotifyResult(const bool &aAllow,
InfallibleTArray<PermissionChoice>&& aChoices) override;
virtual bool RecvGetVisibility() override;
@@ -205,6 +211,10 @@ public:
Release();
}
void Destroy();
bool IPCOpen() const { return mIPCOpen && !mDestroyed; }
private:
virtual ~RemotePermissionRequest()
{
@@ -217,6 +227,7 @@ private:
nsCOMPtr<nsIContentPermissionRequest> mRequest;
nsCOMPtr<nsPIDOMWindow> mWindow;
bool mIPCOpen;
bool mDestroyed;
RefPtr<VisibilityChangeListener> mListener;
};
+6
View File
@@ -85,12 +85,14 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsContentSink)
}
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParser)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCSSLoader)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mNodeInfoManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mScriptLoader)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsContentSink)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParser)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCSSLoader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNodeInfoManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mScriptLoader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@@ -1628,4 +1630,8 @@ nsContentSink::NotifyDocElementCreated(nsIDocument* aDoc)
NotifyObservers(domDoc, "document-element-inserted",
EmptyString().get());
}
nsContentUtils::DispatchChromeEvent(aDoc, aDoc,
NS_LITERAL_STRING("DOMDocElementInserted"),
true, false);
}
+23 -7
View File
@@ -572,7 +572,7 @@ nsDOMMutationObserver::GetAllSubtreeObserversFor(nsINode* aNode,
void
nsDOMMutationObserver::ScheduleForRun()
{
nsDOMMutationObserver::AddCurrentlyHandlingObserver(this);
nsDOMMutationObserver::AddCurrentlyHandlingObserver(this, sMutationLevel);
if (mWaitingForRun) {
return;
@@ -928,6 +928,15 @@ nsDOMMutationObserver::CurrentRecord(nsIAtom* aType)
ScheduleForRun();
}
#ifdef DEBUG
MOZ_ASSERT(sCurrentlyHandlingObservers->Length() == sMutationLevel);
for (size_t i = 0; i < sCurrentlyHandlingObservers->Length(); ++i) {
MOZ_ASSERT(sCurrentlyHandlingObservers->ElementAt(i).Contains(this),
"MutationObserver should be added as an observer of all the "
"nested mutations!");
}
#endif
NS_ASSERTION(mCurrentMutations[last]->mType == aType,
"Unexpected MutationRecord type!");
@@ -972,23 +981,30 @@ nsDOMMutationObserver::LeaveMutationHandling()
}
void
nsDOMMutationObserver::AddCurrentlyHandlingObserver(nsDOMMutationObserver* aObserver)
nsDOMMutationObserver::AddCurrentlyHandlingObserver(nsDOMMutationObserver* aObserver,
uint32_t aMutationLevel)
{
NS_ASSERTION(sMutationLevel > 0, "Unexpected mutation level!");
NS_ASSERTION(aMutationLevel > 0, "Unexpected mutation level!");
if (aMutationLevel > 1) {
// MutationObserver must be in the currently handling observer list
// in all the nested levels.
AddCurrentlyHandlingObserver(aObserver, aMutationLevel - 1);
}
if (!sCurrentlyHandlingObservers) {
sCurrentlyHandlingObservers =
new nsAutoTArray<nsAutoTArray<RefPtr<nsDOMMutationObserver>, 4>, 4>;
}
while (sCurrentlyHandlingObservers->Length() < sMutationLevel) {
while (sCurrentlyHandlingObservers->Length() < aMutationLevel) {
sCurrentlyHandlingObservers->InsertElementAt(
sCurrentlyHandlingObservers->Length());
}
uint32_t last = sMutationLevel - 1;
if (!sCurrentlyHandlingObservers->ElementAt(last).Contains(aObserver)) {
sCurrentlyHandlingObservers->ElementAt(last).AppendElement(aObserver);
uint32_t index = aMutationLevel - 1;
if (!sCurrentlyHandlingObservers->ElementAt(index).Contains(aObserver)) {
sCurrentlyHandlingObservers->ElementAt(index).AppendElement(aObserver);
}
}
+2 -1
View File
@@ -595,7 +595,8 @@ protected:
static void HandleMutationsInternal();
static void AddCurrentlyHandlingObserver(nsDOMMutationObserver* aObserver);
static void AddCurrentlyHandlingObserver(nsDOMMutationObserver* aObserver,
uint32_t aMutationLevel);
nsCOMPtr<nsPIDOMWindow> mOwner;
+3
View File
@@ -6373,6 +6373,7 @@ nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aFullscreenMode,
mWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("DOM_Fullscreen"),
this, rv);
if (rv.Failed()) {
rv.SuppressException();
return rv.StealNSResult();
}
@@ -6380,6 +6381,7 @@ nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aFullscreenMode,
ErrorResult rv;
mWakeLock->Unlock(rv);
mWakeLock = nullptr;
rv.SuppressException();
}
return NS_OK;
@@ -12410,6 +12412,7 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout,
ErrorResult ignored;
JS::Rooted<JS::Value> ignoredVal(CycleCollectedJSRuntime::Get()->Runtime());
callback->Call(me, handler->GetArgs(), &ignoredVal, ignored, reason);
ignored.SuppressException();
}
// We ignore any failures from calling EvaluateString() on the context or
+4 -1
View File
@@ -1106,7 +1106,10 @@ public:
{
MOZ_ASSERT(IsOuterWindow());
mozilla::ErrorResult ignored;
return GetContentInternal(ignored, /* aUnprivilegedCaller = */ false);
nsCOMPtr<nsIDOMWindow> win =
GetContentInternal(ignored, /* aUnprivilegedCaller = */ false);
ignored.SuppressException();
return win.forget();
}
void Get_content(JSContext* aCx,
+5 -5
View File
@@ -49,19 +49,19 @@ public:
const nsTArray<nsString>& aStringParams) = 0;
// A version of AddConsoleReport() that accepts the message parameters
// as variable nsString arguments. Note, the parameters must be exactly
// nsString and not another string class. All other args the same as
// AddConsoleReport().
// as variable nsString arguments (or really, any sort of const nsAString).
// All other args the same as AddConsoleReport().
template<typename... Params>
void
AddConsoleReport(uint32_t aErrorFlags, const nsACString& aCategory,
nsContentUtils::PropertiesFile aPropertiesFile,
const nsACString& aSourceFileURI, uint32_t aLineNumber,
uint32_t aColumnNumber, const nsACString& aMessageName,
Params... aParams)
Params&&... aParams)
{
nsTArray<nsString> params;
mozilla::dom::StringArrayAppender::Append(params, sizeof...(Params), aParams...);
mozilla::dom::StringArrayAppender::Append(params, sizeof...(Params),
mozilla::Forward<Params>(aParams)...);
AddConsoleReport(aErrorFlags, aCategory, aPropertiesFile, aSourceFileURI,
aLineNumber, aColumnNumber, aMessageName, params);
}
+1 -5
View File
@@ -30,6 +30,7 @@
#include "mozilla/UseCounter.h"
#include "mozilla/WeakPtr.h"
#include "Units.h"
#include "nsContentListDeclarations.h"
#include "nsExpirationTracker.h"
#include "nsClassHashtable.h"
#include "prclist.h"
@@ -181,11 +182,6 @@ enum DocumentFlavor {
// Some function forward-declarations
class nsContentList;
already_AddRefed<nsContentList>
NS_GetContentList(nsINode* aRootNode,
int32_t aMatchNameSpaceId,
const nsAString& aTagname);
//----------------------------------------------------------------------
// Document interface. This is implemented by all document objects in
-7
View File
@@ -1081,13 +1081,6 @@ nsINode::IsEqualNode(nsINode* aOther)
if (!string1.Equals(string2)) {
return false;
}
// Internal subset
docType1->GetInternalSubset(string1);
docType2->GetInternalSubset(string2);
if (!string1.Equals(string2)) {
return false;
}
break;
}
+4 -7
View File
@@ -706,12 +706,12 @@ public:
}
};
class PrefEnabledRunnable final : public WorkerMainThreadRunnable
class PrefEnabledRunnable final : public WorkerCheckAPIExposureOnMainThreadRunnable
{
public:
PrefEnabledRunnable(WorkerPrivate* aWorkerPrivate,
const nsCString& aPrefName)
: WorkerMainThreadRunnable(aWorkerPrivate)
: WorkerCheckAPIExposureOnMainThreadRunnable(aWorkerPrivate)
, mEnabled(false)
, mPrefName(aPrefName)
{ }
@@ -749,9 +749,7 @@ nsPerformance::IsEnabled(JSContext* aCx, JSObject* aGlobal)
RefPtr<PrefEnabledRunnable> runnable =
new PrefEnabledRunnable(workerPrivate,
NS_LITERAL_CSTRING("dom.enable_user_timing"));
runnable->Dispatch(workerPrivate->GetJSContext());
return runnable->IsEnabled();
return runnable->Dispatch() && runnable->IsEnabled();
}
/* static */ bool
@@ -768,9 +766,8 @@ nsPerformance::IsObserverEnabled(JSContext* aCx, JSObject* aGlobal)
RefPtr<PrefEnabledRunnable> runnable =
new PrefEnabledRunnable(workerPrivate,
NS_LITERAL_CSTRING("dom.enable_performance_observer"));
runnable->Dispatch(workerPrivate->GetJSContext());
return runnable->IsEnabled();
return runnable->Dispatch() && runnable->IsEnabled();
}
void
+18 -21
View File
@@ -14,30 +14,27 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=913761
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=913761">Mozilla Bug 913761</a>
<script type="application/javascript">
function runTest() {
var transportChannel = new MessageChannel();
transportChannel.port1.onmessage = function (event) {
ok(true, 'Port Returned.');
var portToService = event.data.port;
portToService.onmessage = function (event) {
ok(true, "message received");
SimpleTest.finish();
};
portToService.postMessage('READY?');
}
var serviceChannel = new MessageChannel();
serviceChannel.port1.onmessage = function (event) {
if (event.data == 'READY?') {
this.postMessage('READY!');
}
}
transportChannel.port2.postMessage({ port: serviceChannel.port2}, [serviceChannel.port2]);
var transportChannel = new MessageChannel();
transportChannel.port1.onmessage = function (event) {
ok(true, 'Port Returned.');
var portToService = event.data.port;
portToService.onmessage = function (event) {
ok(true, "message received");
SimpleTest.finish();
};
portToService.postMessage('READY?');
}
var serviceChannel = new MessageChannel();
serviceChannel.port1.onmessage = function (event) {
if (event.data == 'READY?') {
this.postMessage('READY!');
}
}
transportChannel.port2.postMessage({ port: serviceChannel.port2}, [serviceChannel.port2]);
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.messageChannel.enabled", true]]}, runTest);
</script>
</body>
</html>
+1 -1
View File
@@ -107,7 +107,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=912456
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.messageChannel.enabled", true]]}, runTest);
runTest();
</script>
</body>
+1 -1
View File
@@ -524,7 +524,7 @@ function next() {
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.messageChannel.enabled", true]]}, next);
next();
</script>
</body>
</html>
-18
View File
@@ -19,8 +19,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
</div>
<pre id="test">
</pre>
<a href="http://www.example.net?a=b&c=d" id="anchor">foobar</a>
<area href="http://www.example.net?a=b&c=d" id="area">foobar</area>
<script type="application/javascript">
/** Test for Bug 887836 **/
@@ -127,20 +125,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
runTest();
}
function testElement(e) {
ok(e, 'element exists');
ok(e.searchParams, "e.searchParams exists!");
ok(e.searchParams.has('a'), "e.searchParams.has('a')");
is(e.searchParams.get('a'), 'b', "e.searchParams.get('a')");
ok(e.searchParams.has('c'), "e.searchParams.has('c')");
is(e.searchParams.get('c'), 'd', "e.searchParams.get('c')");
e.searchParams.set('e', 'f');
ok(e.href.indexOf('e=f') != 1, 'e is right');
runTest();
}
function testEncoding() {
var encoding = [ [ '1', '1' ],
[ 'a b', 'a+b' ],
@@ -242,8 +226,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
testCopyURLSearchParams,
testParserURLSearchParams,
testURL,
function() { testElement(document.getElementById('anchor')) },
function() { testElement(document.getElementById('area')) },
testEncoding,
testOrdering,
testDelete,
+47 -61
View File
@@ -125,38 +125,6 @@ ThrowInvalidThis(JSContext* aCx, const JS::CallArgs& aArgs,
NamesOfInterfacesWithProtos(aProtoId));
}
bool
ThrowMethodFailed(JSContext* cx, ErrorResult& rv)
{
if (rv.IsUncatchableException()) {
// Nuke any existing exception on aCx, to make sure we're uncatchable.
JS_ClearPendingException(cx);
// Don't do any reporting. Just return false, to create an
// uncatchable exception.
return false;
}
if (rv.IsJSContextException()) {
// Whatever we need to throw is on the JSContext already. We
// can't assert that there is a pending exception on it, though,
// because in the uncatchable exception case there won't be one.
return false;
}
if (rv.IsErrorWithMessage()) {
rv.ReportErrorWithMessage(cx);
return false;
}
if (rv.IsJSException()) {
rv.ReportJSException(cx);
return false;
}
if (rv.IsDOMException()) {
rv.ReportDOMException(cx);
return false;
}
rv.ReportGenericError(cx);
return false;
}
bool
ThrowNoSetterArg(JSContext* aCx, prototypes::ID aProtoId)
{
@@ -222,9 +190,9 @@ ErrorResult::DeserializeMessage(const IPC::Message* aMsg, void** aIter)
}
void
ErrorResult::ReportErrorWithMessage(JSContext* aCx)
ErrorResult::SetPendingExceptionWithMessage(JSContext* aCx)
{
MOZ_ASSERT(mMessage, "ReportErrorWithMessage() can be called only once");
MOZ_ASSERT(mMessage, "SetPendingExceptionWithMessage() can be called only once");
MOZ_ASSERT(mUnionState == HasMessage);
Message* message = mMessage;
@@ -241,6 +209,7 @@ ErrorResult::ReportErrorWithMessage(JSContext* aCx)
argCount > 0 ? args : nullptr);
ClearMessage();
mResult = NS_OK;
}
void
@@ -280,7 +249,7 @@ ErrorResult::ThrowJSException(JSContext* cx, JS::Handle<JS::Value> exn)
}
void
ErrorResult::ReportJSException(JSContext* cx)
ErrorResult::SetPendingJSException(JSContext* cx)
{
MOZ_ASSERT(!mMightHaveUnreportedJSException,
"Why didn't you tell us you planned to handle JS exceptions?");
@@ -295,25 +264,6 @@ ErrorResult::ReportJSException(JSContext* cx)
// what, go ahead and unroot mJSException.
js::RemoveRawValueRoot(cx, &mJSException);
// We no longer have a useful exception but we do want to signal that an error
// occured.
mResult = NS_ERROR_FAILURE;
#ifdef DEBUG
mUnionState = HasNothing;
#endif // DEBUG
}
void
ErrorResult::StealJSException(JSContext* cx,
JS::MutableHandle<JS::Value> value)
{
MOZ_ASSERT(!mMightHaveUnreportedJSException,
"Must call WouldReportJSException unconditionally in all codepaths that might call StealJSException");
MOZ_ASSERT(IsJSException(), "No exception to steal");
MOZ_ASSERT(mUnionState == HasJSException);
value.set(mJSException);
js::RemoveRawValueRoot(cx, &mJSException);
mResult = NS_OK;
#ifdef DEBUG
mUnionState = HasNothing;
@@ -373,14 +323,16 @@ ErrorResult::ThrowDOMException(nsresult rv, const nsACString& message)
}
void
ErrorResult::ReportDOMException(JSContext* cx)
ErrorResult::SetPendingDOMException(JSContext* cx)
{
MOZ_ASSERT(mDOMExceptionInfo, "ReportDOMException() can be called only once");
MOZ_ASSERT(mDOMExceptionInfo,
"SetPendingDOMException() can be called only once");
MOZ_ASSERT(mUnionState == HasDOMExceptionInfo);
dom::Throw(cx, mDOMExceptionInfo->mRv, mDOMExceptionInfo->mMessage);
ClearDOMExceptionInfo();
mResult = NS_OK;
}
void
@@ -414,12 +366,13 @@ ErrorResult::ClearUnionData()
}
void
ErrorResult::ReportGenericError(JSContext* cx)
ErrorResult::SetPendingGenericErrorException(JSContext* cx)
{
MOZ_ASSERT(!IsErrorWithMessage());
MOZ_ASSERT(!IsJSException());
MOZ_ASSERT(!IsDOMException());
dom::Throw(cx, ErrorCode());
mResult = NS_OK;
}
ErrorResult&
@@ -508,6 +461,39 @@ ErrorResult::SuppressException()
mResult = NS_OK;
}
void
ErrorResult::SetPendingException(JSContext* cx)
{
if (IsUncatchableException()) {
// Nuke any existing exception on cx, to make sure we're uncatchable.
JS_ClearPendingException(cx);
// Don't do any reporting. Just return, to create an
// uncatchable exception.
mResult = NS_OK;
return;
}
if (IsJSContextException()) {
// Whatever we need to throw is on the JSContext already. We
// can't assert that there is a pending exception on it, though,
// because in the uncatchable exception case there won't be one.
mResult = NS_OK;
return;
}
if (IsErrorWithMessage()) {
SetPendingExceptionWithMessage(cx);
return;
}
if (IsJSException()) {
SetPendingJSException(cx);
return;
}
if (IsDOMException()) {
SetPendingDOMException(cx);
return;
}
SetPendingGenericErrorException(cx);
}
namespace dom {
bool
@@ -2783,10 +2769,10 @@ ConvertExceptionToPromise(JSContext* cx,
JS_ClearPendingException(cx);
ErrorResult rv;
RefPtr<Promise> promise = Promise::Reject(global, exn, rv);
if (rv.Failed()) {
// We just give up. Make sure to not leak memory on the
// ErrorResult, but then just put the original exception back.
ThrowMethodFailed(cx, rv);
if (rv.MaybeSetPendingException(cx)) {
// We just give up. We put the exception from the ErrorResult on
// the JSContext just to make sure to not leak memory on the
// ErrorResult, but now just put the original exception back.
JS_SetPendingException(cx, exn);
return false;
}
-3
View File
@@ -92,9 +92,6 @@ ThrowInvalidThis(JSContext* aCx, const JS::CallArgs& aArgs,
const ErrNum aErrorNumber,
prototypes::ID aProtoId);
bool
ThrowMethodFailed(JSContext* cx, ErrorResult& rv);
// Returns true if the JSClass is used for DOM objects.
inline bool
IsDOMClass(const JSClass* clasp)
+1
View File
@@ -495,6 +495,7 @@ DOMInterfaces = {
'ExtendableEvent': {
'headerFile': 'mozilla/dom/ServiceWorkerEvents.h',
'nativeType': 'mozilla::dom::workers::ExtendableEvent',
'implicitJSContext': [ 'waitUntil' ],
},
'ExtendableMessageEvent': {
+24 -31
View File
@@ -1724,9 +1724,7 @@ class CGConstructNavigatorObject(CGAbstractMethod):
JS::Rooted<JS::Value> v(aCx);
{ // Scope to make sure |result| goes out of scope while |v| is rooted
RefPtr<mozilla::dom::${descriptorName}> result = ConstructNavigatorObjectHelper(aCx, global, rv);
rv.WouldReportJSException();
if (rv.Failed()) {
ThrowMethodFailed(aCx, rv);
if (rv.MaybeSetPendingException(aCx)) {
return nullptr;
}
if (!GetOrCreateDOMReflector(aCx, result, &v)) {
@@ -4401,11 +4399,13 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
templateBody = "${declName} = &${val}.toObject();\n"
# For JS-implemented APIs, we refuse to allow passing objects that the
# API consumer does not subsume.
# API consumer does not subsume. The extra parens around
# ($${passedToJSImpl}) suppress unreachable code warnings when
# $${passedToJSImpl} is the literal `false`.
if not isinstance(descriptorProvider, Descriptor) or descriptorProvider.interface.isJSImplemented():
templateBody = fill(
"""
if ($${passedToJSImpl} && !CallerSubsumes($${val})) {
if (($${passedToJSImpl}) && !CallerSubsumes($${val})) {
ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "${sourceDescription}");
$*{exceptionCode}
}
@@ -5091,8 +5091,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
}
ErrorResult promiseRv;
$${declName} = Promise::Resolve(promiseGlobal, $${val}, promiseRv);
if (promiseRv.Failed()) {
ThrowMethodFailed(cx, promiseRv);
if (promiseRv.MaybeSetPendingException(cx)) {
$*{exceptionCode}
}
}
@@ -5448,11 +5447,13 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
templateBody = "${declName} = ${val};\n"
# For JS-implemented APIs, we refuse to allow passing objects that the
# API consumer does not subsume.
# API consumer does not subsume. The extra parens around
# ($${passedToJSImpl}) suppress unreachable code warnings when
# $${passedToJSImpl} is the literal `false`.
if not isinstance(descriptorProvider, Descriptor) or descriptorProvider.interface.isJSImplemented():
templateBody = fill(
"""
if ($${passedToJSImpl} && !CallerSubsumes($${val})) {
if (($${passedToJSImpl}) && !CallerSubsumes($${val})) {
ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "${sourceDescription}");
$*{exceptionCode}
}
@@ -6652,23 +6653,18 @@ class CGCallGenerator(CGThing):
A class to generate an actual call to a C++ object. Assumes that the C++
object is stored in a variable whose name is given by the |object| argument.
errorReport should be a CGThing for an error report or None if no
error reporting is needed.
isFallible is a boolean indicating whether the call should be fallible.
resultVar: If the returnType is not void, then the result of the call is
stored in a C++ variable named by resultVar. The caller is responsible for
declaring the result variable. If the caller doesn't care about the result
value, resultVar can be omitted.
"""
def __init__(self, errorReport, arguments, argsPre, returnType,
def __init__(self, isFallible, arguments, argsPre, returnType,
extendedAttributes, descriptorProvider, nativeMethodName,
static, object="self", argsPost=[], resultVar=None):
CGThing.__init__(self)
assert errorReport is None or isinstance(errorReport, CGThing)
isFallible = errorReport is not None
result, resultOutParam, resultRooter, resultArgs, resultConversion = \
getRetvalDeclarationForType(returnType, descriptorProvider)
@@ -6763,10 +6759,12 @@ class CGCallGenerator(CGThing):
if isFallible:
self.cgRoot.prepend(CGGeneric("ErrorResult rv;\n"))
self.cgRoot.append(CGGeneric("rv.WouldReportJSException();\n"))
self.cgRoot.append(CGGeneric("if (MOZ_UNLIKELY(rv.Failed())) {\n"))
self.cgRoot.append(CGIndenter(errorReport))
self.cgRoot.append(CGGeneric("}\n"))
self.cgRoot.append(CGGeneric(dedent(
"""
if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
return false;
}
""")))
self.cgRoot.append(CGGeneric("MOZ_ASSERT(!JS_IsExceptionPending(cx));\n"))
@@ -7160,7 +7158,7 @@ class CGPerSignatureCall(CGThing):
idlNode.identifier.name))
else:
cgThings.append(CGCallGenerator(
self.getErrorReport() if self.isFallible() else None,
self.isFallible(),
self.getArguments(), argsPre, returnType,
self.extendedAttributes, descriptor, nativeMethodName,
static, argsPost=argsPost, resultVar=resultVar))
@@ -7267,9 +7265,6 @@ class CGPerSignatureCall(CGThing):
maybeWrap=getMaybeWrapValueFuncForType(self.idlNode.type))
return wrapCode
def getErrorReport(self):
return CGGeneric('return ThrowMethodFailed(cx, rv);\n')
def define(self):
return (self.cgRoot.define() + self.wrap_return_value())
@@ -7311,7 +7306,7 @@ class CGCase(CGList):
self.append(CGGeneric("case " + expression + ": {\n"))
bodyList = CGList([body])
if fallThrough:
bodyList.append(CGGeneric("/* Fall through */\n"))
bodyList.append(CGGeneric("MOZ_FALLTHROUGH;\n"))
else:
bodyList.append(CGGeneric("break;\n"))
self.append(CGIndenter(bodyList))
@@ -8238,9 +8233,8 @@ class CGEnumerateHook(CGAbstractBindingMethod):
nsAutoTArray<nsString, 8> names;
ErrorResult rv;
self->GetOwnPropertyNames(cx, names, rv);
rv.WouldReportJSException();
if (rv.Failed()) {
return ThrowMethodFailed(cx, rv);
if (rv.MaybeSetPendingException(cx)) {
return false;
}
bool dummy;
for (uint32_t i = 0; i < names.Length(); ++i) {
@@ -10296,9 +10290,8 @@ class CGEnumerateOwnPropertiesViaGetOwnPropertyNames(CGAbstractBindingMethod):
nsAutoTArray<nsString, 8> names;
ErrorResult rv;
self->GetOwnPropertyNames(cx, names, rv);
rv.WouldReportJSException();
if (rv.Failed()) {
return ThrowMethodFailed(cx, rv);
if (rv.MaybeSetPendingException(cx)) {
return false;
}
// OK to pass null as "proxy" because it's ignored if
// shadowPrototypeProperties is true
+81 -29
View File
@@ -6,6 +6,17 @@
/**
* A struct for tracking exceptions that need to be thrown to JS.
*
* Conceptually, an ErrorResult represents either success or an exception in the
* process of being thrown. This means that a failing ErrorResult _must_ be
* handled in one of the following ways before coming off the stack:
*
* 1) Suppressed via SuppressException().
* 2) Converted to a pure nsresult return value via StealNSResult().
* 3) Converted to an actual pending exception on a JSContext via
* MaybeSetPendingException.
* 4) Converted to an exception JS::Value (probably to then reject a Promise
* with) via dom::ToJSValue.
*/
#ifndef mozilla_ErrorResult_h
@@ -61,14 +72,14 @@ struct StringArrayAppender
}
template<typename... Ts>
static void Append(nsTArray<nsString>& aArgs, uint16_t aCount, const nsAString* aFirst, Ts... aOtherArgs)
static void Append(nsTArray<nsString>& aArgs, uint16_t aCount, const nsAString& aFirst, Ts&&... aOtherArgs)
{
if (aCount == 0) {
MOZ_ASSERT(false, "There should not be more string arguments provided than are required by the ErrNum.");
return;
}
aArgs.AppendElement(*aFirst);
Append(aArgs, aCount - 1, aOtherArgs...);
aArgs.AppendElement(aFirst);
Append(aArgs, aCount - 1, Forward<Ts>(aOtherArgs)...);
}
};
@@ -87,8 +98,9 @@ public:
#ifdef DEBUG
~ErrorResult() {
MOZ_ASSERT_IF(IsErrorWithMessage(), !mMessage);
MOZ_ASSERT_IF(IsDOMException(), !mDOMExceptionInfo);
// Consumers should have called one of MaybeSetPendingException
// (possibly via ToJSValue), StealNSResult, and SuppressException
MOZ_ASSERT(!Failed());
MOZ_ASSERT(!mMightHaveUnreportedJSException);
MOZ_ASSERT(mUnionState == HasNothing);
}
@@ -134,33 +146,71 @@ public:
return rv;
}
template<dom::ErrNum errorNumber, typename... Ts>
void ThrowTypeError(Ts... messageArgs)
// Use MaybeSetPendingException to convert an ErrorResult to a pending
// exception on the given JSContext. This is the normal "throw an exception"
// codepath.
//
// The return value is false if the ErrorResult represents success, true
// otherwise. This does mean that in JSAPI method implementations you can't
// just use this as |return rv.MaybeSetPendingException(cx)| (though you could
// |return !rv.MaybeSetPendingException(cx)|), but in practice pretty much any
// consumer would want to do some more work on the success codepath. So
// instead the way you use this is:
//
// if (rv.MaybeSetPendingException(cx)) {
// bail out here
// }
// go on to do something useful
//
// The success path is inline, since it should be the common case and we don't
// want to pay the price of a function call in some of the consumers of this
// method in the common case.
//
// Note that a true return value does NOT mean there is now a pending
// exception on aCx, due to uncatchable exceptions. It should still be
// considered equivalent to a JSAPI failure in terms of what callers should do
// after true is returned.
//
// After this call, the ErrorResult will no longer return true from Failed(),
// since the exception will have moved to the JSContext.
bool MaybeSetPendingException(JSContext* cx)
{
ThrowErrorWithMessage<errorNumber>(NS_ERROR_TYPE_ERR, messageArgs...);
WouldReportJSException();
if (!Failed()) {
return false;
}
SetPendingException(cx);
return true;
}
template<dom::ErrNum errorNumber, typename... Ts>
void ThrowRangeError(Ts... messageArgs)
void ThrowTypeError(Ts&&... messageArgs)
{
ThrowErrorWithMessage<errorNumber>(NS_ERROR_RANGE_ERR, messageArgs...);
ThrowErrorWithMessage<errorNumber>(NS_ERROR_TYPE_ERR,
Forward<Ts>(messageArgs)...);
}
template<dom::ErrNum errorNumber, typename... Ts>
void ThrowRangeError(Ts&&... messageArgs)
{
ThrowErrorWithMessage<errorNumber>(NS_ERROR_RANGE_ERR,
Forward<Ts>(messageArgs)...);
}
void ReportErrorWithMessage(JSContext* cx);
bool IsErrorWithMessage() const { return ErrorCode() == NS_ERROR_TYPE_ERR || ErrorCode() == NS_ERROR_RANGE_ERR; }
// Facilities for throwing a preexisting JS exception value via this
// ErrorResult. The contract is that any code which might end up calling
// ThrowJSException() must call MightThrowJSException() even if no exception
// is being thrown. Code that would call ReportJSException or
// StealJSException as needed must first call WouldReportJSException even if
// is being thrown. Code that conditionally calls ToJSValue on this
// ErrorResult only if Failed() must first call WouldReportJSException even if
// this ErrorResult has not failed.
//
// The exn argument to ThrowJSException can be in any compartment. It does
// not have to be in the compartment of cx. If someone later uses it, they
// will wrap it into whatever compartment they're working in, as needed.
void ThrowJSException(JSContext* cx, JS::Handle<JS::Value> exn);
void ReportJSException(JSContext* cx);
bool IsJSException() const { return ErrorCode() == NS_ERROR_DOM_JS_EXCEPTION; }
// Facilities for throwing a DOMException. If an empty message string is
@@ -169,7 +219,6 @@ public:
// passed in must be one we create DOMExceptions for; otherwise you may get an
// XPConnect Exception.
void ThrowDOMException(nsresult rv, const nsACString& message = EmptyCString());
void ReportDOMException(JSContext* cx);
bool IsDOMException() const { return ErrorCode() == NS_ERROR_DOM_DOMEXCEPTION; }
// Flag on the ErrorResult that whatever needs throwing has been
@@ -183,10 +232,6 @@ public:
return ErrorCode() == NS_ERROR_DOM_EXCEPTION_ON_JSCONTEXT;
}
// Report a generic error. This should only be used if we're not
// some more specific exception type.
void ReportGenericError(JSContext* cx);
// Support for uncatchable exceptions.
void ThrowUncatchableException() {
Throw(NS_ERROR_UNCATCHABLE_EXCEPTION);
@@ -195,11 +240,6 @@ public:
return ErrorCode() == NS_ERROR_UNCATCHABLE_EXCEPTION;
}
// StealJSException steals the JS Exception from the object. This method must
// be called only if IsJSException() returns true. This method also resets the
// error code to NS_OK.
void StealJSException(JSContext* cx, JS::MutableHandle<JS::Value> value);
void MOZ_ALWAYS_INLINE MightThrowJSException()
{
#ifdef DEBUG
@@ -264,7 +304,7 @@ private:
nsTArray<nsString>& CreateErrorMessageHelper(const dom::ErrNum errorNumber, nsresult errorType);
template<dom::ErrNum errorNumber, typename... Ts>
void ThrowErrorWithMessage(nsresult errorType, Ts... messageArgs)
void ThrowErrorWithMessage(nsresult errorType, Ts&&... messageArgs)
{
#if defined(DEBUG) && (defined(__clang__) || defined(__GNUC__))
static_assert(dom::ErrorFormatNumArgs[errorNumber] == sizeof...(messageArgs),
@@ -275,7 +315,8 @@ private:
nsTArray<nsString>& messageArgsArray = CreateErrorMessageHelper(errorNumber, errorType);
uint16_t argCount = dom::GetErrorArgCount(errorNumber);
dom::StringArrayAppender::Append(messageArgsArray, argCount, messageArgs...);
dom::StringArrayAppender::Append(messageArgsArray, argCount,
Forward<Ts>(messageArgs)...);
#ifdef DEBUG
mUnionState = HasMessage;
#endif // DEBUG
@@ -306,6 +347,17 @@ private:
// anymore.
void ClearUnionData();
// Implementation of MaybeSetPendingException for the case when we're a
// failure result.
void SetPendingException(JSContext* cx);
// Methods for setting various specific kinds of pending exceptions.
void SetPendingExceptionWithMessage(JSContext* cx);
void SetPendingJSException(JSContext* cx);
void SetPendingDOMException(JSContext* cx);
void SetPendingGenericErrorException(JSContext* cx);
// Special values of mResult:
// NS_ERROR_TYPE_ERR -- ThrowTypeError() called on us.
// NS_ERROR_RANGE_ERR -- ThrowRangeError() called on us.
@@ -317,11 +369,11 @@ private:
struct Message;
struct DOMExceptionInfo;
// mMessage is set by ThrowErrorWithMessage and reported (and deallocated) by
// ReportErrorWithMessage.
// SetPendingExceptionWithMessage.
// mJSException is set (and rooted) by ThrowJSException and reported
// (and unrooted) by ReportJSException.
// (and unrooted) by SetPendingJSException.
// mDOMExceptionInfo is set by ThrowDOMException and reported
// (and deallocated) by ReportDOMException.
// (and deallocated) by SetPendingDOMException.
union {
Message* mMessage; // valid when IsErrorWithMessage()
JS::Value mJSException; // valid when IsJSException()
+2
View File
@@ -83,3 +83,5 @@ MSG_DEF(MSG_NOTIFICATION_PERMISSION_DENIED, 0, JSEXN_TYPEERR, "Permission to sho
MSG_DEF(MSG_NOTIFICATION_NO_CONSTRUCTOR_IN_SERVICEWORKER, 0, JSEXN_TYPEERR, "Notification constructor cannot be used in ServiceWorkerGlobalScope. Use registration.showNotification() instead.")
MSG_DEF(MSG_INVALID_SCOPE, 2, JSEXN_TYPEERR, "Invalid scope trying to resolve {0} with base URL {1}.")
MSG_DEF(MSG_INVALID_KEYFRAME_OFFSETS, 0, JSEXN_TYPEERR, "Keyframes with specified offsets must be in order and all be in the range [0, 1].")
MSG_DEF(MSG_SW_INSTALL_ERROR, 2, JSEXN_TYPEERR, "ServiceWorker script at {0} for scope {1} encountered an error during installation.")
MSG_DEF(MSG_SW_SCRIPT_THREW, 2, JSEXN_TYPEERR, "ServiceWorker script at {0} for scope {1} threw an exception during script evaluation.")
+2 -2
View File
@@ -56,8 +56,8 @@ ToJSValue(JSContext* aCx,
MOZ_ASSERT(!aArgument.IsUncatchableException(),
"Doesn't make sense to convert uncatchable exception to a JS value!");
AutoForceSetExceptionOnContext forceExn(aCx);
DebugOnly<bool> throwResult = ThrowMethodFailed(aCx, aArgument);
MOZ_ASSERT(!throwResult);
DebugOnly<bool> throwResult = aArgument.MaybeSetPendingException(aCx);
MOZ_ASSERT(throwResult);
DebugOnly<bool> getPendingResult = JS_GetPendingException(aCx, aValue);
MOZ_ASSERT(getPendingResult);
JS_ClearPendingException(aCx);
+1 -44
View File
@@ -13,7 +13,6 @@
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/Preferences.h"
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
@@ -297,50 +296,8 @@ private:
}
};
class PrefEnabledRunnable final : public WorkerMainThreadRunnable
{
public:
explicit PrefEnabledRunnable(WorkerPrivate* aWorkerPrivate)
: WorkerMainThreadRunnable(aWorkerPrivate)
, mEnabled(false)
{ }
bool MainThreadRun() override
{
AssertIsOnMainThread();
mEnabled = Preferences::GetBool("dom.broadcastChannel.enabled", false);
return true;
}
bool IsEnabled() const
{
return mEnabled;
}
private:
bool mEnabled;
};
} // namespace
/* static */ bool
BroadcastChannel::IsEnabled(JSContext* aCx, JSObject* aGlobal)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.broadcastChannel.enabled", false);
}
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
workerPrivate->AssertIsOnWorkerThread();
RefPtr<PrefEnabledRunnable> runnable =
new PrefEnabledRunnable(workerPrivate);
runnable->Dispatch(workerPrivate->GetJSContext());
return runnable->IsEnabled();
}
BroadcastChannel::BroadcastChannel(nsPIDOMWindow* aWindow,
const PrincipalInfo& aPrincipalInfo,
const nsACString& aOrigin,
@@ -431,7 +388,7 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
RefPtr<InitializeRunnable> runnable =
new InitializeRunnable(workerPrivate, origin, principalInfo,
privateBrowsing, aRv);
runnable->Dispatch(cx);
runnable->Dispatch(aRv);
}
if (aRv.Failed()) {
-2
View File
@@ -49,8 +49,6 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BroadcastChannel,
DOMEventTargetHelper)
static bool IsEnabled(JSContext* aCx, JSObject* aGlobal);
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
@@ -1,11 +0,0 @@
onmessage = function() {
var exists = true;
try {
var bc = new BroadcastChannel('foobar');
} catch(e) {
exists = false;
}
postMessage({ exists: exists });
}
-2
View File
@@ -1,7 +1,6 @@
[DEFAULT]
support-files =
iframe_broadcastchannel.html
broadcastchannel_pref_worker.js
broadcastchannel_sharedWorker.js
broadcastchannel_worker.js
broadcastchannel_worker_alive.js
@@ -17,7 +16,6 @@ support-files =
[test_broadcastchannel_basic.html]
[test_broadcastchannel_close.html]
[test_broadcastchannel_self.html]
[test_broadcastchannel_pref.html]
[test_broadcastchannel_sharedWorker.html]
[test_broadcastchannel_worker.html]
[test_broadcastchannel_worker_alive.html]
@@ -130,7 +130,7 @@ function runTest() {
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, runTest);
runTest();
</script>
</body>
@@ -60,7 +60,7 @@ function runTest() {
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, runTest);
runTest();
</script>
</body>
@@ -54,7 +54,7 @@ function runTest() {
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, runTest);
runTest();
</script>
</body>
@@ -84,8 +84,7 @@ var steps = [
},
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true],
["network.disable.ipc.security", true],
SpecialPowers.pushPrefEnv({"set": [["network.disable.ipc.security", true],
["browser.pagethumbnails.capturing_disabled", true],
["dom.mozBrowserFramesEnabled", true],
["dom.ipc.browser_frames.oop_by_default", false],
@@ -84,8 +84,7 @@ var steps = [
},
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true],
["network.disable.ipc.security", true],
SpecialPowers.pushPrefEnv({"set": [["network.disable.ipc.security", true],
["browser.pagethumbnails.capturing_disabled", true],
["dom.mozBrowserFramesEnabled", true],
["dom.ipc.browser_frames.oop_by_default", false],
@@ -1,72 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for BroadcastChannel</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<div id="content"></div>
<script type="application/javascript">
function testNoPref() {
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", false]]}, function() {
ok(!("BroadcastChannel" in window), "BroadcastChannel should not exist");
runTests();
});
}
function testPref() {
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, function() {
ok("BroadcastChannel" in window, "BroadcastChannel should exist");
runTests();
});
}
function testNoPrefWorker() {
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", false]]}, function() {
var worker = new Worker("broadcastchannel_pref_worker.js");
worker.onmessage = function(event) {
ok(!event.data.exists, "BroadcastChannel should not exist in workers");
runTests();
}
worker.postMessage('go!');
});
}
function testPrefWorker() {
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, function() {
var worker = new Worker("broadcastchannel_pref_worker.js");
worker.onmessage = function(event) {
ok(event.data.exists, "BroadcastChannel should exist in workers");
runTests();
}
worker.postMessage('go!');
});
}
var tests = [
testNoPref,
testPref,
testNoPrefWorker,
testPrefWorker
];
function runTests() {
if (tests.length == 0) {
SimpleTest.finish();
return;
}
var test = tests.shift();
test();
}
SimpleTest.waitForExplicitFinish();
runTests();
</script>
</body>
</html>
@@ -109,7 +109,7 @@ function runTest() {
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, runTest);
runTest();
</script>
</body>
@@ -30,7 +30,7 @@ function runTest() {
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, runTest);
runTest();
</script>
</body>
@@ -44,8 +44,7 @@ function runTests() {
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true],
["dom.workers.sharedWorkers.enabled", true]]}, runTests);
SpecialPowers.pushPrefEnv({"set": [["dom.workers.sharedWorkers.enabled", true]]}, runTests);
</script>
</pre>
@@ -54,7 +54,7 @@ function runTests() {
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, runTests);
runTests();
</script>
</pre>
@@ -48,7 +48,7 @@ function runTests() {
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, runTests);
runTests();
</script>
</pre>
+3 -3
View File
@@ -46,8 +46,8 @@ IsValidPutRequestURL(const nsAString& aUrl, ErrorResult& aRv)
}
if (!validScheme) {
NS_NAMED_LITERAL_STRING(label, "Request");
aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(&label, &aUrl);
aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(NS_LITERAL_STRING("Request"),
aUrl);
return false;
}
@@ -61,7 +61,7 @@ IsValidPutRequestMethod(const Request& aRequest, ErrorResult& aRv)
aRequest.GetMethod(method);
if (!method.LowerCaseEqualsLiteral("get")) {
NS_ConvertASCIItoUTF16 label(method);
aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(&label);
aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(label);
return false;
}
+2 -2
View File
@@ -247,8 +247,8 @@ CacheStorage::DefineCaches(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
false, /* private browsing */
true, /* force trusted */
rv);
if (NS_WARN_IF(rv.Failed())) {
return ThrowMethodFailed(aCx, rv);
if (NS_WARN_IF(rv.MaybeSetPendingException(aCx))) {
return false;
}
JS::Rooted<JS::Value> caches(aCx);
+2 -2
View File
@@ -162,9 +162,9 @@ TypeUtils::ToCacheRequest(CacheRequest& aOut, InternalRequest* aIn,
if (!schemeValid) {
if (aSchemeAction == TypeErrorOnInvalidScheme) {
NS_NAMED_LITERAL_STRING(label, "Request");
NS_ConvertUTF8toUTF16 urlUTF16(url);
aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(&label, &urlUTF16);
aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(NS_LITERAL_STRING("Request"),
urlUTF16);
return;
}
}
-3
View File
@@ -1276,8 +1276,6 @@ nsDOMCameraControl::OnHardwareStateChange(CameraControlListener::HardwareState a
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
MOZ_ASSERT(NS_IsMainThread());
ErrorResult ignored;
switch (aState) {
case CameraControlListener::kHardwareOpen:
DOM_CAMERA_LOGI("DOM OnHardwareStateChange: open\n");
@@ -1405,7 +1403,6 @@ nsDOMCameraControl::OnRecorderStateChange(CameraControlListener::RecorderState a
DOM_CAMERA_LOGT("%s:%d : this=%p, state=%u\n", __func__, __LINE__, this, aState);
MOZ_ASSERT(NS_IsMainThread());
ErrorResult ignored;
nsString state;
switch (aState) {
+1
View File
@@ -3998,6 +3998,7 @@ gfxFontGroup *CanvasRenderingContext2D::GetCurrentFontStyle()
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
bool fontUpdated = SetFontInternal(kDefaultFontStyle, err);
if (err.Failed() || !fontUpdated) {
err.SuppressException();
gfxFontStyle style;
style.size = kDefaultFontSize;
gfxTextPerfMetrics* tp = nullptr;
+30 -26
View File
@@ -624,7 +624,7 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, ImageData& aImageData,
aCropRect,
aRv,
getter_AddRefs(data));
task->Dispatch(GetCurrentThreadWorkerPrivate()->GetJSContext());
task->Dispatch(aRv);
}
if (NS_WARN_IF(aRv.Failed())) {
@@ -863,34 +863,37 @@ protected:
{
}
void DoCreateImageBitmapFromBlob(ErrorResult& aRv)
// Returns true on success, false on failure.
bool DoCreateImageBitmapFromBlob()
{
RefPtr<ImageBitmap> imageBitmap = CreateImageBitmap(aRv);
RefPtr<ImageBitmap> imageBitmap = CreateImageBitmap();
// handle errors while creating ImageBitmap
// (1) error occurs during reading of the object
// (2) the image data is not in a supported file format
// (3) the image data is corrupted
// All these three cases should reject promise with null value
if (aRv.Failed()) {
mPromise->MaybeReject(aRv);
return;
if (!imageBitmap) {
return false;
}
if (imageBitmap && mCropRect.isSome()) {
imageBitmap->SetPictureRect(mCropRect.ref(), aRv);
ErrorResult rv;
imageBitmap->SetPictureRect(mCropRect.ref(), rv);
if (aRv.Failed()) {
mPromise->MaybeReject(aRv);
return;
if (rv.Failed()) {
mPromise->MaybeReject(rv);
return false;
}
}
mPromise->MaybeResolve(imageBitmap);
return;
return true;
}
virtual already_AddRefed<ImageBitmap> CreateImageBitmap(ErrorResult& aRv) = 0;
// Will return null on failure. In that case, mPromise will already
// be rejected with the right thing.
virtual already_AddRefed<ImageBitmap> CreateImageBitmap() = 0;
RefPtr<Promise> mPromise;
nsCOMPtr<nsIGlobalObject> mGlobalObject;
@@ -912,17 +915,18 @@ public:
NS_IMETHOD Run() override
{
ErrorResult error;
DoCreateImageBitmapFromBlob(error);
DoCreateImageBitmapFromBlob();
return NS_OK;
}
private:
already_AddRefed<ImageBitmap> CreateImageBitmap(ErrorResult& aRv) override
already_AddRefed<ImageBitmap> CreateImageBitmap() override
{
RefPtr<layers::Image> data = DecodeAndCropBlob(*mBlob, mCropRect, aRv);
ErrorResult rv;
RefPtr<layers::Image> data = DecodeAndCropBlob(*mBlob, mCropRect, rv);
if (NS_WARN_IF(aRv.Failed())) {
if (NS_WARN_IF(rv.Failed())) {
mPromise->MaybeReject(rv);
return nullptr;
}
@@ -957,7 +961,7 @@ class CreateImageBitmapFromBlobWorkerTask final : public WorkerSameThreadRunnabl
RefPtr<layers::Image> image = DecodeAndCropBlob(mBlob, mCropRect, mError);
if (NS_WARN_IF(mError.Failed())) {
return false;
return true;
}
image.forget(mImage);
@@ -984,23 +988,23 @@ public:
bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
{
ErrorResult error;
DoCreateImageBitmapFromBlob(error);
return !(error.Failed());
return DoCreateImageBitmapFromBlob();
}
private:
already_AddRefed<ImageBitmap> CreateImageBitmap(ErrorResult& aRv) override
already_AddRefed<ImageBitmap> CreateImageBitmap() override
{
RefPtr<layers::Image> data;
ErrorResult rv;
RefPtr<DecodeBlobInMainThreadSyncTask> task =
new DecodeBlobInMainThreadSyncTask(mWorkerPrivate, *mBlob, mCropRect,
aRv, getter_AddRefs(data));
task->Dispatch(mWorkerPrivate->GetJSContext()); // This is a synchronous call.
rv, getter_AddRefs(data));
task->Dispatch(rv); // This is a synchronous call.
if (NS_WARN_IF(aRv.Failed())) {
mPromise->MaybeReject(aRv);
if (NS_WARN_IF(rv.Failed())) {
// XXXbz does this really make sense if we're shutting down? Ah, well.
mPromise->MaybeReject(rv);
return nullptr;
}
+1 -1
View File
@@ -26,7 +26,7 @@ TextDecoder::Init(const nsAString& aLabel, const bool aFatal,
if (!EncodingUtils::FindEncodingForLabelNoReplacement(aLabel, encoding)) {
nsAutoString label(aLabel);
EncodingUtils::TrimSpaceCharacters(label);
aRv.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(&label);
aRv.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(label);
return;
}
InitWithEncoding(encoding, aFatal);
+1 -1
View File
@@ -21,7 +21,7 @@ TextEncoder::Init(const nsAString& aEncoding, ErrorResult& aRv)
// If encoding is failure, or is none of utf-8, utf-16, and utf-16be,
// throw a RangeError (https://encoding.spec.whatwg.org/#dom-textencoder).
if (!EncodingUtils::FindEncodingForLabel(label, mEncoding)) {
aRv.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(&label);
aRv.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(label);
return;
}
+2 -2
View File
@@ -54,8 +54,8 @@ xn--wgbh1c=windows-1256
gr=ISO-8859-7
hk=Big5-HKSCS
xn--j6w193g=Big5-HKSCS
hk=Big5
xn--j6w193g=Big5
hr=windows-1250
-1
View File
@@ -5,7 +5,6 @@
# x-unicode is assumed for encodings not listed here
Big5=zh-TW
Big5-HKSCS=zh=HK
EUC-JP=ja
EUC-KR=ko
gb18030=zh-CN
+1 -1
View File
@@ -189,7 +189,7 @@ x-gbk=gbk
gb18030=gb18030
hz-gb-2312=replacement
big5=Big5
big5-hkscs=Big5-HKSCS
big5-hkscs=Big5
cn-big5=Big5
csbig5=Big5
x-x-big5=Big5
+77 -2
View File
@@ -44,6 +44,7 @@ function runTextDecoderOptions()
}, "testDecodeABVOption");
test(testDecoderForThaiEncoding, "testDecoderForThaiEncoding");
test(testInvalid2022JP, "testInvalid2022JP");
test(testDecoderForBig5, "testDecoderForBig5");
}
/*
@@ -355,8 +356,7 @@ function testDecoderGetEncoding()
{encoding: "x-mac-cyrillic", labels: ["x-mac-cyrillic", "x-mac-ukrainian"]},
{encoding: "gbk", labels: ["chinese", "csgb2312", "csiso58gb231280", "gb2312", "gb_2312", "gb_2312-80", "gbk", "iso-ir-58", "x-gbk"]},
{encoding: "gb18030", labels: ["gb18030"]},
{encoding: "big5", labels: ["big5", "cn-big5", "csbig5", "x-x-big5"]},
{encoding: "big5-hkscs", labels: ["big5-hkscs"]},
{encoding: "big5", labels: ["big5", "cn-big5", "csbig5", "x-x-big5", "big5-hkscs"]},
{encoding: "euc-jp", labels: ["cseucpkdfmtjapanese", "euc-jp", "x-euc-jp"]},
{encoding: "iso-2022-jp", labels: ["csiso2022jp", "iso-2022-jp"]},
{encoding: "shift_jis", labels: ["csshiftjis", "ms_kanji", "shift-jis", "shift_jis", "sjis", "windows-31j", "x-sjis"]},
@@ -463,3 +463,78 @@ function testInvalid2022JP()
});
assert_equals(failureCount, 0, failureCount + " of " + inputs.length + " tests failed");
}
function testDecoderForBig5()
{
const inputs = [
[ 0x61, 0x62 ],
[ 0x87, 0x40 ],
[ 0xFE, 0xFE ],
[ 0xFE, 0xFD ],
[ 0x88, 0x62 ],
[ 0x88, 0x64 ],
[ 0x88, 0x66 ],
[ 0x88, 0xA3 ],
[ 0x88, 0xA5 ],
[ 0x88, 0xA7 ],
[ 0x99, 0xD4 ],
[ 0x99, 0xD5 ],
[ 0x99, 0xD6 ],
[ 0x61, 0x87, 0x40, 0x62 ],
[ 0x61, 0xFE, 0xFE, 0x62 ],
[ 0x61, 0xFE, 0xFD, 0x62 ],
[ 0x61, 0x88, 0x62, 0x62 ],
[ 0x61, 0x88, 0x64, 0x62 ],
[ 0x61, 0x88, 0x66, 0x62 ],
[ 0x61, 0x88, 0xA3, 0x62 ],
[ 0x61, 0x88, 0xA5, 0x62 ],
[ 0x61, 0x88, 0xA7, 0x62 ],
[ 0x61, 0x99, 0xD4, 0x62 ],
[ 0x61, 0x99, 0xD5, 0x62 ],
[ 0x61, 0x99, 0xD6, 0x62 ],
[ 0x80, 0x61 ],
[ 0xFF, 0x61 ],
[ 0xFE, 0x39 ],
[ 0x87, 0x66 ],
[ 0x81, 0x40 ],
[ 0x61, 0x81 ],
];
const expectations = [
"\u0061\u0062",
"\u43F0",
"\u79D4",
"\uD864\uDD0D",
"\u00CA\u0304",
"\u00CA\u030C",
"\u00CA",
"\u00EA\u0304",
"\u00EA\u030C",
"\u00EA",
"\u8991",
"\uD85E\uDD67",
"\u8A29",
"\u0061\u43F0\u0062",
"\u0061\u79D4\u0062",
"\u0061\uD864\uDD0D\u0062",
"\u0061\u00CA\u0304\u0062",
"\u0061\u00CA\u030C\u0062",
"\u0061\u00CA\u0062",
"\u0061\u00EA\u0304\u0062",
"\u0061\u00EA\u030C\u0062",
"\u0061\u00EA\u0062",
"\u0061\u8991\u0062",
"\u0061\uD85E\uDD67\u0062",
"\u0061\u8A29\u0062",
"\uFFFD\u0061",
"\uFFFD\u0061",
"\uFFFD\u0039",
"\uFFFD\u0066",
"\uFFFD\u0040",
"\u0061\uFFFD",
];
for (var i = 0; i < inputs.length; i++) {
testCharset({encoding: "big5", input: inputs[i], expected: expectations[i],
msg: "decoder test #" + i + " for big5."});
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=848294
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.messageChannel.enabled", true]]}, runTest);
runTest();
</script>
</body>
</html>
+8 -10
View File
@@ -978,8 +978,14 @@ FetchBody<Derived>::ContinueConsumeBody(nsresult aStatus, uint32_t aResultLength
// FetchBody on the main thread.
RefPtr<CancelPumpRunnable<Derived>> r =
new CancelPumpRunnable<Derived>(this);
if (!r->Dispatch(mWorkerPrivate->GetJSContext())) {
ErrorResult rv;
r->Dispatch(rv);
if (rv.Failed()) {
NS_WARNING("Could not dispatch CancelPumpRunnable. Nothing we can do here");
// None of our callers are callled directly from JS, so there is no
// point in trying to propagate this failure out of here. And
// localPromise is already rejected. Just suppress the failure.
rv.SuppressException();
}
}
}
@@ -1009,7 +1015,6 @@ FetchBody<Derived>::ContinueConsumeBody(nsresult aStatus, uint32_t aResultLength
FetchUtil::ConsumeArrayBuffer(cx, &arrayBuffer, aResultLength, aResult,
error);
error.WouldReportJSException();
if (!error.Failed()) {
JS::Rooted<JS::Value> val(cx);
val.setObjectOrNull(arrayBuffer);
@@ -1024,7 +1029,6 @@ FetchBody<Derived>::ContinueConsumeBody(nsresult aStatus, uint32_t aResultLength
RefPtr<dom::Blob> blob = FetchUtil::ConsumeBlob(
DerivedClass()->GetParentObject(), NS_ConvertUTF8toUTF16(mMimeType),
aResultLength, aResult, error);
error.WouldReportJSException();
if (!error.Failed()) {
localPromise->MaybeResolve(blob);
// File takes over ownership.
@@ -1068,13 +1072,7 @@ FetchBody<Derived>::ContinueConsumeBody(nsresult aStatus, uint32_t aResultLength
error.WouldReportJSException();
if (error.Failed()) {
if (error.IsJSException()) {
JS::Rooted<JS::Value> exn(cx);
error.StealJSException(cx, &exn);
localPromise->MaybeReject(cx, exn);
} else {
localPromise->MaybeReject(error);
}
localPromise->MaybeReject(error);
}
}
+2 -2
View File
@@ -185,7 +185,7 @@ InternalHeaders::IsInvalidName(const nsACString& aName, ErrorResult& aRv)
{
if (!NS_IsValidHTTPToken(aName)) {
NS_ConvertUTF8toUTF16 label(aName);
aRv.ThrowTypeError<MSG_INVALID_HEADER_NAME>(&label);
aRv.ThrowTypeError<MSG_INVALID_HEADER_NAME>(label);
return true;
}
@@ -198,7 +198,7 @@ InternalHeaders::IsInvalidValue(const nsACString& aValue, ErrorResult& aRv)
{
if (!NS_IsReasonableHTTPHeaderValue(aValue)) {
NS_ConvertUTF8toUTF16 label(aValue);
aRv.ThrowTypeError<MSG_INVALID_HEADER_VALUE>(&label);
aRv.ThrowTypeError<MSG_INVALID_HEADER_VALUE>(label);
return true;
}
return false;
+8 -8
View File
@@ -83,7 +83,7 @@ GetRequestURLFromDocument(nsIDocument* aDocument, const nsAString& aInput,
nsCOMPtr<nsIURI> resolvedURI;
aRv = NS_NewURI(getter_AddRefs(resolvedURI), aInput, nullptr, baseURI);
if (NS_WARN_IF(aRv.Failed())) {
aRv.ThrowTypeError<MSG_INVALID_URL>(&aInput);
aRv.ThrowTypeError<MSG_INVALID_URL>(aInput);
return;
}
@@ -92,7 +92,7 @@ GetRequestURLFromDocument(nsIDocument* aDocument, const nsAString& aInput,
nsAutoCString credentials;
Unused << resolvedURI->GetUserPass(credentials);
if (!credentials.IsEmpty()) {
aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(&aInput);
aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(aInput);
return;
}
@@ -122,7 +122,7 @@ GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL,
nsCOMPtr<nsIURI> uri;
aRv = NS_NewURI(getter_AddRefs(uri), aInput, nullptr, nullptr);
if (NS_WARN_IF(aRv.Failed())) {
aRv.ThrowTypeError<MSG_INVALID_URL>(&aInput);
aRv.ThrowTypeError<MSG_INVALID_URL>(aInput);
return;
}
@@ -131,7 +131,7 @@ GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL,
nsAutoCString credentials;
Unused << uri->GetUserPass(credentials);
if (!credentials.IsEmpty()) {
aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(&aInput);
aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(aInput);
return;
}
@@ -164,7 +164,7 @@ GetRequestURLFromWorker(const GlobalObject& aGlobal, const nsAString& aInput,
RefPtr<workers::URL> url =
workers::URL::Constructor(aGlobal, aInput, baseURL, aRv);
if (NS_WARN_IF(aRv.Failed())) {
aRv.ThrowTypeError<MSG_INVALID_URL>(&aInput);
aRv.ThrowTypeError<MSG_INVALID_URL>(aInput);
return;
}
@@ -181,7 +181,7 @@ GetRequestURLFromWorker(const GlobalObject& aGlobal, const nsAString& aInput,
}
if (!username.IsEmpty() || !password.IsEmpty()) {
aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(&aInput);
aRv.ThrowTypeError<MSG_URL_HAS_CREDENTIALS>(aInput);
return;
}
@@ -297,7 +297,7 @@ Request::Constructor(const GlobalObject& aGlobal,
nsresult rv = FetchUtil::GetValidRequestMethod(method, outMethod);
if (NS_FAILED(rv)) {
NS_ConvertUTF8toUTF16 label(method);
aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(&label);
aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(label);
return nullptr;
}
@@ -331,7 +331,7 @@ Request::Constructor(const GlobalObject& aGlobal,
nsAutoCString method;
request->GetMethod(method);
NS_ConvertUTF8toUTF16 label(method);
aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(&label);
aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(label);
return nullptr;
}
+2 -8
View File
@@ -63,13 +63,11 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLAnchorElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLAnchorElement,
nsGenericHTMLElement)
tmp->Link::Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLAnchorElement,
nsGenericHTMLElement)
tmp->Link::Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelList)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@@ -324,17 +322,13 @@ HTMLAnchorElement::RelList()
NS_IMETHODIMP \
HTMLAnchorElement::Get##_part(nsAString& a##_part) \
{ \
ErrorResult rv; \
Link::Get##_part(a##_part, rv); \
MOZ_ASSERT(!rv.Failed()); \
Link::Get##_part(a##_part); \
return NS_OK; \
} \
NS_IMETHODIMP \
HTMLAnchorElement::Set##_part(const nsAString& a##_part) \
{ \
ErrorResult rv; \
Link::Set##_part(a##_part, rv); \
MOZ_ASSERT(!rv.Failed()); \
Link::Set##_part(a##_part); \
return NS_OK; \
}
+18 -20
View File
@@ -89,10 +89,8 @@ public:
virtual bool HasDeferredDNSPrefetchRequest() override;
// WebIDL API
void GetHref(nsAString& aValue, ErrorResult& rv)
{
GetHTMLURIAttr(nsGkAtoms::href, aValue);
}
// The XPCOM GetHref is OK for us
void SetHref(const nsAString& aValue, mozilla::ErrorResult& rv)
{
SetHTMLAttr(nsGkAtoms::href, aValue, rv);
@@ -156,8 +154,8 @@ public:
// Link::GetOrigin is OK for us
using Link::GetProtocol;
using Link::SetProtocol;
// Link::GetProtocol is OK for us
// Link::SetProtocol is OK for us
// Link::GetUsername is OK for us
// Link::SetUsername is OK for us
@@ -165,23 +163,23 @@ public:
// Link::GetPassword is OK for us
// Link::SetPassword is OK for us
using Link::GetHost;
using Link::SetHost;
// Link::Link::GetHost is OK for us
// Link::Link::SetHost is OK for us
using Link::GetHostname;
using Link::SetHostname;
// Link::Link::GetHostname is OK for us
// Link::Link::SetHostname is OK for us
using Link::GetPort;
using Link::SetPort;
// Link::Link::GetPort is OK for us
// Link::Link::SetPort is OK for us
using Link::GetPathname;
using Link::SetPathname;
// Link::Link::GetPathname is OK for us
// Link::Link::SetPathname is OK for us
using Link::GetSearch;
using Link::SetSearch;
// Link::Link::GetSearch is OK for us
// Link::Link::SetSearch is OK for us
using Link::GetHash;
using Link::SetHash;
// Link::Link::GetHash is OK for us
// Link::Link::SetHash is OK for us
// The XPCOM URI decomposition attributes are fine for us
void GetCoords(DOMString& aValue)
@@ -224,9 +222,9 @@ public:
{
SetHTMLAttr(nsGkAtoms::shape, aValue, rv);
}
void Stringify(nsAString& aResult, ErrorResult& aError)
void Stringify(nsAString& aResult)
{
GetHref(aResult, aError);
GetHref(aResult);
}
protected:
+2 -8
View File
@@ -40,13 +40,11 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLAreaElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLAreaElement,
nsGenericHTMLElement)
tmp->Link::Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLAreaElement,
nsGenericHTMLElement)
tmp->Link::Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelList)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@@ -207,17 +205,13 @@ HTMLAreaElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
NS_IMETHODIMP \
HTMLAreaElement::Get##_part(nsAString& a##_part) \
{ \
ErrorResult rv; \
Link::Get##_part(a##_part, rv); \
MOZ_ASSERT(!rv.Failed()); \
Link::Get##_part(a##_part); \
return NS_OK; \
} \
NS_IMETHODIMP \
HTMLAreaElement::Set##_part(const nsAString& a##_part) \
{ \
ErrorResult rv; \
Link::Set##_part(a##_part, rv); \
MOZ_ASSERT(!rv.Failed()); \
Link::Set##_part(a##_part); \
return NS_OK; \
}
+17 -20
View File
@@ -90,10 +90,7 @@ public:
SetHTMLAttr(nsGkAtoms::shape, aShape, aError);
}
void GetHref(nsAString& aHref, ErrorResult& aError)
{
aError = GetHref(aHref);
}
// The XPCOM GetHref is OK for us
void SetHref(const nsAString& aHref, ErrorResult& aError)
{
aError = SetHref(aHref);
@@ -139,8 +136,8 @@ public:
// The Link::GetOrigin is OK for us
using Link::GetProtocol;
using Link::SetProtocol;
// Link::Link::GetProtocol is OK for us
// Link::Link::SetProtocol is OK for us
// The Link::GetUsername is OK for us
// The Link::SetUsername is OK for us
@@ -148,23 +145,23 @@ public:
// The Link::GetPassword is OK for us
// The Link::SetPassword is OK for us
using Link::GetHost;
using Link::SetHost;
// Link::Link::GetHost is OK for us
// Link::Link::SetHost is OK for us
using Link::GetHostname;
using Link::SetHostname;
// Link::Link::GetHostname is OK for us
// Link::Link::SetHostname is OK for us
using Link::GetPort;
using Link::SetPort;
// Link::Link::GetPort is OK for us
// Link::Link::SetPort is OK for us
using Link::GetPathname;
using Link::SetPathname;
// Link::Link::GetPathname is OK for us
// Link::Link::SetPathname is OK for us
using Link::GetSearch;
using Link::SetSearch;
// Link::Link::GetSearch is OK for us
// Link::Link::SetSearch is OK for us
using Link::GetHash;
using Link::SetHash;
// Link::Link::GetHash is OK for us
// Link::Link::SetHash is OK for us
// The Link::GetSearchParams is OK for us
@@ -178,9 +175,9 @@ public:
SetHTMLBoolAttr(nsGkAtoms::nohref, aValue, aError);
}
void Stringify(nsAString& aResult, ErrorResult& aError)
void Stringify(nsAString& aResult)
{
GetHref(aResult, aError);
GetHref(aResult);
}
protected:
-2
View File
@@ -49,7 +49,6 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLLinkElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLLinkElement,
nsGenericHTMLElement)
tmp->nsStyleLinkElement::Traverse(cb);
tmp->Link::Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImportLoader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@@ -57,7 +56,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLLinkElement,
nsGenericHTMLElement)
tmp->nsStyleLinkElement::Unlink();
tmp->Link::Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelList)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mImportLoader)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+1
View File
@@ -2380,6 +2380,7 @@ HTMLMediaElement::WakeLockRelease()
if (mWakeLock) {
ErrorResult rv;
mWakeLock->Unlock(rv);
rv.SuppressException();
mWakeLock = nullptr;
}
}
+23 -3
View File
@@ -42,6 +42,7 @@ NS_IMPL_ELEMENT_CLONE(HTMLVideoElement)
HTMLVideoElement::HTMLVideoElement(already_AddRefed<NodeInfo>& aNodeInfo)
: HTMLMediaElement(aNodeInfo)
, mUseScreenWakeLock(true)
{
}
@@ -186,7 +187,11 @@ double HTMLVideoElement::MozFrameDelay()
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
VideoFrameContainer* container = GetVideoFrameContainer();
return container ? container->GetFrameDelay() : 0;
// Hide negative delays. Frame timing tweaks in the compositor (e.g.
// adding a bias value to prevent multiple dropped/duped frames when
// frame times are aligned with composition times) may produce apparent
// negative delay, but we shouldn't report that.
return container ? std::max(0.0, container->GetFrameDelay()) : 0.0;
}
bool HTMLVideoElement::MozHasAudio() const
@@ -195,6 +200,19 @@ bool HTMLVideoElement::MozHasAudio() const
return HasAudio();
}
bool HTMLVideoElement::MozUseScreenWakeLock() const
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
return mUseScreenWakeLock;
}
void HTMLVideoElement::SetMozUseScreenWakeLock(bool aValue)
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
mUseScreenWakeLock = aValue;
UpdateScreenWakeLock();
}
JSObject*
HTMLVideoElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
@@ -259,14 +277,16 @@ HTMLVideoElement::UpdateScreenWakeLock()
{
bool hidden = OwnerDoc()->Hidden();
if (mScreenWakeLock && (mPaused || hidden)) {
if (mScreenWakeLock && (mPaused || hidden || !mUseScreenWakeLock)) {
ErrorResult rv;
mScreenWakeLock->Unlock(rv);
rv.SuppressException();
mScreenWakeLock = nullptr;
return;
}
if (!mScreenWakeLock && !mPaused && !hidden && HasVideo()) {
if (!mScreenWakeLock && !mPaused && !hidden &&
mUseScreenWakeLock && HasVideo()) {
RefPtr<power::PowerManagerService> pmService =
power::PowerManagerService::GetInstance();
NS_ENSURE_TRUE_VOID(pmService);
+5
View File
@@ -124,6 +124,10 @@ public:
bool MozHasAudio() const;
bool MozUseScreenWakeLock() const;
void SetMozUseScreenWakeLock(bool aValue);
bool NotifyOwnerDocumentActivityChangedInternal() override;
already_AddRefed<VideoPlaybackQuality> GetVideoPlaybackQuality();
@@ -137,6 +141,7 @@ protected:
virtual void WakeLockRelease() override;
void UpdateScreenWakeLock();
bool mUseScreenWakeLock;
RefPtr<WakeLock> mScreenWakeLock;
private:
+5 -30
View File
@@ -694,16 +694,10 @@ nsFSTextPlain::GetEncodedSubmission(nsIURI* aURI,
nsEncodingFormSubmission::nsEncodingFormSubmission(const nsACString& aCharset,
nsIContent* aOriginatingElement)
: nsFormSubmission(aCharset, aOriginatingElement)
, mEncoder(aCharset)
{
nsAutoCString charset(aCharset);
// canonical name is passed so that we just have to check against
// *our* canonical names listed in charsetaliases.properties
if (charset.EqualsLiteral("ISO-8859-1")) {
charset.AssignLiteral("windows-1252");
}
if (!(charset.EqualsLiteral("UTF-8") || charset.EqualsLiteral("gb18030"))) {
NS_ConvertUTF8toUTF16 charsetUtf16(charset);
if (!(aCharset.EqualsLiteral("UTF-8") || aCharset.EqualsLiteral("gb18030"))) {
NS_ConvertUTF8toUTF16 charsetUtf16(aCharset);
const char16_t* charsetPtr = charsetUtf16.get();
SendJSWarning(aOriginatingElement ? aOriginatingElement->GetOwnerDocument()
: nullptr,
@@ -711,18 +705,6 @@ nsEncodingFormSubmission::nsEncodingFormSubmission(const nsACString& aCharset,
&charsetPtr,
1);
}
mEncoder = do_CreateInstance(NS_SAVEASCHARSET_CONTRACTID);
if (mEncoder) {
nsresult rv =
mEncoder->Init(charset.get(),
(nsISaveAsCharset::attr_EntityAfterCharsetConv +
nsISaveAsCharset::attr_FallbackDecimalNCR),
0);
if (NS_FAILED(rv)) {
mEncoder = nullptr;
}
}
}
nsEncodingFormSubmission::~nsEncodingFormSubmission()
@@ -734,15 +716,8 @@ nsresult
nsEncodingFormSubmission::EncodeVal(const nsAString& aStr, nsCString& aOut,
bool aHeaderEncode)
{
if (mEncoder && !aStr.IsEmpty()) {
aOut.Truncate();
nsresult rv = mEncoder->Convert(PromiseFlatString(aStr).get(),
getter_Copies(aOut));
NS_ENSURE_SUCCESS(rv, rv);
}
else {
// fall back to UTF-8
CopyUTF16toUTF8(aStr, aOut);
if (!mEncoder.Encode(aStr, aOut)) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (aHeaderEncode) {
+2 -2
View File
@@ -10,11 +10,11 @@
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsIContent.h"
#include "nsNCRFallbackEncoderWrapper.h"
class nsIURI;
class nsIInputStream;
class nsGenericHTMLElement;
class nsISaveAsCharset;
class nsIMultiplexInputStream;
namespace mozilla {
@@ -140,7 +140,7 @@ public:
private:
// The encoder that will encode Unicode names and values
nsCOMPtr<nsISaveAsCharset> mEncoder;
nsNCRFallbackEncoderWrapper mEncoder;
};
/**
+40 -10
View File
@@ -52,6 +52,7 @@
#include "nsRuleData.h"
#include "nsIPrincipal.h"
#include "nsContainerFrame.h"
#include "nsStyleUtil.h"
#include "nsPresState.h"
#include "nsILayoutHistoryState.h"
@@ -404,7 +405,7 @@ nsGenericHTMLElement::GetOffsetRect(CSSIntRect& aRect)
// Subtract the parent border unless it uses border-box sizing.
if (parent &&
parent->StylePosition()->mBoxSizing != NS_STYLE_BOX_SIZING_BORDER) {
parent->StylePosition()->mBoxSizing != StyleBoxSizing::Border) {
const nsStyleBorder* border = parent->StyleBorder();
origin.x -= border->GetComputedBorderWidth(NS_SIDE_LEFT);
origin.y -= border->GetComputedBorderWidth(NS_SIDE_TOP);
@@ -1300,6 +1301,43 @@ nsGenericHTMLElement::ParseScrollingValue(const nsAString& aString,
return aResult.ParseEnumValue(aString, kScrollingTable, false);
}
static inline void
MapLangAttributeInto(const nsMappedAttributes* aAttributes, nsRuleData* aData)
{
if (!(aData->mSIDs & (NS_STYLE_INHERIT_BIT(Font) |
NS_STYLE_INHERIT_BIT(Text)))) {
return;
}
const nsAttrValue* langValue = aAttributes->GetAttr(nsGkAtoms::lang);
if (!langValue || langValue->Type() != nsAttrValue::eString) {
return;
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
nsCSSValue* lang = aData->ValueForLang();
if (lang->GetUnit() == eCSSUnit_Null) {
lang->SetStringValue(langValue->GetStringValue(), eCSSUnit_Ident);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
nsCSSValue* emphasisPos = aData->ValueForTextEmphasisPosition();
if (emphasisPos->GetUnit() == eCSSUnit_Null) {
const nsAString& lang = langValue->GetStringValue();
if (nsStyleUtil::MatchesLanguagePrefix(lang, MOZ_UTF16("zh"))) {
emphasisPos->SetIntValue(NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT_ZH,
eCSSUnit_Enumerated);
} else if (nsStyleUtil::MatchesLanguagePrefix(lang, MOZ_UTF16("ja")) ||
nsStyleUtil::MatchesLanguagePrefix(lang, MOZ_UTF16("mn"))) {
// This branch is currently no part of the spec.
// See bug 1040668 comment 69 and comment 75.
emphasisPos->SetIntValue(NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT,
eCSSUnit_Enumerated);
}
}
}
}
/**
* Handle attributes common to all html elements
*/
@@ -1326,15 +1364,7 @@ nsGenericHTMLElement::MapCommonAttributesIntoExceptHidden(const nsMappedAttribut
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
nsCSSValue* lang = aData->ValueForLang();
if (lang->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::lang);
if (value && value->Type() == nsAttrValue::eString) {
lang->SetStringValue(value->GetStringValue(), eCSSUnit_Ident);
}
}
}
MapLangAttributeInto(aAttributes, aData);
}
void
+1 -2
View File
@@ -182,8 +182,7 @@ nsHTMLDNSPrefetch::CancelPrefetch(Link *aElement,
return NS_ERROR_NOT_AVAILABLE;
nsAutoString hostname;
ErrorResult rv;
aElement->GetHostname(hostname, rv);
aElement->GetHostname(hostname);
return CancelPrefetch(hostname, flags, aReason);
}
+1
View File
@@ -13,3 +13,4 @@ support-files =
file_bug1108547-1.html
file_bug1108547-2.html
file_bug1108547-3.html
[browser_DOMDocElementInserted.js]
@@ -0,0 +1,24 @@
// Tests that the DOMDocElementInserted event is visible on the frame
add_task(function*() {
let tab = gBrowser.addTab();
let uri = "data:text/html;charset=utf-8,<html/>"
let eventPromise = ContentTask.spawn(tab.linkedBrowser, null, function() {
Cu.import("resource://gre/modules/PromiseUtils.jsm");
let deferred = PromiseUtils.defer();
let listener = (event) => {
removeEventListener("DOMDocElementInserted", listener, true);
deferred.resolve(event.target.documentURIObject.spec);
};
addEventListener("DOMDocElementInserted", listener, true);
return deferred.promise;
});
tab.linkedBrowser.loadURI(uri);
let loadedURI = yield eventPromise;
is(loadedURI, uri, "Should have seen the event for the right URI");
gBrowser.removeTab(tab);
});
+55 -2
View File
@@ -31,6 +31,7 @@ function testVideoPlayPause() {
var content = document.getElementById('content');
var video = document.createElement('video');
ok(video.mozUseScreenWakeLock, "#1 Video element uses screen wake lock by default");
video.src = "wakelock.ogv";
content.appendChild(video);
@@ -83,6 +84,7 @@ function testVideoPlay() {
var content = document.getElementById('content');
var video = document.createElement('video');
ok(video.mozUseScreenWakeLock, "#2 Video element uses screen wake lock by default");
video.src = "wakelock.ogv";
content.appendChild(video);
@@ -124,7 +126,57 @@ function testVideoPlay() {
video.play();
}
var tests = [ testVideoPlayPause, testVideoPlay ];
function testVideoNoScreenWakeLock() {
info("#3 testVideoNoScreenWakeLock");
var lockState_cpu = true;
var lockState_screen = false;
var count_cpu = 0;
var content = document.getElementById('content');
var video = document.createElement('video');
video.mozUseScreenWakeLock = false;
video.src = "wakelock.ogv";
content.appendChild(video);
var startDate;
function testVideoNoScreenWakeLockListener(topic, state) {
info("#3 topic=" + topic + ", state=" + state);
var locked = state == "locked-foreground" ||
state == "locked-background";
if (topic == "cpu") {
is(locked, lockState_cpu, "#3 Video element locked the cpu");
count_cpu++;
} else if (topic == "screen") {
is(locked, lockState_screen, "#3 Video element locked the screen");
}
if (count_cpu == 1) {
info("#3 Cpu is locked");
// The next step is to unlock the resource.
lockState_cpu = false;
video.pause();
startDate = new Date();
}
if (count_cpu == 2) {
var diffDate = (new Date() - startDate);
ok(diffDate > 200, "#3 There was at least 200 milliseconds between the stop and the wakelock release");
content.removeChild(video);
navigator.mozPower.removeWakeLockListener(testVideoNoScreenWakeLockListener);
runTests();
}
}
navigator.mozPower.addWakeLockListener(testVideoNoScreenWakeLockListener);
video.play();
}
var tests = [ testVideoPlayPause, testVideoPlay, testVideoNoScreenWakeLock ];
function runTests() {
if (!tests.length) {
SimpleTest.finish();
@@ -138,7 +190,8 @@ function runTests() {
SpecialPowers.pushPermissions(
[{'type': 'power', 'allow': true, 'context': document}],
function() {
SpecialPowers.pushPrefEnv({"set": [["media.wakelock_timeout", 500]]}, runTests);
SpecialPowers.pushPrefEnv({"set": [["media.wakelock_timeout", 500],
["dom.wakelock.enabled", true]]}, runTests);
});
SimpleTest.waitForExplicitFinish();
@@ -5,10 +5,7 @@ support-files =
[test_Document-createElement-namespace.html.json]
[test_Document-createElementNS.html.json]
[test_Document-getElementsByTagName.html.json]
[test_Node-isEqualNode.xhtml.json]
[test_Node-properties.html.json]
[test_attributes.html.json]
[test_case.html.json]
[test_getElementsByClassName-10.xml.json]
[test_getElementsByClassName-11.xml.json]
@@ -1,4 +0,0 @@
{
"Document.getElementsByTagName 1": true,
"Document.getElementsByTagName 2": true
}
@@ -1,3 +0,0 @@
{
"isEqualNode should return true when only the internal subsets of DocumentTypes differ.": true
}
@@ -1,7 +1,5 @@
{
"getElementsByTagName abc": true,
"getElementsByTagName Abc": true,
"getElementsByTagName ABC": true,
"getElementsByTagName \u00e4": true,
"getElementsByTagName \u00c4": true
"getElementsByTagName ABC": true
}
@@ -1,3 +0,0 @@
{
"document.getElementsByClassName(): compound": true
}
@@ -21,20 +21,45 @@ interface nsIServiceWorkerUnregisterCallback : nsISupports
void unregisterFailed();
};
[scriptable, builtinclass, uuid(e633b73b-a734-4d04-a09c-b7779a439f3f)]
[scriptable, builtinclass, uuid(1a1e71dd-0f78-4e2e-a2db-a946fe02cddf)]
interface nsIServiceWorkerInfo : nsISupports
{
readonly attribute DOMString scriptSpec;
readonly attribute DOMString cacheName;
};
[scriptable, uuid(87e63548-d440-4b8a-b158-65ad1de0211E)]
interface nsIServiceWorkerRegistrationInfoListener : nsISupports
{
void onChange();
};
[scriptable, builtinclass, uuid(72faba24-0a1b-4284-bad3-d44c044d6d95)]
interface nsIServiceWorkerRegistrationInfo : nsISupports
{
readonly attribute nsIPrincipal principal;
readonly attribute DOMString scope;
readonly attribute DOMString scriptSpec;
readonly attribute DOMString currentWorkerURL;
readonly attribute DOMString activeCacheName;
readonly attribute DOMString waitingCacheName;
readonly attribute nsIServiceWorkerInfo installingWorker;
readonly attribute nsIServiceWorkerInfo waitingWorker;
readonly attribute nsIServiceWorkerInfo activeWorker;
void addListener(in nsIServiceWorkerRegistrationInfoListener listener);
void removeListener(in nsIServiceWorkerRegistrationInfoListener listener);
};
[scriptable, builtinclass, uuid(10f80c8c-7bf5-479e-a8d8-12ef50c802e8)]
[scriptable, uuid(9e523e7c-ad6f-4df0-8077-c74aebbc679d)]
interface nsIServiceWorkerManagerListener : nsISupports
{
void onRegister(in nsIServiceWorkerRegistrationInfo aInfo);
void onUnregister(in nsIServiceWorkerRegistrationInfo aInfo);
};
[scriptable, builtinclass, uuid(2f61820a-1e9a-4c16-bf1c-ce182c5f5d6d)]
interface nsIServiceWorkerManager : nsISupports
{
/**
@@ -113,7 +138,7 @@ interface nsIServiceWorkerManager : nsISupports
DOMString getScopeForUrl(in nsIPrincipal aPrincipal, in DOMString aPath);
// Note: This is meant to be used only by about:serviceworkers.
//It returns an array of nsIServiceWorkerInfo.
// It returns an array of nsIServiceWorkerRegistrationInfos.
nsIArray getAllRegistrations();
// Note: This is meant to be used only by about:serviceworkers.
@@ -145,6 +170,10 @@ interface nsIServiceWorkerManager : nsISupports
[optional, array, size_is(aDataLength)] in uint8_t aDataBytes);
void sendPushSubscriptionChangeEvent(in ACString aOriginAttributes,
in ACString scope);
void addListener(in nsIServiceWorkerManagerListener aListener);
void removeListener(in nsIServiceWorkerManagerListener aListener);
};
%{ C++
+4 -4
View File
@@ -881,8 +881,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
renderFrame = nullptr;
}
ShowInfo showInfo(EmptyString(), false, false, true,
aTabOpener->mDPI, aTabOpener->mDefaultScale);
ShowInfo showInfo(EmptyString(), false, false, true, 0, 0);
nsCOMPtr<nsPIDOMWindow> opener = do_QueryInterface(aParent);
nsIDocShell* openerShell;
if (opener && (openerShell = opener->GetDocShell())) {
@@ -2173,8 +2172,7 @@ ContentChild::ActorDestroy(ActorDestroyReason why)
// going through the full XPCOM shutdown path, because it doesn't
// keep persistent state.
QuickExit();
#endif
#else
if (sFirstIdleTask) {
sFirstIdleTask->Cancel();
}
@@ -2199,6 +2197,7 @@ ContentChild::ActorDestroy(ActorDestroyReason why)
#endif
XRE_ShutdownChildProcess();
#endif // NS_FREE_PERMANENT_DATA
}
void
@@ -3014,6 +3013,7 @@ ContentChild::AllocPContentPermissionRequestChild(const InfallibleTArray<Permiss
bool
ContentChild::DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor)
{
nsContentPermissionUtils::NotifyRemoveContentPermissionRequestChild(actor);
auto child = static_cast<RemotePermissionRequest*>(actor);
child->IPDLRelease();
return true;
+1 -4
View File
@@ -2260,10 +2260,7 @@ ContentParent::NotifyTabDestroyed(const TabId& aTabId,
// Need to close undeleted ContentPermissionRequestParents before tab is closed.
for (auto& permissionRequestParent : parentArray) {
nsTArray<PermissionChoice> emptyChoices;
Unused << PContentPermissionRequestParent::Send__delete__(permissionRequestParent,
false,
emptyChoices);
Unused << PContentPermissionRequestParent::Send__delete__(permissionRequestParent);
}
// There can be more than one PBrowser for a given app process
+3 -1
View File
@@ -15,10 +15,12 @@ protocol PContentPermissionRequest
parent:
prompt();
NotifyVisibility(bool visibility);
Destroy();
child:
GetVisibility();
__delete__(bool allow, PermissionChoice[] choices);
NotifyResult(bool allow, PermissionChoice[] choices);
__delete__();
};
+10 -1
View File
@@ -96,6 +96,7 @@
#include "nsIOService.h"
#include "nsDOMClassInfoID.h"
#include "nsColorPickerProxy.h"
#include "nsContentPermissionHelper.h"
#include "nsPresShell.h"
#include "nsIAppsService.h"
#include "nsNetUtil.h"
@@ -2101,7 +2102,6 @@ TabChild::DeallocPIndexedDBPermissionRequestChild(
PIndexedDBPermissionRequestChild* aActor)
{
MOZ_ASSERT(aActor);
delete aActor;
return true;
}
@@ -2213,6 +2213,15 @@ TabChild::RecvDestroy()
MOZ_ASSERT(mDestroyed == false);
mDestroyed = true;
nsTArray<PContentPermissionRequestChild*> childArray =
nsContentPermissionUtils::GetContentPermissionRequestChildById(GetTabId());
// Need to close undeleted ContentPermissionRequestChilds before tab is closed.
for (auto& permissionRequestChild : childArray) {
auto child = static_cast<RemotePermissionRequest*>(permissionRequestChild);
child->Destroy();
}
if (mTabChildGlobal) {
// Message handlers are called from the event loop, so it better be safe to
// run script.
+2 -1
View File
@@ -957,7 +957,7 @@ MediaRecorder::Constructor(const GlobalObject& aGlobal,
// Pretending that this constructor is not defined.
NS_NAMED_LITERAL_STRING(argStr, "Argument 1 of MediaRecorder.constructor");
NS_NAMED_LITERAL_STRING(typeStr, "MediaStream");
aRv.ThrowTypeError<MSG_DOES_NOT_IMPLEMENT_INTERFACE>(&argStr, &typeStr);
aRv.ThrowTypeError<MSG_DOES_NOT_IMPLEMENT_INTERFACE>(argStr, typeStr);
return nullptr;
}
@@ -1129,6 +1129,7 @@ MediaRecorder::NotifyOwnerDocumentActivityChanged()
// Stop the session.
ErrorResult result;
Stop(result);
result.SuppressException();
}
}
-1
View File
@@ -236,7 +236,6 @@ function setupEnvironment() {
SpecialPowers.pushPrefEnv({
'set': [
['canvas.capturestream.enabled', true],
['dom.messageChannel.enabled', true],
['media.peerconnection.enabled', true],
['media.peerconnection.identity.enabled', true],
['media.peerconnection.identity.timeout', 12000],
@@ -105,8 +105,7 @@ function testMultipleFingerprints() {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
set: [ [ 'dom.messageChannel.enabled', true ],
[ 'media.peerconnection.identity.enabled', true ] ]
set: [ [ 'media.peerconnection.identity.enabled', true ] ]
}, testMultipleFingerprints);
</script>
</body>
@@ -162,9 +162,7 @@ function run_all_tests() {
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
set: [ [ 'dom.messageChannel.enabled', true ] ]
}, run_all_tests);
run_all_tests();
</script>
</body>
</html>
-144
View File
@@ -6,7 +6,6 @@
#include "MessageChannel.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/MessageChannelBinding.h"
#include "mozilla/dom/MessagePort.h"
#include "mozilla/dom/Navigator.h"
@@ -30,149 +29,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MessageChannel)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
namespace {
bool gPrefInitialized = false;
bool gPrefEnabled = false;
bool
CheckPermission(nsIPrincipal* aPrincipal, bool aCallerChrome)
{
MOZ_ASSERT(NS_IsMainThread());
if (!gPrefInitialized) {
Preferences::AddBoolVarCache(&gPrefEnabled, "dom.messageChannel.enabled");
gPrefInitialized = true;
}
// Enabled by pref
if (gPrefEnabled) {
return true;
}
// Chrome callers are allowed.
if (aCallerChrome) {
return true;
}
nsCOMPtr<nsIURI> uri;
if (NS_FAILED(aPrincipal->GetURI(getter_AddRefs(uri))) || !uri) {
return false;
}
bool isResource = false;
if (NS_FAILED(uri->SchemeIs("resource", &isResource))) {
return false;
}
return isResource;
}
nsIPrincipal*
GetPrincipalFromWorkerPrivate(workers::WorkerPrivate* aWorkerPrivate)
{
MOZ_ASSERT(NS_IsMainThread());
nsIPrincipal* principal = aWorkerPrivate->GetPrincipal();
if (principal) {
return principal;
}
// Walk up to our containing page
workers::WorkerPrivate* wp = aWorkerPrivate;
while (wp->GetParent()) {
wp = wp->GetParent();
}
nsPIDOMWindow* window = wp->GetWindow();
if (!window) {
return nullptr;
}
nsIDocument* doc = window->GetExtantDoc();
if (!doc) {
return nullptr;
}
return doc->NodePrincipal();
}
// A WorkerMainThreadRunnable to synchronously dispatch the call of
// CheckPermission() from the worker thread to the main thread.
class CheckPermissionRunnable final : public workers::WorkerMainThreadRunnable
{
public:
bool mResult;
bool mCallerChrome;
explicit CheckPermissionRunnable(workers::WorkerPrivate* aWorkerPrivate)
: workers::WorkerMainThreadRunnable(aWorkerPrivate)
, mResult(false)
, mCallerChrome(false)
{
MOZ_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread();
mCallerChrome = aWorkerPrivate->UsesSystemPrincipal();
}
protected:
virtual bool
MainThreadRun() override
{
MOZ_ASSERT(NS_IsMainThread());
nsIPrincipal* principal = GetPrincipalFromWorkerPrivate(mWorkerPrivate);
if (!principal) {
return true;
}
bool isNullPrincipal;
nsresult rv = principal->GetIsNullPrincipal(&isNullPrincipal);
if (NS_WARN_IF(NS_FAILED(rv))) {
return true;
}
if (NS_WARN_IF(isNullPrincipal)) {
return true;
}
mResult = CheckPermission(principal, mCallerChrome);
return true;
}
};
} // anonymous namespace
/* static */ bool
MessageChannel::Enabled(JSContext* aCx, JSObject* aGlobal)
{
if (NS_IsMainThread()) {
JS::Rooted<JSObject*> global(aCx, aGlobal);
nsCOMPtr<nsPIDOMWindow> win = Navigator::GetWindowFromGlobal(global);
if (!win) {
return false;
}
nsIDocument* doc = win->GetExtantDoc();
if (!doc) {
return false;
}
return CheckPermission(doc->NodePrincipal(),
nsContentUtils::IsCallerChrome());
}
workers::WorkerPrivate* workerPrivate =
workers::GetWorkerPrivateFromContext(aCx);
workerPrivate->AssertIsOnWorkerThread();
RefPtr<CheckPermissionRunnable> runnable =
new CheckPermissionRunnable(workerPrivate);
runnable->Dispatch(aCx);
return runnable->mResult;
}
MessageChannel::MessageChannel(nsPIDOMWindow* aWindow)
: mWindow(aWindow)
{

Some files were not shown because too many files have changed in this diff Show More