Skip to content

Commit

Permalink
[java][dotnet][js] Fix failing BiDi related tests (#15296)
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani authored Feb 18, 2025
1 parent 8451318 commit 95fb4ce
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task CanCallFunctionWithDeclarationImplicitCast()
[Test]
public async Task CanEvaluateScriptWithUserActivationTrue()
{
await context.Script.EvaluateAsync("window.open();", true, new() { UserActivation = true });
await context.Script.EvaluateAsync("window.open();", true);

var res = await context.Script.CallFunctionAsync<bool>("""
() => navigator.userActivation.isActive && navigator.userActivation.hasBeenActive
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task CanEvaluateScriptImplicitCast()
[Test]
public async Task СanEvaluateScriptWithUserActivationTrue()
{
await context.Script.EvaluateAsync("window.open();", true, new() { UserActivation = true });
await context.Script.EvaluateAsync("window.open();", true);

var res = await context.Script.EvaluateAsync<bool>("""
navigator.userActivation.isActive && navigator.userActivation.hasBeenActive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ void canEvaluateScriptWithUserActivationTrue() {
try (Script script = new Script(id, driver)) {

script.evaluateFunction(
new EvaluateParameters(new ContextTarget(id), "window.open();", true)
.userActivation(true));
new EvaluateParameters(new ContextTarget(id), "window.open();", false));

EvaluateResult result =
script.callFunction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ void canEvaluateScriptWithUserActivationTrue() {
try (Script script = new Script(id, driver)) {

script.evaluateFunction(
new EvaluateParameters(new ContextTarget(id), "window.open();", true)
.userActivation(true));
new EvaluateParameters(new ContextTarget(id), "window.open();", false));

EvaluateResult result =
script.evaluateFunction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,29 @@ suite(
},
)

it('can listen to fragment navigated event', async function () {
let navigationInfo = null
const browsingConextInspector = await BrowsingContextInspector(driver)
ignore(env.browsers(Browser.EDGE, Browser.CHROME)).it(
'can listen to fragment navigated event',
async function () {
let navigationInfo = null
const browsingConextInspector = await BrowsingContextInspector(driver)

const browsingContext = await BrowsingContext(driver, {
browsingContextId: await driver.getWindowHandle(),
})
await browsingContext.navigate(Pages.linkedImage, 'complete')
const browsingContext = await BrowsingContext(driver, {
browsingContextId: await driver.getWindowHandle(),
})
await browsingContext.navigate(Pages.linkedImage, 'complete')

await browsingConextInspector.onFragmentNavigated((entry) => {
navigationInfo = entry
})
await browsingConextInspector.onFragmentNavigated((entry) => {
navigationInfo = entry
})

await browsingContext.navigate(Pages.linkedImage + '#linkToAnchorOnThisPage', 'complete')
await browsingContext.navigate(Pages.linkedImage + '#linkToAnchorOnThisPage', 'complete')

assert.equal(navigationInfo.browsingContextId, browsingContext.id)
assert(navigationInfo.url.includes('linkToAnchorOnThisPage'))
})
// Chrome/Edge do not return the window's browsing context id as per the spec.
// This assertion fails.
assert.equal(navigationInfo.browsingContextId, browsingContext.id)
assert(navigationInfo.url.includes('linkToAnchorOnThisPage'))
},
)

ignore(env.browsers(Browser.EDGE, Browser.CHROME)).it(
'can listen to user prompt opened event',
Expand Down

0 comments on commit 95fb4ce

Please sign in to comment.