-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(android): run selected page tests on android (#5879)
- Loading branch information
1 parent
cbebf64
commit ad5c028
Showing
22 changed files
with
188 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Copyright 2018 Google Inc. All rights reserved. | ||
* Modifications copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { it, expect } from './fixtures'; | ||
import path from 'path'; | ||
|
||
it('should work with browser context scripts', async ({ context, server }) => { | ||
await context.addInitScript(() => window['temp'] = 123); | ||
const page = await context.newPage(); | ||
await page.addInitScript(() => window['injected'] = window['temp']); | ||
await page.goto(server.PREFIX + '/tamperable.html'); | ||
expect(await page.evaluate(() => window['result'])).toBe(123); | ||
}); | ||
|
||
it('should work without navigation, after all bindings', async ({ context }) => { | ||
let callback; | ||
const promise = new Promise(f => callback = f); | ||
await context.exposeFunction('woof', function(arg) { | ||
callback(arg); | ||
}); | ||
|
||
await context.addInitScript(() => { | ||
window['woof']('hey'); | ||
window['temp'] = 123; | ||
}); | ||
const page = await context.newPage(); | ||
|
||
expect(await page.evaluate(() => window['temp'])).toBe(123); | ||
expect(await promise).toBe('hey'); | ||
}); | ||
|
||
it('should work without navigation in popup', async ({ context }) => { | ||
await context.addInitScript(() => window['temp'] = 123); | ||
const page = await context.newPage(); | ||
const [popup] = await Promise.all([ | ||
page.waitForEvent('popup'), | ||
page.evaluate(() => window['win'] = window.open()), | ||
]); | ||
expect(await popup.evaluate(() => window['temp'])).toBe(123); | ||
}); | ||
|
||
it('should work with browser context scripts with a path', async ({ context, server }) => { | ||
await context.addInitScript({ path: path.join(__dirname, 'assets/injectedfile.js') }); | ||
const page = await context.newPage(); | ||
await page.goto(server.PREFIX + '/tamperable.html'); | ||
expect(await page.evaluate(() => window['result'])).toBe(123); | ||
}); | ||
|
||
it('should work with browser context scripts for already created pages', async ({ context, server }) => { | ||
const page = await context.newPage(); | ||
await context.addInitScript(() => window['temp'] = 123); | ||
await page.addInitScript(() => window['injected'] = window['temp']); | ||
await page.goto(server.PREFIX + '/tamperable.html'); | ||
expect(await page.evaluate(() => window['result'])).toBe(123); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.