Skip to content

Commit

Permalink
fix: navigation started
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf-2 committed Feb 15, 2024
1 parent 190c8ad commit 0e98a68
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 318 deletions.
394 changes: 189 additions & 205 deletions src/bidiMapper/domains/context/BrowsingContextImpl.ts

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/utils/EventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ export class EventEmitter<Events extends Record<EventType, unknown>> {
* @param handler The handler function to run when the event occurs
* @return `this` to enable chaining method calls.
*/
once(event: EventType, handler: Handler): this {
const onceHandler: Handler = (eventData) => {
once<Key extends keyof Events>(
event: Key,
handler: Handler<Events[Key]>
): this {
const onceHandler = (eventData: Events[Key]) => {
handler(eventData);
this.off(event, onceHandler);
};
Expand Down
3 changes: 2 additions & 1 deletion tests/browsing_context/test_fragment_navigated.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from anys import ANY_STR
from test_helpers import (ANY_TIMESTAMP, goto_url, read_JSON_message,
send_JSON_command, subscribe)

Expand Down Expand Up @@ -43,7 +44,7 @@ async def test_browsingContext_fragmentNavigated_event(websocket, context_id):
"method": "browsingContext.fragmentNavigated",
"params": {
"context": context_id,
"navigation": None,
"navigation": ANY_STR,
"timestamp": ANY_TIMESTAMP,
"url": url + "#test",
}
Expand Down
18 changes: 10 additions & 8 deletions tests/browsing_context/test_navigate.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ async def test_browsingContext_navigateSameDocumentNavigation_waitNone_navigated
await goto_url(websocket, context_id, url, "complete")

resp = await goto_url(websocket, context_id, url_with_hash_1, "none")
assert resp == {'navigation': None, 'url': url_with_hash_1}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_1}

resp = await goto_url(websocket, context_id, url_with_hash_2, "none")
assert resp == {'navigation': None, 'url': url_with_hash_2}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_2}


@pytest.mark.asyncio
Expand All @@ -225,7 +225,7 @@ async def test_browsingContext_navigateSameDocumentNavigation_waitInteractive_na

resp = await goto_url(websocket, context_id, url_with_hash_1,
"interactive")
assert resp == {'navigation': None, 'url': url_with_hash_1}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_1}

result = await get_tree(websocket, context_id)

Expand All @@ -241,7 +241,7 @@ async def test_browsingContext_navigateSameDocumentNavigation_waitInteractive_na

resp = await goto_url(websocket, context_id, url_with_hash_2,
"interactive")
assert resp == {'navigation': None, 'url': url_with_hash_2}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_2}

result = await get_tree(websocket, context_id)

Expand All @@ -267,7 +267,7 @@ async def test_browsingContext_navigateSameDocumentNavigation_waitComplete_navig
await goto_url(websocket, context_id, url, "complete")

resp = await goto_url(websocket, context_id, url_with_hash_1, "complete")
assert resp == {'navigation': None, 'url': url_with_hash_1}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_1}

result = await get_tree(websocket, context_id)

Expand All @@ -282,7 +282,7 @@ async def test_browsingContext_navigateSameDocumentNavigation_waitComplete_navig
} == result

resp = await goto_url(websocket, context_id, url_with_hash_2, "complete")
assert resp == {'navigation': None, 'url': url_with_hash_2}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_2}

result = await get_tree(websocket, context_id)

Expand Down Expand Up @@ -344,13 +344,15 @@ async def test_browsingContext_navigationStartedEvent_viaScript(
}
})

await read_JSON_message(websocket)

response = await read_JSON_message(websocket)
assert response == {
'type': 'event',
"method": "browsingContext.navigationStarted",
"params": {
"context": context_id,
"navigation": None,
"navigation": ANY_STR,
"timestamp": ANY_TIMESTAMP,
# TODO: Should report correct string
"url": ANY_STR,
Expand Down Expand Up @@ -381,7 +383,7 @@ async def test_browsingContext_navigationStartedEvent_viaCommand(
"method": "browsingContext.navigationStarted",
"params": {
"context": context_id,
"navigation": None,
"navigation": ANY_STR,
"timestamp": ANY_TIMESTAMP,
# TODO: Should report correct string
"url": ANY_STR,
Expand Down
12 changes: 6 additions & 6 deletions tests/browsing_context/test_nested_browsing_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ async def test_nestedBrowsingContext_navigateSameDocumentNavigation_waitNone_nav
await goto_url(websocket, iframe_id, url, "complete")

resp = await goto_url(websocket, iframe_id, url_with_hash_1, "none")
assert resp == {'navigation': None, 'url': url_with_hash_1}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_1}

resp = await goto_url(websocket, iframe_id, url_with_hash_2, "none")
assert resp == {'navigation': None, 'url': url_with_hash_2}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_2}


@pytest.mark.asyncio
Expand All @@ -184,7 +184,7 @@ async def test_nestedBrowsingContext_navigateSameDocumentNavigation_waitInteract
await goto_url(websocket, iframe_id, url, "complete")

resp = await goto_url(websocket, iframe_id, url_with_hash_1, "interactive")
assert resp == {'navigation': None, 'url': url_with_hash_1}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_1}

result = await get_tree(websocket, iframe_id)

Expand All @@ -199,7 +199,7 @@ async def test_nestedBrowsingContext_navigateSameDocumentNavigation_waitInteract
} == result

resp = await goto_url(websocket, iframe_id, url_with_hash_2, "interactive")
assert resp == {'navigation': None, 'url': url_with_hash_2}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_2}

result = await get_tree(websocket, iframe_id)

Expand All @@ -225,7 +225,7 @@ async def test_nestedBrowsingContext_navigateSameDocumentNavigation_waitComplete
await goto_url(websocket, iframe_id, url, "complete")

resp = await goto_url(websocket, iframe_id, url_with_hash_1, "complete")
assert resp == {'navigation': None, 'url': url_with_hash_1}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_1}

result = await get_tree(websocket, iframe_id)

Expand All @@ -240,7 +240,7 @@ async def test_nestedBrowsingContext_navigateSameDocumentNavigation_waitComplete
} == result

resp = await goto_url(websocket, iframe_id, url_with_hash_2, "complete")
assert resp == {'navigation': None, 'url': url_with_hash_2}
assert resp == {'navigation': ANY_STR, 'url': url_with_hash_2}

result = await get_tree(websocket, iframe_id)

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
[test_subscribe]
expected: FAIL

[test_timestamp]
expected: FAIL

[test_iframe]
expected: FAIL

Expand Down Expand Up @@ -34,6 +31,3 @@

[test_redirect_navigation]
expected: FAIL

[test_navigate_history_pushstate]
expected: FAIL

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
[test_subscribe]
expected: FAIL

[test_timestamp]
expected: FAIL

[test_iframe]
expected: FAIL

Expand Down Expand Up @@ -34,6 +31,3 @@

[test_redirect_navigation]
expected: FAIL

[test_navigate_history_pushstate]
expected: FAIL

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
[test_subscribe]
expected: FAIL

[test_timestamp]
expected: FAIL

[test_iframe]
expected: FAIL

Expand Down Expand Up @@ -34,6 +31,3 @@

[test_redirect_navigation]
expected: FAIL

[test_navigate_history_pushstate]
expected: FAIL

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
[test_subscribe]
expected: FAIL

[test_timestamp]
expected: FAIL

[test_iframe]
expected: FAIL

Expand Down Expand Up @@ -34,6 +31,3 @@

[test_redirect_navigation]
expected: FAIL

[test_navigate_history_pushstate]
expected: FAIL

0 comments on commit 0e98a68

Please sign in to comment.