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

test(iframes): add x-frame-options display test #3217

Merged
merged 1 commit into from
Jul 29, 2020
Merged
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
16 changes: 16 additions & 0 deletions test/frame.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,20 @@ describe('Frame Management', function() {
expect(frame2.isDetached()).toBe(false);
expect(frame1).not.toBe(frame2);
});
it.fail(FFOX)('should refuse to display x-frame-options:deny iframe', async({page, server}) => {
server.setRoute('/x-frame-options-deny.html', async (req, res) => {
res.setHeader('Content-Type', 'text/html');
res.setHeader('X-Frame-Options', 'DENY');
res.end(`<!DOCTYPE html><html><head><title>login</title></head><body style="background-color: red;"><p>dangerous login page</p></body></html>`);
});
await page.goto(server.EMPTY_PAGE);
const refusalText = new Promise(f => {
page.on('console', msg => {
if (msg.text().match(/Refused to display/i))
rwoll marked this conversation as resolved.
Show resolved Hide resolved
f(msg.text());
});
});
await page.setContent(`<iframe src="${server.CROSS_PROCESS_PREFIX}/x-frame-options-deny.html"></iframe>`);
expect(await refusalText).toMatch(/Refused to display 'http.*\/x-frame-options-deny\.html' in a frame because it set 'X-Frame-Options' to 'deny'./i)
dgozman marked this conversation as resolved.
Show resolved Hide resolved
});
});