Bug 38840 - [Qt] The QWebPage crashes on history.pushState().
Summary: [Qt] The QWebPage crashes on history.pushState().
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: History (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Jędrzej Nowacki
URL:
Keywords: HTML5, Qt, QtTriaged
Depends on:
Blocks: 36464
  Show dependency treegraph
 
Reported: 2010-05-10 04:07 PDT by Jędrzej Nowacki
Modified: 2010-05-20 04:27 PDT (History)
5 users (show)

See Also:


Attachments
Fix v1 (2.34 KB, patch)
2010-05-11 03:26 PDT, Jędrzej Nowacki
no flags Details | Formatted Diff | Diff
Fix v1 (3.83 KB, patch)
2010-05-11 07:54 PDT, Jędrzej Nowacki
no flags Details | Formatted Diff | Diff
Fix v2 (4.50 KB, patch)
2010-05-12 00:51 PDT, Jędrzej Nowacki
no flags Details | Formatted Diff | Diff
Fix v3 (4.16 KB, patch)
2010-05-18 02:01 PDT, Jędrzej Nowacki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jędrzej Nowacki 2010-05-10 04:07:11 PDT
This code crashes:

QWebPage page;
page.mainFrame()->setHtml("<html><body></body></html>");
page.mainFrame()->evaluateJavaScript("history.pushState()");

The code crashes inside the HistoryController::pushState because a null pointer (m_previousItem is not set).

The problem is casued by a feature of the QWebFrame::setHtml(); it doesn't set HistoryItem. The easiest workaround is to use QWebFrame::load instead.
Comment 1 Jędrzej Nowacki 2010-05-11 03:26:41 PDT
Created attachment 55685 [details]
Fix v1

This is a crash fix. I think it is the only thing we can do about it. Some history feature won't work.
Comment 2 Jędrzej Nowacki 2010-05-11 07:54:37 PDT
Created attachment 55702 [details]
Fix v1

:-)
Comment 3 Jędrzej Nowacki 2010-05-11 09:48:30 PDT
Comment on attachment 55702 [details]
Fix v1

It breaks layout tests... clearing flags
Comment 4 Jędrzej Nowacki 2010-05-12 00:51:54 PDT
Created attachment 55816 [details]
Fix v2
Comment 5 Antonio Gomes 2010-05-15 10:07:09 PDT
It would be good to mention in the ChangeLog why this is needed, as you said in the comment #0: "The problem is casued by a feature of the QWebFrame::setHtml(); it doesn't set HistoryItem."

... and that it is based of this:

/*
  ...
  \note This method will not affect session or global history for the frame.
*/
void QWebFrame::setHtml(const QString &html, const QUrl &baseUrl)
Comment 6 Antonio Gomes 2010-05-15 10:09:38 PDT
Darin Fisher might be a potention reviewer
Comment 7 Jędrzej Nowacki 2010-05-18 02:01:06 PDT
Created attachment 56338 [details]
Fix v3

Changelog changes :-)
Comment 8 Kenneth Rohde Christiansen 2010-05-18 06:38:32 PDT
Yes, I remember that specific behaviour, nice that we have a test for it now.
Comment 9 WebKit Commit Bot 2010-05-19 21:18:11 PDT
Comment on attachment 56338 [details]
Fix v3

Clearing flags on attachment: 56338

Committed r59815: <http://trac.webkit.org/changeset/59815>
Comment 10 WebKit Commit Bot 2010-05-19 21:18:18 PDT
All reviewed patches have been landed.  Closing bug.
Comment 11 Darin Fisher (:fishd, Google) 2010-05-19 21:30:26 PDT
Comment on attachment 56338 [details]
Fix v3

WebCore/loader/HistoryController.cpp:647
 +      if (!m_previousItem)
this seems wrong to me.  you probably meant to check m_currentItem here.
note that m_currentItem is assigned to m_previousItem after the call to
createTreeItem.  this change means that the first page in a window cannot
call pushState, which is not good.
Comment 12 Jędrzej Nowacki 2010-05-20 04:27:17 PDT
(In reply to comment #11)
> (From update of attachment 56338 [details])
> WebCore/loader/HistoryController.cpp:647
>  +      if (!m_previousItem)
> this seems wrong to me.  you probably meant to check m_currentItem here.
> note that m_currentItem is assigned to m_previousItem after the call to
> createTreeItem.  this change means that the first page in a window cannot
> call pushState, which is not good.
You are right. I created a bug for it (bug 39418)