'Fixture which provides a window with a fake history.'

@pytest.fixture
def fake_history(self, win_registry, stubs, monkeypatch, webview):

    win = FakeMainWindow('fake-geometry-0', win_id=0)
    objreg.register('main-window', win, scope='window', window=0)
    browser = stubs.TabbedBrowserStub([webview])
    objreg.register('tabbed-browser', browser, scope='window', window=0)
    qapp = stubs.FakeQApplication(active_window=win)
    monkeypatch.setattr(sessions, 'QApplication', qapp)
    def set_data(items):
        history = browser.widgets()[0].page().history()
        (stream, _data, user_data) = tabhistory.serialize(items)
        qtutils.deserialize_stream(stream, history)
        for (i, data) in enumerate(user_data):
            history.itemAt(i).setUserData(data)
    (yield set_data)
    objreg.delete('main-window', scope='window', window=0)
    objreg.delete('tabbed-browser', scope='window', window=0)
