Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Applications
Tor Browser
Commits
68ea938b
Commit
68ea938b
authored
Mar 24, 2023
by
ma1
Committed by
Pier Angelo Vendrame
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
BB 41695: Warn on window maximization without letterboxing in RFPHelper module
parent
99c71124
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1503
TB 43415, part 3: Shuffle commits
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
browser/app/profile/001-base-profile.js
+2
-0
2 additions, 0 deletions
browser/app/profile/001-base-profile.js
toolkit/components/resistfingerprinting/RFPHelper.sys.mjs
+82
-0
82 additions, 0 deletions
toolkit/components/resistfingerprinting/RFPHelper.sys.mjs
with
84 additions
and
0 deletions
browser/app/profile/001-base-profile.js
+
2
−
0
View file @
68ea938b
...
...
@@ -452,6 +452,8 @@ pref("privacy.resistFingerprinting.letterboxing.vcenter", true);
pref
(
"
privacy.resistFingerprinting.letterboxing.gradient
"
,
true
);
// tor-browser#41918: Should we reuse last window sizes if letterboxing is enabled
pref
(
"
privacy.resistFingerprinting.letterboxing.rememberSize
"
,
false
);
// tor-browser#41695: How many warnings we show if user closes them without restoring the window size
pref
(
"
privacy.resistFingerprinting.resizeWarnings
"
,
3
);
// tor-browser#43402: Avoid a resize from the skeleton to the newwin size.
// Should be fixed in ESR-140 with Bug 1448423.
pref
(
"
browser.startup.blankWindow
"
,
false
);
...
...
This diff is collapsed.
Click to expand it.
toolkit/components/resistfingerprinting/RFPHelper.sys.mjs
+
82
−
0
View file @
68ea938b
...
...
@@ -27,6 +27,8 @@ const kPrefLetterboxingRememberSize =
const
kTopicDOMWindowOpened
=
"
domwindowopened
"
;
const
kPrefResizeWarnings
=
"
privacy.resistFingerprinting.resizeWarnings
"
;
const
lazy
=
{};
ChromeUtils
.
defineLazyGetter
(
lazy
,
"
logConsole
"
,
()
=>
...
...
@@ -54,6 +56,84 @@ function forEachWindow(callback) {
}
}
async
function
windowResizeHandler
(
aEvent
)
{
if
(
RFPHelper
.
letterboxingEnabled
||
!
RFPHelper
.
rfpEnabled
)
{
return
;
}
if
(
Services
.
prefs
.
getIntPref
(
kPrefResizeWarnings
)
<=
0
)
{
return
;
}
const
window
=
aEvent
.
currentTarget
;
// Wait for end of execution queue to ensure we have correct windowState.
await
new
Promise
(
resolve
=>
window
.
setTimeout
(
resolve
,
0
));
switch
(
window
.
windowState
)
{
case
window
.
STATE_MAXIMIZED
:
case
window
.
STATE_FULLSCREEN
:
break
;
default
:
return
;
}
// Do not add another notification if one is already showing.
const
kNotificationName
=
"
rfp-window-resize-notification
"
;
let
box
=
window
.
gNotificationBox
;
if
(
box
.
getNotificationWithValue
(
kNotificationName
))
{
return
;
}
// Rate-limit showing our notification if needed.
if
(
Date
.
now
()
-
(
windowResizeHandler
.
timestamp
||
0
)
<
1000
)
{
return
;
}
windowResizeHandler
.
timestamp
=
Date
.
now
();
const
decreaseWarningsCount
=
()
=>
{
const
currentCount
=
Services
.
prefs
.
getIntPref
(
kPrefResizeWarnings
);
if
(
currentCount
>
0
)
{
Services
.
prefs
.
setIntPref
(
kPrefResizeWarnings
,
currentCount
-
1
);
}
};
const
[
label
,
accessKey
]
=
await
window
.
document
.
l10n
.
formatValues
([
{
id
:
"
basebrowser-rfp-restore-window-size-button-label
"
},
{
id
:
"
basebrowser-rfp-restore-window-size-button-ak
"
},
]);
const
buttons
=
[
{
label
,
accessKey
,
popup
:
null
,
callback
()
{
// reset notification timer to work-around resize race conditions
windowResizeHandler
.
timestamp
=
Date
.
now
();
// restore the original (rounded) size we had stored on window startup
let
{
_rfpOriginalSize
}
=
window
;
window
.
setTimeout
(()
=>
{
window
.
resizeTo
(
_rfpOriginalSize
.
width
,
_rfpOriginalSize
.
height
);
},
0
);
},
},
];
box
.
appendNotification
(
kNotificationName
,
{
label
:
{
"
l10n-id
"
:
"
basebrowser-rfp-maximize-warning-message
"
},
priority
:
box
.
PRIORITY_WARNING_LOW
,
eventCallback
(
event
)
{
if
(
event
===
"
dismissed
"
)
{
// user manually dismissed the notification
decreaseWarningsCount
();
}
},
},
buttons
);
}
class
_RFPHelper
{
// ============================================================================
// Shared Setup
...
...
@@ -696,6 +776,7 @@ class _RFPHelper {
_attachWindow
(
aWindow
)
{
this
.
_fixRounding
(
aWindow
);
aWindow
.
addEventListener
(
"
sizemodechange
"
,
windowResizeHandler
);
aWindow
.
gBrowser
.
addTabsProgressListener
(
this
);
aWindow
.
addEventListener
(
"
TabOpen
"
,
this
);
const
resizeObserver
=
(
aWindow
.
_rfpResizeObserver
=
...
...
@@ -727,6 +808,7 @@ class _RFPHelper {
let
browser
=
tab
.
linkedBrowser
;
this
.
_resetContentSize
(
browser
);
}
aWindow
.
removeEventListener
(
"
sizemodechange
"
,
windowResizeHandler
);
}
_handleDOMWindowOpened
(
win
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment