Skip to content

Commit

Permalink
Bug 1874801 - Check that HTTPS-Only is disabled when checking if HTTP…
Browse files Browse the repository at this point in the history
…S-First is enabled in nsHTTPSOnlyUtils r=freddyb

Differential Revision: https://phabricator.services.mozilla.com/D198780

UltraBlame original commit: 7d35b1612c9f80b1ce49a6f7f8adc8b90621969d
  • Loading branch information
marco-c committed Feb 1, 2024
1 parent fb107cd commit 4379917
Show file tree
Hide file tree
Showing 5 changed files with 563 additions and 7 deletions.
19 changes: 12 additions & 7 deletions dom/security/nsHTTPSOnlyUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ aFromPrivateWindow
{
if
(
IsHttpsOnlyModeEnabled
(
aFromPrivateWindow
)
)
{
return
false
;
}
if
(
mozilla
:
:
Expand Down Expand Up @@ -533,13 +545,6 @@ dom_security_https_first_schemeless
)
)
)
&
&
!
IsHttpsOnlyModeEnabled
(
isPrivateWin
)
)
{
int32_t
Expand Down
23 changes: 23 additions & 0 deletions dom/security/test/https-only/browser.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ sjs
]
[
"
browser_bug1874801
.
js
"
]
support
-
files
=
[
"
file_bug1874801
.
sjs
"
"
file_bug1874801
.
html
"
]
[
"
browser_console_logging
.
js
Expand Down
230 changes: 230 additions & 0 deletions dom/security/test/https-only/browser_bug1874801.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
"
use
strict
"
;
const
TAB_URL
=
"
https
:
/
/
example
.
com
/
browser
/
dom
/
security
/
test
/
https
-
only
/
file_bug1874801
.
html
"
;
function
assertImageLoaded
(
tab
)
{
return
ContentTask
.
spawn
(
tab
.
linkedBrowser
{
}
(
)
=
>
{
const
img
=
content
.
document
.
getElementsByTagName
(
"
img
"
)
[
0
]
;
ok
(
!
!
img
"
Image
tag
should
exist
"
)
;
ok
(
img
.
complete
&
&
img
.
naturalWidth
>
0
"
Image
should
have
loaded
"
)
;
}
)
;
}
add_task
(
async
function
test_bug1874801
(
)
{
await
SpecialPowers
.
pushPrefEnv
(
{
set
:
[
[
"
security
.
mixed_content
.
upgrade_display_content
"
false
]
[
"
dom
.
security
.
https_first
"
true
]
[
"
dom
.
security
.
https_only_mode
"
true
]
]
}
)
;
const
tabToClose
=
await
BrowserTestUtils
.
openNewForegroundTab
(
gBrowser
TAB_URL
true
)
;
await
assertImageLoaded
(
tabToClose
)
;
const
tabClosePromise
=
BrowserTestUtils
.
waitForSessionStoreUpdate
(
tabToClose
)
;
BrowserTestUtils
.
removeTab
(
tabToClose
)
;
await
tabClosePromise
;
const
restoredTabPromise
=
BrowserTestUtils
.
waitForNewTab
(
gBrowser
TAB_URL
true
)
;
undoCloseTab
(
)
;
const
restoredTab
=
await
restoredTabPromise
;
await
assertImageLoaded
(
restoredTab
)
;
}
)
;
104 changes: 104 additions & 0 deletions dom/security/test/https-only/file_bug1874801.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<
!
DOCTYPE
html
>
<
html
lang
=
"
en
"
>
<
head
>
<
meta
charset
=
"
UTF
-
8
"
>
<
meta
name
=
"
viewport
"
content
=
"
width
=
device
-
width
initial
-
scale
=
1
.
0
"
>
<
title
>
Bug
1874801
<
/
title
>
<
/
head
>
<
body
>
<
img
src
=
"
http
:
/
/
example
.
com
/
browser
/
dom
/
security
/
test
/
https
-
only
/
file_bug1874801
.
sjs
"
>
<
/
body
>
<
/
html
>
Loading

0 comments on commit 4379917

Please sign in to comment.