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

fix: do not wait during browsingContext.traverseHistory #1557

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions src/bidiMapper/domains/context/BrowsingContextImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -998,9 +998,6 @@ export class BrowsingContextImpl {
await this.#cdpTarget.cdpClient.sendCommand('Page.navigateToHistoryEntry', {
entryId: entry.id,
});

this.#resetDeferredsIfFinished();
await this.lifecycleLoaded();
}
}

Expand Down
24 changes: 17 additions & 7 deletions tests/browsing_context/test_traverse_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# limitations under the License.

import pytest
from test_helpers import execute_command, goto_url
from test_helpers import (execute_command, goto_url, read_JSON_message,
subscribe)

HISTORY_LENGTH = 2

Expand All @@ -24,20 +25,24 @@ async def test_traverse_history(websocket, context_id, html):
for i in range(HISTORY_LENGTH + 1):
await goto_url(websocket, context_id, html(i))

await subscribe(websocket, ["browsingContext.load"])

await traverse_history(websocket, context_id, -2)
await assert_href_equals(websocket, context_id, html(HISTORY_LENGTH - 2))
await assert_href_equals(websocket, html(HISTORY_LENGTH - 2))

await traverse_history(websocket, context_id, 2)
await assert_href_equals(websocket, context_id, html(HISTORY_LENGTH))
await assert_href_equals(websocket, html(HISTORY_LENGTH))

await traverse_history(websocket, context_id, -1)
await assert_href_equals(websocket, context_id, html(HISTORY_LENGTH - 1))
await assert_href_equals(websocket, html(HISTORY_LENGTH - 1))

await traverse_history(websocket, context_id, 1)
await assert_href_equals(websocket, context_id, html(HISTORY_LENGTH))
await assert_href_equals(websocket, html(HISTORY_LENGTH))

# There is no event here.
await traverse_history(websocket, context_id, 0)
await assert_href_equals(websocket, context_id, html(HISTORY_LENGTH))
await assert_location_href_equals(websocket, context_id,
html(HISTORY_LENGTH))


@pytest.mark.asyncio
Expand All @@ -63,7 +68,12 @@ async def traverse_history(websocket, context_id, delta):
})


async def assert_href_equals(websocket, context_id, href):
async def assert_href_equals(websocket, href):
response = await read_JSON_message(websocket)
assert response["params"]["url"] == href


async def assert_location_href_equals(websocket, context_id, href):
result = await execute_command(
websocket, {
"method": "script.evaluate",
Expand Down
Loading