Skip to content

Commit

Permalink
remove waitUntilExtensionIsFullyStarted as it doesn't work as is
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch committed Jun 11, 2024
1 parent 1635f68 commit ee84404
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
12 changes: 0 additions & 12 deletions test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ async function withFixtures(options, testSuite) {
useBundler,
usePaymaster,
ethConversionInUsd,
waitUntilExtensionIsFullyStarted = false,
} = options;

const fixtureServer = new FixtureServer();
Expand Down Expand Up @@ -177,17 +176,6 @@ async function withFixtures(options, testSuite) {

console.log(`\nExecuting testcase: '${title}'\n`);

if (waitUntilExtensionIsFullyStarted) {
if (
process.env.ENABLE_MV3 === 'true' ||
process.env.ENABLE_MV3 === undefined
) {
await driver.navigate(PAGES.OFFSCREEN);
} else {
await driver.navigate(PAGES.BACKGROUND);
}
}

await testSuite({
driver: driverProxy ?? driver,
contractRegistry,
Expand Down
38 changes: 25 additions & 13 deletions test/e2e/tests/phishing-controller/phishing-detection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,25 @@ describe('Phishing Detection', function () {
function handleRequests(name, value, code) {
server.once('request', async function (_request, response) {
response.setHeader(name, value).writeHead(code).end(`
<meta http-equiv="Refresh" content="0;url="${destination}">
<script>
// this script should not run.
// it is meant to test for regressions in our redirect
// protection due to changes in either MetaMask or browsers.
document.location.href = "${destination}";
alert("trying to prevent phishing protection");
while(true){}
</script>
<!doctype html>
<html>
<head>
<meta http-equiv="Refresh" content="0;url="${destination}"/>
<title>Phishing test</title>
<script>
// this script should not run.
// it is meant to test for regressions in our redirect
// protection due to changes in either MetaMask or browsers.
document.location.href = "${destination}";
alert("trying to prevent phishing protection");
while(true){}
</script>
</head>
<body>
<h1>Redirecting...</h1>
</body>
</html>
`);
});
}
Expand Down Expand Up @@ -387,9 +397,6 @@ describe('Phishing Detection', function () {
const { promise, resolve } = createDeferredPromise();
fixturePromise = withFixtures(
{
// The redirect Phishing handler isn't active until the extension is
// fully started.
waitUntilExtensionIsFullyStarted: true,
fixtures: new FixtureBuilder().build(),
ganacheOptions: defaultGanacheOptions,
title: this.test.fullTitle(),
Expand All @@ -406,6 +413,11 @@ describe('Phishing Detection', function () {
},
);
driver = await promise;

// required to ensure MetaMask is fully started before running tests
// if we had a way of detecting when the offscreen/background were ready
// we could remove this
await unlockWallet(driver);
});
after('Shut down fixtures', async function () {
deferredTestSuite.resolve(); // let the fixtures know tests are complete
Expand All @@ -419,7 +431,7 @@ describe('Phishing Detection', function () {
});

for (const code of redirectableStatusCodes) {
it(`should display the MetaMask Phishing Detection page if a blocked site redirects via HTTP Status Code ${code} to another page`, async function () {
it.only(`should display the MetaMask Phishing Detection page if a blocked site redirects via HTTP Status Code ${code} to another page`, async function () {
const { port } = server.address();
const refresh = { name: 'Refresh', value: `0;url="${destination}"` };
const location = { name: 'Location', value: destination };
Expand Down

0 comments on commit ee84404

Please sign in to comment.