Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Phishing and Malware support - iOS #252

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions integration-tests/ios.spec-int.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ test.describe('temporary reporting flows', () => {
await dash.mocks.calledForAlert('missingDescription');
});
});

test('opens to category selection from primary screen when breakageScreen param is present', async ({ page }) => {
const dash = await DashboardPage.webkit(page, { breakageScreen: 'categorySelection', platform: 'ios' });
await dash.reducedMotion();
Expand Down Expand Up @@ -271,6 +272,48 @@ test.describe('temporary reporting flows', () => {
});
});

test.describe('phishing & malware protection', () => {
test('phishing warning', { tag: '@screenshots' }, async ({ page }) => {
/** @type {DashboardPage} */
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
await dash.addState([testDataStates.phishing]);
await dash.screenshot('phishing-warning.png');
await dash.hasPhishingIcon();
await dash.hasPhishingHeadingText();
await dash.hasPhishingWarningText();
await dash.hasPhishingStatusText();
await dash.connectionLinkDoesntShow();
});

test('malware warning', { tag: '@screenshots' }, async ({ page }) => {
/** @type {DashboardPage} */
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
await dash.addState([testDataStates.malware]);
await dash.screenshot('malware-warning.png');
await dash.hasMalwareIcon();
await dash.hasMalwareHeadingText();
await dash.hasMalwareWarningText();
await dash.hasMalwareStatusText();
await dash.connectionLinkDoesntShow();
});

test('shows report as safe link', async ({ page }) => {
/** @type {DashboardPage} */
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
await dash.addState([testDataStates.malware]);
await dash.clickReportAsSafeLink();
await dash.mocks.calledForReportAsSafeLink('https://privacy-test-pages.site/security/badware/malware.html');
});

test('shows help page link', async ({ page }) => {
/** @type {DashboardPage} */
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
await dash.addState([testDataStates.malware]);
await dash.clickHelpPageLink();
await dash.mocks.calledForHelpPagesLink();
});
});

test.describe('screenshots', { tag: '@screenshots' }, () => {
const states = [
{ name: '01', state: testDataStates.protectionsOn },
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion shared/js/browser/macos-communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const resolveInitialRender = function () {
const isIsProtectedSet = typeof protections !== 'undefined';
const isTrackerBlockingDataSet = typeof trackerBlockingData === 'object';
const isLocaleSet = typeof locale === 'string';
const isMaliciousSiteSet = isIOS() || (maliciousSiteStatus && maliciousSiteStatus.kind !== undefined);
const isMaliciousSiteSet = maliciousSiteStatus && maliciousSiteStatus.kind !== undefined;
if (!isLocaleSet || !isUpgradedHttpsSet || !isIsProtectedSet || !isTrackerBlockingDataSet || !isMaliciousSiteSet) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion shared/js/browser/utils/communication-mocks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function mockDataProvider(params) {
window.onChangeLocale?.(state.localeSettings);
window.onChangeRequestData(state.url, { requests: state.requests || [] });

if (platform?.name === 'macos') {
if (platform?.name === 'macos' || platform?.name === 'ios') {
window.onChangeMaliciousSiteStatus?.(state.maliciousSiteStatus);
}
}
Expand Down
2 changes: 1 addition & 1 deletion shared/js/ui/platform-features.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function createPlatformFeatures(platform) {
initialScreen: screen,
opener,
supportsInvalidCertsImplicitly: platform.name !== 'browser' && platform.name !== 'windows',
supportsMaliciousSiteWarning: platform.name === 'macos',
supportsMaliciousSiteWarning: platform.name === 'macos' || platform.name === 'ios',
includeToggleOnBreakageForm,
breakageScreen,
randomisedCategories,
Expand Down
2 changes: 1 addition & 1 deletion v2/data-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class DataChannel extends EventTarget {

/** @type {import('../shared/js/ui/models/site.js').PublicSiteModel['httpsState']} */
const nextState = (() => {
if (this.features.supportsMaliciousSiteWarning && this.tab.maliciousSiteStatus) {
if (this.features.supportsMaliciousSiteWarning && typeof this.tab.maliciousSiteStatus === 'object') {
const { kind } = this.tab.maliciousSiteStatus;
if (kind === 'phishing' || kind === 'malware') {
return kind;
Expand Down
Loading