diff --git a/src/webpage.cpp b/src/webpage.cpp index eaad90dd..734bddf9 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -108,10 +108,11 @@ WebPage::WebPage(QObject *parent, const Config *config) setObjectName("WebPage"); m_webPage = new CustomPage(this); m_mainFrame = m_webPage->mainFrame(); + m_mainFrame->setHtml(BLANK_HTML); - connect(m_mainFrame, SIGNAL(javaScriptWindowObjectCleared()), SIGNAL(initialized())); - connect(m_webPage, SIGNAL(loadStarted()), SIGNAL(loadStarted())); - connect(m_webPage, SIGNAL(loadFinished(bool)), SLOT(finish(bool))); + connect(m_mainFrame, SIGNAL(javaScriptWindowObjectCleared()), SIGNAL(initialized()), Qt::QueuedConnection); + connect(m_webPage, SIGNAL(loadStarted()), SIGNAL(loadStarted()), Qt::QueuedConnection); + connect(m_webPage, SIGNAL(loadFinished(bool)), SLOT(finish(bool)), Qt::QueuedConnection); // Start with transparent background. QPalette palette = m_webPage->palette(); @@ -135,8 +136,6 @@ WebPage::WebPage(QObject *parent, const Config *config) m_webPage->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); m_webPage->settings()->setLocalStoragePath(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); - m_mainFrame->setHtml(BLANK_HTML); - // Custom network access manager to allow traffic monitoring. m_networkAccessManager = new NetworkAccessManager(this, config); m_webPage->setNetworkAccessManager(m_networkAccessManager); diff --git a/test/webpage-spec.js b/test/webpage-spec.js index b4ff6d5b..4feefaf8 100644 --- a/test/webpage-spec.js +++ b/test/webpage-spec.js @@ -236,9 +236,16 @@ describe("WebPage construction with options", function () { }; var page = new WebPage(opts); it("should have onLoadStarted that was specified",function () { - expect(started).toEqual(false); - page.open("about:blank"); - expect(started).toEqual(true); + runs(function() { + expect(started).toEqual(false); + page.open("about:blank"); + }); + + waits(0); + + runs(function() { + expect(started).toEqual(true); + }); }); }); @@ -251,9 +258,16 @@ describe("WebPage construction with options", function () { }; var page = new WebPage(opts); it("should have onLoadFinished that was specified",function () { - expect(finished).toEqual(false); - page.open("about:blank"); - expect(finished).toEqual(true); + runs(function() { + expect(finished).toEqual(false); + page.open("about:blank"); + }); + + waits(0); + + runs(function() { + expect(finished).toEqual(true); + }); }); });