Bug 1786640 Comment 15 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

For reference, here's a test which intermittently reproduces the issue on desktop:
```
def test_navigate_back_and_switch_frame(session, inline):
    target_page = inline("<p id='foo'>foo</p>")

    session.url = inline("<a id='link' href='{}'>click</a>".format(target_page))
    element = session.find.css("a", all=False)

    orig_handles = session.handles

    response = element_click(session, element)
    assert_success(response)

    session.execute_script("history.go(-1)")
    session.switch_frame(None)

    wait = Poll(
        session,
        timeout=5,
        ignored_exceptions=NoSuchElementException,
        message="Expected element has not been found")
    wait.until(lambda s: s.find.css("#link"))
```

The trick is to start a bfcache navigation that will not be awaited by marionette and then call `switch_frame(None)`. But as you can see it's a bit harder to trigger than on android, which seems to replace browsing contexts much more often than desktop.
For reference, here's a test which intermittently reproduces the issue on desktop:
```python
def test_navigate_back_and_switch_frame(session, inline):
    target_page = inline("<p id='foo'>foo</p>")

    session.url = inline("<a id='link' href='{}'>click</a>".format(target_page))
    element = session.find.css("a", all=False)

    orig_handles = session.handles

    response = element_click(session, element)
    assert_success(response)

    session.execute_script("history.go(-1)")
    session.switch_frame(None)

    wait = Poll(
        session,
        timeout=5,
        ignored_exceptions=NoSuchElementException,
        message="Expected element has not been found")
    wait.until(lambda s: s.find.css("#link"))
```

The trick is to start a bfcache navigation that will not be awaited by marionette and then call `switch_frame(None)`. But as you can see it's a bit harder to trigger than on android, which seems to replace browsing contexts much more often than desktop.

Back to Bug 1786640 Comment 15