Loading dom/base/ScreenOrientation.cpp +14 −14 Original line number Diff line number Diff line Loading @@ -626,7 +626,7 @@ void ScreenOrientation::CleanupFullscreenListener() { OrientationType ScreenOrientation::DeviceType(CallerType aCallerType) const { if (nsContentUtils::ShouldResistFingerprinting( aCallerType, GetOwnerGlobal(), RFPTarget::ScreenOrientation)) { return OrientationType::Landscape_primary; return nsRFPService::OrientationSecondaryToPrimary(mType); } return mType; } Loading @@ -634,18 +634,13 @@ OrientationType ScreenOrientation::DeviceType(CallerType aCallerType) const { uint16_t ScreenOrientation::DeviceAngle(CallerType aCallerType) const { if (nsContentUtils::ShouldResistFingerprinting( aCallerType, GetOwnerGlobal(), RFPTarget::ScreenOrientation)) { return 0; return nsRFPService::OrientationSecondaryToPrimary(mAngle); } return mAngle; } OrientationType ScreenOrientation::GetType(CallerType aCallerType, ErrorResult& aRv) const { if (nsContentUtils::ShouldResistFingerprinting( aCallerType, GetOwnerGlobal(), RFPTarget::ScreenOrientation)) { return OrientationType::Landscape_primary; } Document* doc = GetResponsibleDocument(); BrowsingContext* bc = doc ? doc->GetBrowsingContext() : nullptr; if (!bc) { Loading @@ -653,16 +648,16 @@ OrientationType ScreenOrientation::GetType(CallerType aCallerType, return OrientationType::Portrait_primary; } return bc->GetCurrentOrientationType(); } uint16_t ScreenOrientation::GetAngle(CallerType aCallerType, ErrorResult& aRv) const { OrientationType orientation = bc->GetCurrentOrientationType(); if (nsContentUtils::ShouldResistFingerprinting( aCallerType, GetOwnerGlobal(), RFPTarget::ScreenOrientation)) { return 0; return nsRFPService::OrientationSecondaryToPrimary(orientation); } return orientation; } uint16_t ScreenOrientation::GetAngle(CallerType aCallerType, ErrorResult& aRv) const { Document* doc = GetResponsibleDocument(); BrowsingContext* bc = doc ? doc->GetBrowsingContext() : nullptr; if (!bc) { Loading @@ -670,7 +665,12 @@ uint16_t ScreenOrientation::GetAngle(CallerType aCallerType, return 0; } return bc->GetCurrentOrientationAngle(); uint16_t angle = static_cast<uint16_t>(bc->GetCurrentOrientationAngle()); if (nsContentUtils::ShouldResistFingerprinting( aCallerType, GetOwnerGlobal(), RFPTarget::ScreenOrientation)) { return nsRFPService::OrientationSecondaryToPrimary(angle); } return angle; } ScreenOrientation::LockPermission Loading dom/base/nsGlobalWindowInner.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -7306,11 +7306,12 @@ void nsGlobalWindowInner::InitWasOffline() { mWasOffline = NS_IsOffline(); } int16_t nsGlobalWindowInner::Orientation(CallerType aCallerType) { // GetOrientationAngle() returns 0, 90, 180 or 270. // window.orientation returns -90, 0, 90 or 180. uint16_t screenAngle = Screen()->GetOrientationAngle(); if (nsIGlobalObject::ShouldResistFingerprinting( aCallerType, RFPTarget::ScreenOrientation)) { return 0; screenAngle = nsRFPService::OrientationSecondaryToPrimary(screenAngle); } int16_t angle = AssertedCast<int16_t>(Screen()->GetOrientationAngle()); int16_t angle = AssertedCast<int16_t>(screenAngle); return angle <= 180 ? angle : angle - 360; } Loading dom/base/test/chrome/bug418986-1.js +0 −3 Original line number Diff line number Diff line Loading @@ -32,9 +32,6 @@ var test = function (isContent) { ["screen.availTop", 0], ["screen.width", "outerWidth"], ["screen.height", "outerHeight"], ["screen.orientation.type", "'landscape-primary'"], ["screen.orientation.angle", 0], ["screen.mozOrientation", "'landscape-primary'"], ["devicePixelRatio", 2], ]; Loading hal/android/AndroidHal.cpp +14 −13 Original line number Diff line number Diff line Loading @@ -79,19 +79,20 @@ void GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo) { static bool IsSupportedScreenOrientation(hal::ScreenOrientation aOrientation) { // The Android backend only supports these orientations. static constexpr ScreenOrientation kSupportedOrientations[] = { ScreenOrientation::PortraitPrimary, ScreenOrientation::PortraitSecondary, ScreenOrientation::PortraitPrimary | ScreenOrientation::PortraitSecondary, ScreenOrientation::LandscapePrimary, ScreenOrientation::LandscapeSecondary, ScreenOrientation::LandscapePrimary | ScreenOrientation::LandscapeSecondary, ScreenOrientation::PortraitPrimary | ScreenOrientation::PortraitSecondary | ScreenOrientation::LandscapePrimary | ScreenOrientation::LandscapeSecondary, ScreenOrientation::Default, static constexpr hal::ScreenOrientation kSupportedOrientations[] = { hal::ScreenOrientation::PortraitPrimary, hal::ScreenOrientation::PortraitSecondary, hal::ScreenOrientation::PortraitPrimary | hal::ScreenOrientation::PortraitSecondary, hal::ScreenOrientation::LandscapePrimary, hal::ScreenOrientation::LandscapeSecondary, hal::ScreenOrientation::LandscapePrimary | hal::ScreenOrientation::LandscapeSecondary, hal::ScreenOrientation::PortraitPrimary | hal::ScreenOrientation::PortraitSecondary | hal::ScreenOrientation::LandscapePrimary | hal::ScreenOrientation::LandscapeSecondary, hal::ScreenOrientation::Default, }; for (auto supportedOrientation : kSupportedOrientations) { if (aOrientation == supportedOrientation) { Loading toolkit/components/resistfingerprinting/nsRFPService.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -2279,3 +2279,28 @@ Maybe<RFPTarget> nsRFPService::GetOverriddenFingerprintingSettingsForURI( return result; } /* static */ dom::OrientationType nsRFPService::OrientationSecondaryToPrimary( dom::OrientationType aOrientation) { switch (aOrientation) { case dom::OrientationType::Landscape_secondary: return dom::OrientationType::Landscape_primary; case dom::OrientationType::Portrait_secondary: return dom::OrientationType::Portrait_primary; default: return aOrientation; } } /* static */ uint16_t nsRFPService::OrientationSecondaryToPrimary(uint16_t aAngle) { switch (aAngle) { case 180: return 0; case 270: return 90; default: return aAngle; } } Loading
dom/base/ScreenOrientation.cpp +14 −14 Original line number Diff line number Diff line Loading @@ -626,7 +626,7 @@ void ScreenOrientation::CleanupFullscreenListener() { OrientationType ScreenOrientation::DeviceType(CallerType aCallerType) const { if (nsContentUtils::ShouldResistFingerprinting( aCallerType, GetOwnerGlobal(), RFPTarget::ScreenOrientation)) { return OrientationType::Landscape_primary; return nsRFPService::OrientationSecondaryToPrimary(mType); } return mType; } Loading @@ -634,18 +634,13 @@ OrientationType ScreenOrientation::DeviceType(CallerType aCallerType) const { uint16_t ScreenOrientation::DeviceAngle(CallerType aCallerType) const { if (nsContentUtils::ShouldResistFingerprinting( aCallerType, GetOwnerGlobal(), RFPTarget::ScreenOrientation)) { return 0; return nsRFPService::OrientationSecondaryToPrimary(mAngle); } return mAngle; } OrientationType ScreenOrientation::GetType(CallerType aCallerType, ErrorResult& aRv) const { if (nsContentUtils::ShouldResistFingerprinting( aCallerType, GetOwnerGlobal(), RFPTarget::ScreenOrientation)) { return OrientationType::Landscape_primary; } Document* doc = GetResponsibleDocument(); BrowsingContext* bc = doc ? doc->GetBrowsingContext() : nullptr; if (!bc) { Loading @@ -653,16 +648,16 @@ OrientationType ScreenOrientation::GetType(CallerType aCallerType, return OrientationType::Portrait_primary; } return bc->GetCurrentOrientationType(); } uint16_t ScreenOrientation::GetAngle(CallerType aCallerType, ErrorResult& aRv) const { OrientationType orientation = bc->GetCurrentOrientationType(); if (nsContentUtils::ShouldResistFingerprinting( aCallerType, GetOwnerGlobal(), RFPTarget::ScreenOrientation)) { return 0; return nsRFPService::OrientationSecondaryToPrimary(orientation); } return orientation; } uint16_t ScreenOrientation::GetAngle(CallerType aCallerType, ErrorResult& aRv) const { Document* doc = GetResponsibleDocument(); BrowsingContext* bc = doc ? doc->GetBrowsingContext() : nullptr; if (!bc) { Loading @@ -670,7 +665,12 @@ uint16_t ScreenOrientation::GetAngle(CallerType aCallerType, return 0; } return bc->GetCurrentOrientationAngle(); uint16_t angle = static_cast<uint16_t>(bc->GetCurrentOrientationAngle()); if (nsContentUtils::ShouldResistFingerprinting( aCallerType, GetOwnerGlobal(), RFPTarget::ScreenOrientation)) { return nsRFPService::OrientationSecondaryToPrimary(angle); } return angle; } ScreenOrientation::LockPermission Loading
dom/base/nsGlobalWindowInner.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -7306,11 +7306,12 @@ void nsGlobalWindowInner::InitWasOffline() { mWasOffline = NS_IsOffline(); } int16_t nsGlobalWindowInner::Orientation(CallerType aCallerType) { // GetOrientationAngle() returns 0, 90, 180 or 270. // window.orientation returns -90, 0, 90 or 180. uint16_t screenAngle = Screen()->GetOrientationAngle(); if (nsIGlobalObject::ShouldResistFingerprinting( aCallerType, RFPTarget::ScreenOrientation)) { return 0; screenAngle = nsRFPService::OrientationSecondaryToPrimary(screenAngle); } int16_t angle = AssertedCast<int16_t>(Screen()->GetOrientationAngle()); int16_t angle = AssertedCast<int16_t>(screenAngle); return angle <= 180 ? angle : angle - 360; } Loading
dom/base/test/chrome/bug418986-1.js +0 −3 Original line number Diff line number Diff line Loading @@ -32,9 +32,6 @@ var test = function (isContent) { ["screen.availTop", 0], ["screen.width", "outerWidth"], ["screen.height", "outerHeight"], ["screen.orientation.type", "'landscape-primary'"], ["screen.orientation.angle", 0], ["screen.mozOrientation", "'landscape-primary'"], ["devicePixelRatio", 2], ]; Loading
hal/android/AndroidHal.cpp +14 −13 Original line number Diff line number Diff line Loading @@ -79,19 +79,20 @@ void GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo) { static bool IsSupportedScreenOrientation(hal::ScreenOrientation aOrientation) { // The Android backend only supports these orientations. static constexpr ScreenOrientation kSupportedOrientations[] = { ScreenOrientation::PortraitPrimary, ScreenOrientation::PortraitSecondary, ScreenOrientation::PortraitPrimary | ScreenOrientation::PortraitSecondary, ScreenOrientation::LandscapePrimary, ScreenOrientation::LandscapeSecondary, ScreenOrientation::LandscapePrimary | ScreenOrientation::LandscapeSecondary, ScreenOrientation::PortraitPrimary | ScreenOrientation::PortraitSecondary | ScreenOrientation::LandscapePrimary | ScreenOrientation::LandscapeSecondary, ScreenOrientation::Default, static constexpr hal::ScreenOrientation kSupportedOrientations[] = { hal::ScreenOrientation::PortraitPrimary, hal::ScreenOrientation::PortraitSecondary, hal::ScreenOrientation::PortraitPrimary | hal::ScreenOrientation::PortraitSecondary, hal::ScreenOrientation::LandscapePrimary, hal::ScreenOrientation::LandscapeSecondary, hal::ScreenOrientation::LandscapePrimary | hal::ScreenOrientation::LandscapeSecondary, hal::ScreenOrientation::PortraitPrimary | hal::ScreenOrientation::PortraitSecondary | hal::ScreenOrientation::LandscapePrimary | hal::ScreenOrientation::LandscapeSecondary, hal::ScreenOrientation::Default, }; for (auto supportedOrientation : kSupportedOrientations) { if (aOrientation == supportedOrientation) { Loading
toolkit/components/resistfingerprinting/nsRFPService.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -2279,3 +2279,28 @@ Maybe<RFPTarget> nsRFPService::GetOverriddenFingerprintingSettingsForURI( return result; } /* static */ dom::OrientationType nsRFPService::OrientationSecondaryToPrimary( dom::OrientationType aOrientation) { switch (aOrientation) { case dom::OrientationType::Landscape_secondary: return dom::OrientationType::Landscape_primary; case dom::OrientationType::Portrait_secondary: return dom::OrientationType::Portrait_primary; default: return aOrientation; } } /* static */ uint16_t nsRFPService::OrientationSecondaryToPrimary(uint16_t aAngle) { switch (aAngle) { case 180: return 0; case 270: return 90; default: return aAngle; } }