This commit is contained in:
parent
2026c60136
commit
030f75b4df
53
app/src/main/assets/high_risk_error_pages.html
Normal file
53
app/src/main/assets/high_risk_error_pages.html
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width; user-scalable=false;" />
|
||||
<link rel="stylesheet" type="text/css" href="high_risk_error_style.css">
|
||||
</head>
|
||||
|
||||
<body id="errorPage" dir="auto">
|
||||
<!-- PAGE CONTAINER (for styling purposes only) -->
|
||||
<div id="errorPageContainer">
|
||||
|
||||
<!-- Error Image -->
|
||||
<iframe id="errorImage" src="" frameborder="0"></iframe>
|
||||
|
||||
<!-- Error Title -->
|
||||
<div id="errorTitle">
|
||||
<h1 id="errorTitleText"></h1>
|
||||
</div>
|
||||
|
||||
<!-- LONG CONTENT (the section most likely to require scrolling) -->
|
||||
<div id="errorLongContent">
|
||||
<div id="errorShortDesc"></div>
|
||||
</div>
|
||||
|
||||
<!-- Back Button -->
|
||||
<button id="backButton" onclick="window.history.back()">Go back</button>
|
||||
|
||||
<!-- Advanced Button -->
|
||||
<button id="advancedButton" class="buttonSecondary" onclick="toggleAdvanced()" style="display: none;"></button>
|
||||
|
||||
<div id="advancedPanelContainer">
|
||||
<div id="badCertAdvancedPanel" class="advanced-panel" style="display: none;">
|
||||
<p id="badCertTechnicalInfo"></p>
|
||||
<div id="advancedPanelBackButtonContainer" class="advancedPanelButtonContainer">
|
||||
<button id="advancedPanelBackButton" onClick="window.history.back()"></button>
|
||||
</div>
|
||||
<div id="advancedPanelAcceptButtonContainer" class="advancedPanelButtonContainer">
|
||||
<button id="advancedPanelAcceptButton" class="buttonSecondary" onClick="acceptAndContinue(true)"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
<script src="./errorPageScripts.js"></script>
|
||||
</html>
|
120
app/src/main/assets/high_risk_error_style.css
Normal file
120
app/src/main/assets/high_risk_error_style.css
Normal file
|
@ -0,0 +1,120 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
--moz-vertical-spacing: 10px;
|
||||
--moz-background-height: 32px;
|
||||
}
|
||||
|
||||
body {
|
||||
background-size: 64px var(--moz-background-height);
|
||||
background-repeat: repeat-x;
|
||||
background-color: #c50042;
|
||||
color: #ffffff;
|
||||
padding: 0 40px;
|
||||
font-size: 14px;
|
||||
-moz-text-size-adjust: none;
|
||||
font-family: sharp-sans;
|
||||
}
|
||||
|
||||
ul {
|
||||
/* Shove the list indicator so that its left aligned, but use outside so that text
|
||||
* doesn't don't wrap the text around it */
|
||||
padding: 0 1em;
|
||||
margin: 0;
|
||||
list-style-type: disc;
|
||||
}
|
||||
|
||||
#errorShortDesc,
|
||||
li:not(:last-of-type) {
|
||||
/* Margins between the li and buttons below it won't be collapsed. Remove the bottom margin here. */
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
color: #ffffff;
|
||||
font-family: sharp-sans;
|
||||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 20px;
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
button {
|
||||
display: block;
|
||||
height: 36px;
|
||||
width: 100%;
|
||||
border-radius: 5px;
|
||||
border-color: #e3e3e7;
|
||||
font-family: sans-serif;
|
||||
background-color: #e6e6eb;
|
||||
color: #2f2c61;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
margin: var(--moz-vertical-spacing) auto;
|
||||
text-aligned:center;
|
||||
vertical-aligned:center;
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
button.inProgress {
|
||||
background-image: linear-gradient(-45deg, #dfe8ee, #dfe8ee 33%,
|
||||
#ecf0f3 33%, #ecf0f3 66%,
|
||||
#dfe8ee 66%, #dfe8ee);
|
||||
background-size: 37px 5px;
|
||||
background-repeat: repeat-x;
|
||||
animation: progress 6s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes progress {
|
||||
from { background-position: 0 100%; }
|
||||
to { background-position: 100% 100%; }
|
||||
}
|
||||
|
||||
#errorPageContainer {
|
||||
/* If the page is greater than 550px center the content.
|
||||
* This number should be kept in sync with the media query for tablets below */
|
||||
max-width: 550px;
|
||||
margin: 0 auto;
|
||||
transform: translateY(var(--moz-background-height));
|
||||
padding-bottom: var(--moz-vertical-spacing);
|
||||
|
||||
min-height: calc(100% - var(--moz-background-height) - var(--moz-vertical-spacing));
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* On large width devices, apply specific styles here. Often triggered by landscape mode or tablets */
|
||||
@media (min-width: 550px) {
|
||||
button {
|
||||
margin: var(--moz-vertical-spacing) var(--moz-vertical-spacing);
|
||||
min-width: 400px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/* If the device is tall as well, add some padding to make content feel a bit more centered */
|
||||
@media (min-height: 550px) {
|
||||
#errorPageContainer {
|
||||
padding-top: 64px;
|
||||
min-height: calc(100% - 64px);
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
83
app/src/main/assets/low_and_medium_risk_error_pages.html
Normal file
83
app/src/main/assets/low_and_medium_risk_error_pages.html
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width; user-scalable=false;" />
|
||||
<link rel="stylesheet" type="text/css" href="low_and_medium_risk_error_style.css">
|
||||
</head>
|
||||
|
||||
<body id="errorPage" dir="auto">
|
||||
<!-- PAGE CONTAINER (for styling purposes only) -->
|
||||
<div id="errorPageContainer">
|
||||
|
||||
<!-- Error Image -->
|
||||
<iframe id="errorImage" src="" frameborder="0"></iframe>
|
||||
|
||||
<!-- Error Title -->
|
||||
<div id="errorTitle">
|
||||
<h1 id="errorTitleText"></h1>
|
||||
</div>
|
||||
|
||||
<!-- LONG CONTENT (the section most likely to require scrolling) -->
|
||||
<div id="errorLongContent">
|
||||
<div id="errorShortDesc"></div>
|
||||
</div>
|
||||
|
||||
<!-- Retry Button -->
|
||||
<button id="errorTryAgain" onclick="window.location.reload()"></button>
|
||||
|
||||
<!-- Advanced Button -->
|
||||
<button id="advancedButton" class="buttonSecondary" onclick="toggleAdvancedAndScroll()" style="display: none;"></button>
|
||||
|
||||
<hr id="horizontalLine" style="display: none;">
|
||||
<div id="advancedPanelContainer">
|
||||
<div id="badCertAdvancedPanel" class="advanced-panel" style="display: none;">
|
||||
<p id="badCertTechnicalInfo"></p>
|
||||
<div id="advancedPanelBackButtonContainer" class="advancedPanelButtonContainer">
|
||||
<button id="advancedPanelBackButton" onClick="window.history.back()"></button>
|
||||
</div>
|
||||
<div id="advancedPanelAcceptButtonContainer" class="advancedPanelButtonContainer">
|
||||
<button id="advancedPanelAcceptButton" class="buttonSecondary" onClick="acceptAndContinue(true)"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
function toggleAdvancedAndScroll() {
|
||||
toggleAdvanced();
|
||||
|
||||
const horizontalLine = document.getElementById("horizontalLine");
|
||||
const advancedPanelAcceptButton = document.getElementById("advancedPanelAcceptButton");
|
||||
const badCertAdvancedPanel = document.getElementById("badCertAdvancedPanel");
|
||||
/*
|
||||
horizontalLine.style.display = "block";
|
||||
advancedPanelAcceptButton.scrollIntoView({behavior: "smooth", block: "center", inline: "nearest"});
|
||||
|
||||
*/
|
||||
|
||||
// We know that the button is being displayed
|
||||
|
||||
if (badCertAdvancedPanel.style.display === "block") {
|
||||
horizontalLine.style.display = "block";
|
||||
advancedPanelAcceptButton.scrollIntoView({behavior: "smooth", block: "center", inline: "nearest"});
|
||||
} else if (badCertAdvancedPanel.style.display === "none") {
|
||||
horizontalLine.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function overrideAdvancedButtonStyling() {
|
||||
const advancedButton = document.getElementById("advancedButton");
|
||||
advancedButton.style.display = "inline-flex";
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="./errorPageScripts.js"></script>
|
||||
</html>
|
133
app/src/main/assets/low_and_medium_risk_error_style.css
Normal file
133
app/src/main/assets/low_and_medium_risk_error_style.css
Normal file
|
@ -0,0 +1,133 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
--moz-vertical-spacing: 10px;
|
||||
--moz-background-height: 32px;
|
||||
}
|
||||
|
||||
body {
|
||||
background-size: 64px var(--moz-background-height);
|
||||
background-repeat: repeat-x;
|
||||
background-color: #f9f9fb;
|
||||
color: #15141A;
|
||||
padding: 0 40px;
|
||||
font-size: 14px;
|
||||
-moz-text-size-adjust: none;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
ul {
|
||||
/* Shove the list indicator so that its left aligned, but use outside so that text
|
||||
* doesn't don't wrap the text around it */
|
||||
padding: 0 1em;
|
||||
margin: 0;
|
||||
list-style-type: disc;
|
||||
}
|
||||
|
||||
#errorShortDesc,
|
||||
li:not(:last-of-type) {
|
||||
/* Margins between the li and buttons below it won't be collapsed. Remove the bottom margin here. */
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
color: #312a65;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 20px;
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
}
|
||||
|
||||
|
||||
button {
|
||||
display: block;
|
||||
height: 36px;
|
||||
width: 100%;
|
||||
border-radius: 5px;
|
||||
border-color: #312A65;
|
||||
font-family: sans-serif;
|
||||
background-color: #312A65;
|
||||
color: #FFFFFF;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
margin: var(--moz-vertical-spacing) auto;
|
||||
text-aligned:center;
|
||||
vertical-aligned:center;
|
||||
}
|
||||
|
||||
hr {
|
||||
color: #EDEDF0;
|
||||
margin-left: -40px;
|
||||
margin-right: -40px;
|
||||
}
|
||||
|
||||
.buttonSecondary {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 36px;
|
||||
border-radius: 5px;
|
||||
border-color: #E0E0E6;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
background-color: #E0E0E6;
|
||||
color: #20123A;
|
||||
text-aligned:center;
|
||||
vertical-aligned:center;
|
||||
margin: var(--moz-vertical-spacing) auto;
|
||||
}
|
||||
|
||||
#errorPageContainer {
|
||||
/* If the page is greater than 550px center the content.
|
||||
* This number should be kept in sync with the media query for tablets below */
|
||||
max-width: 550px;
|
||||
margin: 0 auto;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
/* On large width devices, apply specific styles here. Often triggered by landscape mode or tablets */
|
||||
@media (min-width: 550px) {
|
||||
button {
|
||||
margin: var(--moz-vertical-spacing) auto;
|
||||
min-width: 400px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.buttonSecondary {
|
||||
margin: var(--moz-vertical-spacing) auto;
|
||||
min-width: 400px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/* If the device is tall as well, add some padding to make content feel a bit more centered */
|
||||
@media (min-height: 550px) {
|
||||
#errorPageContainer {
|
||||
padding-top: 64px;
|
||||
min-height: calc(100% - 64px);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#badCertTechnicalInfo {
|
||||
overflow: auto;
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
#advancedPanelButtonContainer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ package org.mozilla.fenix
|
|||
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import androidx.annotation.RawRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.content.getSystemService
|
||||
import mozilla.components.browser.errorpages.ErrorPages
|
||||
import mozilla.components.browser.errorpages.ErrorType
|
||||
|
@ -14,8 +14,8 @@ import mozilla.components.concept.engine.EngineSession
|
|||
import mozilla.components.concept.engine.request.RequestInterceptor
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.ext.isOnline
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
class AppRequestInterceptor(private val context: Context) : RequestInterceptor {
|
||||
override fun onLoadRequest(
|
||||
|
@ -60,20 +60,18 @@ class AppRequestInterceptor(private val context: Context) : RequestInterceptor {
|
|||
uri: String?
|
||||
): RequestInterceptor.ErrorResponse? {
|
||||
val improvedErrorType = improveErrorType(errorType)
|
||||
|
||||
val riskLevel = getRiskLevel(improvedErrorType)
|
||||
|
||||
context.components.analytics.metrics.track(Event.ErrorPageVisited(improvedErrorType))
|
||||
|
||||
return RequestInterceptor.ErrorResponse.Content(
|
||||
ErrorPages.createErrorPage(
|
||||
context,
|
||||
improvedErrorType,
|
||||
val errorPageUri = ErrorPages.createUrlEncodedErrorPage(
|
||||
context = context,
|
||||
errorType = improvedErrorType,
|
||||
uri = uri,
|
||||
htmlResource = riskLevel.htmlRes,
|
||||
cssResource = riskLevel.cssRes
|
||||
)
|
||||
htmlResource = riskLevel.htmlRes
|
||||
)
|
||||
|
||||
return RequestInterceptor.ErrorResponse.Uri(errorPageUri)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,9 +122,17 @@ class AppRequestInterceptor(private val context: Context) : RequestInterceptor {
|
|||
ErrorType.ERROR_SAFEBROWSING_UNWANTED_URI -> RiskLevel.High
|
||||
}
|
||||
|
||||
private enum class RiskLevel(@RawRes val htmlRes: Int, @RawRes val cssRes: Int) {
|
||||
Low(R.raw.low_risk_error_pages, R.raw.low_and_medium_risk_error_style),
|
||||
Medium(R.raw.medium_and_high_risk_error_pages, R.raw.low_and_medium_risk_error_style),
|
||||
High(R.raw.medium_and_high_risk_error_pages, R.raw.high_risk_error_style),
|
||||
internal enum class RiskLevel(val htmlRes: String) {
|
||||
|
||||
Low(LOW_AND_MEDIUM_RISK_ERROR_PAGES),
|
||||
Medium(LOW_AND_MEDIUM_RISK_ERROR_PAGES),
|
||||
High(HIGH_RISK_ERROR_PAGES),
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
internal const val LOW_AND_MEDIUM_RISK_ERROR_PAGES = "low_and_medium_risk_error_pages.html"
|
||||
internal const val HIGH_RISK_ERROR_PAGES = "high_risk_error_pages.html"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
|
|||
// NB: There are ways for the user to install new products without leaving the browser.
|
||||
BrowsersCache.resetAll()
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles intents received when the activity is open.
|
||||
*/
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:letterSpacing="0"
|
||||
android:text="@string/sign_in_ready_for_scan"
|
||||
|
@ -79,6 +80,7 @@
|
|||
style="@style/ThemeIndependentMaterialGreyButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/sign_in_with_email"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -1,227 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
--moz-vertical-spacing: 10px;
|
||||
--moz-background-height: 32px;
|
||||
}
|
||||
|
||||
body {
|
||||
background-size: 64px var(--moz-background-height);
|
||||
background-repeat: repeat-x;
|
||||
background-color: #c50042;
|
||||
color: #ffffff;
|
||||
padding: 0 40px;
|
||||
font-size: 14px;
|
||||
-moz-text-size-adjust: none;
|
||||
font-family: sharp-sans;
|
||||
}
|
||||
|
||||
ul {
|
||||
/* Shove the list indicator so that its left aligned, but use outside so that text
|
||||
* doesn't don't wrap the text around it */
|
||||
padding: 0 1em;
|
||||
margin: 0;
|
||||
list-style-type: disc;
|
||||
}
|
||||
|
||||
#errorShortDesc,
|
||||
li:not(:last-of-type) {
|
||||
/* Margins between the li and buttons below it won't be collapsed. Remove the bottom margin here. */
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
}
|
||||
|
||||
li > button {
|
||||
/* Removing the normal padding on the li so this stretched edge to edge. */
|
||||
margin-left: -1em;
|
||||
margin-right: -1em;
|
||||
width: calc(100% + 2em);
|
||||
}
|
||||
|
||||
/* Push the #ignoreWarningButton to the bottom on the blocked site page */
|
||||
.blockedsite > #errorPageContainer > #errorLongContent {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
color: #ffffff;
|
||||
font-family: sharp-sans;
|
||||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 20px;
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
button {
|
||||
/* Force buttons to display: block here to try and enforce collapsing margins */
|
||||
display: block;
|
||||
height: 36px;
|
||||
width: 100%;
|
||||
border-radius: 5px;
|
||||
border-color: #e3e3e7;
|
||||
font-family: sharp-sans;
|
||||
background-color: #e6e6eb;
|
||||
color: #2f2c61;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
text-aligned:center;
|
||||
vertical-aligned:center;
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
button.inProgress {
|
||||
background-image: linear-gradient(-45deg, #dfe8ee, #dfe8ee 33%,
|
||||
#ecf0f3 33%, #ecf0f3 66%,
|
||||
#dfe8ee 66%, #dfe8ee);
|
||||
background-size: 37px 5px;
|
||||
background-repeat: repeat-x;
|
||||
animation: progress 6s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes progress {
|
||||
from { background-position: 0 100%; }
|
||||
to { background-position: 100% 100%; }
|
||||
}
|
||||
|
||||
.certerror {
|
||||
background-image: linear-gradient(-45deg, #f0d000, #f0d000 33%,
|
||||
#fedc00 33%, #fedc00 66%,
|
||||
#f0d000 66%, #f0d000);
|
||||
}
|
||||
|
||||
.blockedsite {
|
||||
background-image: linear-gradient(-45deg, #9b2e2e, #9b2e2e 33%,
|
||||
#a83232 33%, #a83232 66%,
|
||||
#9b2e2e 66%, #9b2e2e);
|
||||
background-color: #b14646;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#errorPageContainer {
|
||||
/* If the page is greater than 550px center the content.
|
||||
* This number should be kept in sync with the media query for tablets below */
|
||||
max-width: 550px;
|
||||
margin: 0 auto;
|
||||
transform: translateY(var(--moz-background-height));
|
||||
padding-bottom: var(--moz-vertical-spacing);
|
||||
|
||||
min-height: calc(100% - var(--moz-background-height) - var(--moz-vertical-spacing));
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Expanders have a structure of
|
||||
* <div collapsed="true/false">
|
||||
* <h2 class="expander">Title</h2>
|
||||
* <p>Content</p>
|
||||
* </div>
|
||||
*
|
||||
* This shows an arrow to the right of the h2 element, and hides the content when collapsed="true". */
|
||||
.expander {
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
background-image: url("chrome://browser/skin/images/dropmarker.svg");
|
||||
background-repeat: no-repeat;
|
||||
/* dropmarker.svg is 10x7. Ensure that its centered in the middle of an 18x18 box */
|
||||
background-position: 3px 5.5px;
|
||||
background-size: 10px 7px;
|
||||
padding-left: 18px;
|
||||
}
|
||||
|
||||
div[collapsed="true"] > .expander {
|
||||
background-image: url("chrome://browser/skin/images/dropmarker-right.svg");
|
||||
/* dropmarker.svg is 7x10. Ensure that its centered in the middle of an 18x18 box */
|
||||
background-size: 7px 10px;
|
||||
background-position: 5.5px 4px;
|
||||
}
|
||||
|
||||
div[hidden] > .expander,
|
||||
div[hidden] > .expander + *,
|
||||
div[collapsed="true"] > .expander + * {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.blockedsite h1 {
|
||||
border-bottom-color: #9b2e2e;
|
||||
}
|
||||
|
||||
.blockedsite button {
|
||||
background-color: #9b2e2e;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Style warning button to look like a small text link in the
|
||||
bottom. This is preferable to just using a text link
|
||||
since there is already a mechanism in browser.js for trapping
|
||||
oncommand events from unprivileged chrome pages (ErrorPageEventHandler).*/
|
||||
#ignoreWarningButton {
|
||||
width: calc(100% + 40px);
|
||||
-moz-appearance: none;
|
||||
background: #b14646;
|
||||
border: none;
|
||||
text-decoration: underline;
|
||||
margin: 0;
|
||||
margin-inline-start: -20px;
|
||||
font-size: smaller;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
/* On large screen devices (hopefully a 7+ inch tablet, we already center content (see #errorPageContainer above).
|
||||
Apply tablet specific styles here */
|
||||
@media (min-width: 550px) {
|
||||
button {
|
||||
min-width: 160px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/* If the tablet is tall as well, add some padding to make content feel a bit more centered
|
||||
border-box value of box-sizing property makes height property include both content and padding */
|
||||
@media (min-height: 550px) {
|
||||
#errorPageContainer {
|
||||
padding-top: 64px;
|
||||
min-height: calc(100% - 64px);
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#searchbox {
|
||||
padding: 0;
|
||||
display: flex;
|
||||
margin: var(--moz-vertical-spacing) -1em;
|
||||
}
|
||||
|
||||
#searchbox > input {
|
||||
flex: 3;
|
||||
padding: 0em 3em 0em 1em;
|
||||
width: 100%;
|
||||
border: none;
|
||||
font-family: sans-serif;
|
||||
background-image: none;
|
||||
background-color: white;
|
||||
border-radius-top-right: none;
|
||||
border-radius-bottom-right: none;
|
||||
}
|
||||
|
||||
#searchbox > button {
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
width: auto;
|
||||
}
|
||||
|
|
@ -1,220 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
--moz-vertical-spacing: 10px;
|
||||
--moz-background-height: 32px;
|
||||
}
|
||||
|
||||
body {
|
||||
background-size: 64px var(--moz-background-height);
|
||||
background-repeat: repeat-x;
|
||||
background-color: #f9f9fb;
|
||||
color: #15141A;
|
||||
padding: 0 40px;
|
||||
font-size: 14px;
|
||||
-moz-text-size-adjust: none;
|
||||
font-family: sharp-sans;
|
||||
}
|
||||
|
||||
ul {
|
||||
/* Shove the list indicator so that its left aligned, but use outside so that text
|
||||
* doesn't don't wrap the text around it */
|
||||
padding: 0 1em;
|
||||
margin: 0;
|
||||
list-style-type: disc;
|
||||
}
|
||||
|
||||
#errorShortDesc,
|
||||
li:not(:last-of-type) {
|
||||
/* Margins between the li and buttons below it won't be collapsed. Remove the bottom margin here. */
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
}
|
||||
|
||||
li > button {
|
||||
/* Removing the normal padding on the li so this stretched edge to edge. */
|
||||
margin-left: -1em;
|
||||
margin-right: -1em;
|
||||
width: calc(100% + 2em);
|
||||
}
|
||||
|
||||
/* Push the #ignoreWarningButton to the bottom on the blocked site page */
|
||||
#errorLongContent {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
color: #312a65;
|
||||
font-family: sharp-sans;
|
||||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 20px;
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
}
|
||||
|
||||
button {
|
||||
/* Force buttons to display: block here to try and enforce collapsing margins */
|
||||
display: block;
|
||||
flex: 0;
|
||||
height: 36px;
|
||||
width: 100%;
|
||||
border-radius: 5px;
|
||||
border-color: #312a65;
|
||||
font-family: sharp-sans;
|
||||
background-color: #312a65;
|
||||
color: #FFFFFF;
|
||||
line-height:16px;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
text-aligned:center;
|
||||
vertical-aligned:center;
|
||||
background-image: none;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
button.inProgress {
|
||||
background-image: linear-gradient(-45deg, #dfe8ee, #dfe8ee 33%,
|
||||
#ecf0f3 33%, #ecf0f3 66%,
|
||||
#dfe8ee 66%, #dfe8ee);
|
||||
background-size: 37px 5px;
|
||||
background-repeat: repeat-x;
|
||||
animation: progress 6s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes progress {
|
||||
from { background-position: 0 100%; }
|
||||
to { background-position: 100% 100%; }
|
||||
}
|
||||
|
||||
.certerror {
|
||||
background-image: linear-gradient(-45deg, #f0d000, #f0d000 33%,
|
||||
#fedc00 33%, #fedc00 66%,
|
||||
#f0d000 66%, #f0d000);
|
||||
}
|
||||
|
||||
.blockedsite {
|
||||
background-image: linear-gradient(-45deg, #9b2e2e, #9b2e2e 33%,
|
||||
#a83232 33%, #a83232 66%,
|
||||
#9b2e2e 66%, #9b2e2e);
|
||||
background-color: #b14646;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#errorPageContainer {
|
||||
/* If the page is greater than 550px center the content.
|
||||
* This number should be kept in sync with the media query for tablets below */
|
||||
max-width: 550px;
|
||||
margin: 0 auto;
|
||||
min-height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Expanders have a structure of
|
||||
* <div collapsed="true/false">
|
||||
* <h2 class="expander">Title</h2>
|
||||
* <p>Content</p>
|
||||
* </div>
|
||||
*
|
||||
* This shows an arrow to the right of the h2 element, and hides the content when collapsed="true". */
|
||||
.expander {
|
||||
margin: var(--moz-vertical-spacing) 0;
|
||||
background-image: url("chrome://browser/skin/images/dropmarker.svg");
|
||||
background-repeat: no-repeat;
|
||||
/* dropmarker.svg is 10x7. Ensure that its centered in the middle of an 18x18 box */
|
||||
background-position: 3px 5.5px;
|
||||
background-size: 10px 7px;
|
||||
padding-left: 18px;
|
||||
}
|
||||
|
||||
div[collapsed="true"] > .expander {
|
||||
background-image: url("chrome://browser/skin/images/dropmarker-right.svg");
|
||||
/* dropmarker.svg is 7x10. Ensure that its centered in the middle of an 18x18 box */
|
||||
background-size: 7px 10px;
|
||||
background-position: 5.5px 4px;
|
||||
}
|
||||
|
||||
div[hidden] > .expander,
|
||||
div[hidden] > .expander + *,
|
||||
div[collapsed="true"] > .expander + * {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.blockedsite h1 {
|
||||
border-bottom-color: #9b2e2e;
|
||||
}
|
||||
|
||||
.blockedsite button {
|
||||
background-color: #9b2e2e;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Style warning button to look like a small text link in the
|
||||
bottom. This is preferable to just using a text link
|
||||
since there is already a mechanism in browser.js for trapping
|
||||
oncommand events from unprivileged chrome pages (ErrorPageEventHandler).*/
|
||||
#ignoreWarningButton {
|
||||
width: calc(100% + 40px);
|
||||
-moz-appearance: none;
|
||||
background: #b14646;
|
||||
border: none;
|
||||
text-decoration: underline;
|
||||
margin: 0;
|
||||
margin-inline-start: -20px;
|
||||
font-size: smaller;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
/* On large screen devices (hopefully a 7+ inch tablet, we already center content (see #errorPageContainer above).
|
||||
Apply tablet specific styles here */
|
||||
@media (min-width: 550px) {
|
||||
button {
|
||||
min-width: 160px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/* If the tablet is tall as well, add some padding to make content feel a bit more centered */
|
||||
@media (min-height: 550px) {
|
||||
#errorPageContainer {
|
||||
padding-top: 64px;
|
||||
min-height: calc(100% - 64px);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#searchbox {
|
||||
padding: 0;
|
||||
display: flex;
|
||||
margin: var(--moz-vertical-spacing) -1em;
|
||||
}
|
||||
|
||||
#searchbox > input {
|
||||
flex: 3;
|
||||
padding: 0em 3em 0em 1em;
|
||||
width: 100%;
|
||||
border: none;
|
||||
font-family: sans-serif;
|
||||
background-image: none;
|
||||
background-color: white;
|
||||
border-radius-top-right: none;
|
||||
border-radius-bottom-right: none;
|
||||
}
|
||||
|
||||
#searchbox > button {
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
width: auto;
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<meta charset="UTF-8">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width; user-scalable=false;" />
|
||||
<title>%pageTitle%</title>
|
||||
<style>%css%</style>
|
||||
</head>
|
||||
|
||||
<body id="errorPage" dir="auto">
|
||||
<!-- PAGE CONTAINER (for styling purposes only) -->
|
||||
<div id="errorPageContainer">
|
||||
|
||||
<!-- Error Title -->
|
||||
<div id="errorTitle">
|
||||
<h1 id="et_dnsNotFound" class="errorTitleText">%messageShort%</h1>
|
||||
</div>
|
||||
|
||||
<!-- LONG CONTENT (the section most likely to require scrolling) -->
|
||||
<div id="errorLongContent">
|
||||
|
||||
<!-- Short Description -->
|
||||
<div id="errorShortDesc">
|
||||
<p id="errorShortDescText">%messageLong%</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Retry Button -->
|
||||
<div id="buttonWrapper">
|
||||
<button id="errorTryAgain" onclick="window.location.reload()">%button%</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,45 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<meta charset="UTF-8">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width; user-scalable=false;" />
|
||||
<title>%pageTitle%</title>
|
||||
<style>%css%</style>
|
||||
</head>
|
||||
|
||||
<body id="errorPage" dir="auto">
|
||||
<!-- PAGE CONTAINER (for styling purposes only) -->
|
||||
<div id="errorPageContainer">
|
||||
|
||||
<!-- Error Title -->
|
||||
<div id="errorTitle">
|
||||
<h1 id="et_dnsNotFound" class="errorTitleText">%messageShort%</h1>
|
||||
</div>
|
||||
|
||||
<!-- LONG CONTENT (the section most likely to require scrolling) -->
|
||||
<div id="errorLongContent">
|
||||
|
||||
<!-- Short Description -->
|
||||
<div id="errorShortDesc">
|
||||
<p id="errorShortDescText">%messageLong%</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Retry Button -->
|
||||
<div id="buttonWrapper">
|
||||
<button id="errorTryAgain" onclick="window.history.back() ">%backButton%</button>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (window.history.length == 1) {
|
||||
document.getElementById('errorTryAgain').style.visibility = 'hidden';
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -5,7 +5,6 @@
|
|||
package org.mozilla.fenix
|
||||
|
||||
import android.net.ConnectivityManager
|
||||
import androidx.annotation.RawRes
|
||||
import androidx.core.content.getSystemService
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
|
@ -20,6 +19,8 @@ import mozilla.components.support.test.robolectric.testContext
|
|||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.fenix.AppRequestInterceptor.Companion.HIGH_RISK_ERROR_PAGES
|
||||
import org.mozilla.fenix.AppRequestInterceptor.Companion.LOW_AND_MEDIUM_RISK_ERROR_PAGES
|
||||
import org.mozilla.fenix.ext.isOnline
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
@ -67,8 +68,7 @@ class AppRequestInterceptorTest {
|
|||
val actualPage = createActualErrorPage(error)
|
||||
val expectedPage = createExpectedErrorPage(
|
||||
error = error,
|
||||
html = R.raw.low_risk_error_pages,
|
||||
css = R.raw.low_and_medium_risk_error_style
|
||||
html = LOW_AND_MEDIUM_RISK_ERROR_PAGES
|
||||
)
|
||||
|
||||
assertThat(actualPage).isEqualTo(expectedPage)
|
||||
|
@ -85,8 +85,7 @@ class AppRequestInterceptorTest {
|
|||
val actualPage = createActualErrorPage(error)
|
||||
val expectedPage = createExpectedErrorPage(
|
||||
error = error,
|
||||
html = R.raw.medium_and_high_risk_error_pages,
|
||||
css = R.raw.low_and_medium_risk_error_style
|
||||
html = LOW_AND_MEDIUM_RISK_ERROR_PAGES
|
||||
)
|
||||
|
||||
assertThat(actualPage).isEqualTo(expectedPage)
|
||||
|
@ -104,8 +103,7 @@ class AppRequestInterceptorTest {
|
|||
val actualPage = createActualErrorPage(error)
|
||||
val expectedPage = createExpectedErrorPage(
|
||||
error = error,
|
||||
html = R.raw.medium_and_high_risk_error_pages,
|
||||
css = R.raw.high_risk_error_style
|
||||
html = HIGH_RISK_ERROR_PAGES
|
||||
)
|
||||
|
||||
assertThat(actualPage).isEqualTo(expectedPage)
|
||||
|
@ -114,11 +112,15 @@ class AppRequestInterceptorTest {
|
|||
|
||||
private fun createActualErrorPage(error: ErrorType): String {
|
||||
val errorPage = interceptor.onErrorRequest(session = mockk(), errorType = error, uri = null)
|
||||
as RequestInterceptor.ErrorResponse.Content
|
||||
return errorPage.data
|
||||
as RequestInterceptor.ErrorResponse.Uri
|
||||
return errorPage.uri
|
||||
}
|
||||
|
||||
private fun createExpectedErrorPage(error: ErrorType, @RawRes html: Int, @RawRes css: Int): String {
|
||||
return ErrorPages.createErrorPage(testContext, error, null, html, css)
|
||||
private fun createExpectedErrorPage(error: ErrorType, html: String): String {
|
||||
return ErrorPages.createUrlEncodedErrorPage(
|
||||
context = testContext,
|
||||
errorType = error,
|
||||
htmlResource = html
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user