Skip to content

Commit

Permalink
Update JS examples for async newContext
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed May 7, 2024
1 parent b1771a7 commit a7b9285
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/colorscheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const options = {
export default async function() {
const preferredColorScheme = 'dark';

const context = browser.newContext({
const context = await browser.newContext({
// valid values are "light", "dark" or "no-preference"
colorScheme: preferredColorScheme,
});
Expand Down
2 changes: 1 addition & 1 deletion examples/device_emulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default async function() {
// Object.assign instead to merge browser context and device options.
// See https://github.com/grafana/k6/issues/2296
const options = Object.assign({ locale: 'es-ES' }, device);
const context = browser.newContext(options);
const context = await browser.newContext(options);
const page = context.newPage();

try {
Expand Down
2 changes: 1 addition & 1 deletion examples/dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const options = {
}

export default async function() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand Down
4 changes: 2 additions & 2 deletions examples/elementstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const options = {
}
}

export default function() {
const context = browser.newContext();
export default async function() {
const context = await browser.newContext();
const page = context.newPage();

// Inject page content
Expand Down
2 changes: 1 addition & 1 deletion examples/evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const options = {
}

export default async function() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand Down
2 changes: 1 addition & 1 deletion examples/fillform.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const options = {
}

export default async function() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand Down
2 changes: 1 addition & 1 deletion examples/getattribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const options = {
}

export default async function() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand Down
2 changes: 1 addition & 1 deletion examples/grant_permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const options = {
export default async function() {
// grant camera and microphone permissions to the
// new browser context.
const context = browser.newContext({
const context = await browser.newContext({
permissions: ["camera", "microphone"],
});

Expand Down
2 changes: 1 addition & 1 deletion examples/hosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const options = {
};

export default async function() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand Down
2 changes: 1 addition & 1 deletion examples/locator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const options = {
}

export default async function() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand Down
2 changes: 1 addition & 1 deletion examples/locator_pom.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class Bet {
}

export default async function() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

const bet = new Bet(page);
Expand Down
2 changes: 1 addition & 1 deletion examples/querying.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const options = {
}

export default async function() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand Down
2 changes: 1 addition & 1 deletion examples/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const options = {
}

export default async function() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand Down
6 changes: 3 additions & 3 deletions examples/throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const options = {
}

export async function normal() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand All @@ -50,7 +50,7 @@ export async function normal() {
}

export async function networkThrottled() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand All @@ -63,7 +63,7 @@ export async function networkThrottled() {
}

export async function cpuThrottled() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand Down
2 changes: 1 addition & 1 deletion examples/waitForEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const options = {
}

export default async function() {
const context = browser.newContext()
const context = await browser.newContext()

// We want to wait for two page creations before carrying on.
var counter = 0
Expand Down
2 changes: 1 addition & 1 deletion examples/waitforfunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const options = {
}

export default async function() {
const context = browser.newContext();
const context = await browser.newContext();
const page = context.newPage();

try {
Expand Down

0 comments on commit a7b9285

Please sign in to comment.