mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-28 23:06:37 +01:00
d9450f454d
* feat(17901): fix network, add-account and mv3 phishing warning issue * feature(17901): trigger a pipeline * feature(17901): remove findClickale to avoid conflicting clickElement
67 lines
2.1 KiB
JavaScript
67 lines
2.1 KiB
JavaScript
const { strict: assert } = require('assert');
|
|
const {
|
|
withFixtures,
|
|
mockPhishingDetection,
|
|
openDapp,
|
|
defaultGanacheOptions,
|
|
assertAccountBalanceForDOM,
|
|
restartServiceWorker,
|
|
SERVICE_WORKER_URL,
|
|
regularDelayMs,
|
|
} = require('../helpers');
|
|
const FixtureBuilder = require('../fixture-builder');
|
|
|
|
describe('Phishing warning page', function () {
|
|
const driverOptions = { openDevToolsForTabs: true };
|
|
|
|
it('should restore the transaction when service worker restarts', async function () {
|
|
let windowHandles;
|
|
|
|
await withFixtures(
|
|
{
|
|
dapp: true,
|
|
fixtures: new FixtureBuilder().build(),
|
|
ganacheOptions: defaultGanacheOptions,
|
|
title: this.test.title,
|
|
testSpecificMock: mockPhishingDetection,
|
|
driverOptions,
|
|
},
|
|
async ({ driver, ganacheServer }) => {
|
|
await driver.navigate();
|
|
// log in wallet
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
// DAPP is detected as phishing page
|
|
await openDapp(driver);
|
|
const phishingPageHeader = await driver.findElements({
|
|
text: 'Deceptive site ahead',
|
|
tag: 'h1',
|
|
});
|
|
assert.ok(phishingPageHeader.length, 1);
|
|
|
|
// Restart service worker
|
|
await driver.openNewPage(SERVICE_WORKER_URL);
|
|
await restartServiceWorker(driver);
|
|
|
|
await driver.delay(regularDelayMs);
|
|
// wait until extension is reloaded
|
|
windowHandles = await driver.getAllWindowHandles();
|
|
const extension = windowHandles[0];
|
|
await driver.switchToWindow(extension);
|
|
await assertAccountBalanceForDOM(driver, ganacheServer);
|
|
|
|
// Open the dapp site and extension detect it as phishing warning page
|
|
await openDapp(driver);
|
|
// - extension, dapp, service worker and new dapp
|
|
await driver.waitUntilXWindowHandles(4);
|
|
const newPhishingPageHeader = await driver.findElements({
|
|
text: 'Deceptive site ahead',
|
|
tag: 'h1',
|
|
});
|
|
assert.ok(newPhishingPageHeader.length, 1);
|
|
},
|
|
);
|
|
});
|
|
});
|