OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 2 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
3 Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in> | 3 Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in> |
4 Copyright (C) 2010 Holger Hans Peter Freyther | 4 Copyright (C) 2010 Holger Hans Peter Freyther |
5 | 5 |
6 This library is free software; you can redistribute it and/or | 6 This library is free software; you can redistribute it and/or |
7 modify it under the terms of the GNU Library General Public | 7 modify it under the terms of the GNU Library General Public |
8 License as published by the Free Software Foundation; either | 8 License as published by the Free Software Foundation; either |
9 version 2 of the License, or (at your option) any later version. | 9 version 2 of the License, or (at your option) any later version. |
10 | 10 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 void findText(); | 179 void findText(); |
180 void supportedContentType(); | 180 void supportedContentType(); |
181 // [Qt] tst_QWebPage::infiniteLoopJS() timeouts with DFG JIT | 181 // [Qt] tst_QWebPage::infiniteLoopJS() timeouts with DFG JIT |
182 // https://bugs.webkit.org/show_bug.cgi?id=79040 | 182 // https://bugs.webkit.org/show_bug.cgi?id=79040 |
183 // void infiniteLoopJS(); | 183 // void infiniteLoopJS(); |
184 void navigatorCookieEnabled(); | 184 void navigatorCookieEnabled(); |
185 void deleteQWebViewTwice(); | 185 void deleteQWebViewTwice(); |
186 void renderOnRepaintRequestedShouldNotRecurse(); | 186 void renderOnRepaintRequestedShouldNotRecurse(); |
187 void loadSignalsOrder_data(); | 187 void loadSignalsOrder_data(); |
188 void loadSignalsOrder(); | 188 void loadSignalsOrder(); |
| 189 void openWindowDefaultSize(); |
189 | 190 |
190 #ifdef Q_OS_MAC | 191 #ifdef Q_OS_MAC |
191 void macCopyUnicodeToClipboard(); | 192 void macCopyUnicodeToClipboard(); |
192 #endif | 193 #endif |
193 | 194 |
194 private: | 195 private: |
195 QWebView* m_view; | 196 QWebView* m_view; |
196 QWebPage* m_page; | 197 QWebPage* m_page; |
197 QString tmpDirPath() const | 198 QString tmpDirPath() const |
198 { | 199 { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 }; | 404 }; |
404 | 405 |
405 void tst_QWebPage::consoleOutput() | 406 void tst_QWebPage::consoleOutput() |
406 { | 407 { |
407 ConsolePage page; | 408 ConsolePage page; |
408 page.mainFrame()->evaluateJavaScript("this is not valid JavaScript"); | 409 page.mainFrame()->evaluateJavaScript("this is not valid JavaScript"); |
409 QCOMPARE(page.messages.count(), 1); | 410 QCOMPARE(page.messages.count(), 1); |
410 QCOMPARE(page.lineNumbers.at(0), 1); | 411 QCOMPARE(page.lineNumbers.at(0), 1); |
411 } | 412 } |
412 | 413 |
413 class TestPage : public QWebPage | 414 class TestPage : public QWebPage { |
414 { | 415 Q_OBJECT |
415 public: | 416 public: |
416 TestPage(QObject* parent = 0) : QWebPage(parent) {} | 417 TestPage(QObject* parent = 0) : QWebPage(parent) |
| 418 { |
| 419 connect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeo
metryChangeRequested(QRect))); |
| 420 } |
417 | 421 |
418 struct Navigation { | 422 struct Navigation { |
419 QPointer<QWebFrame> frame; | 423 QPointer<QWebFrame> frame; |
420 QNetworkRequest request; | 424 QNetworkRequest request; |
421 NavigationType type; | 425 NavigationType type; |
422 }; | 426 }; |
423 | 427 |
424 QList<Navigation> navigations; | 428 QList<Navigation> navigations; |
425 QList<QWebPage*> createdWindows; | 429 QList<TestPage*> createdWindows; |
| 430 QRect requestedGeometry; |
426 | 431 |
427 virtual bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest
&request, NavigationType type) { | 432 virtual bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest
&request, NavigationType type) { |
428 Navigation n; | 433 Navigation n; |
429 n.frame = frame; | 434 n.frame = frame; |
430 n.request = request; | 435 n.request = request; |
431 n.type = type; | 436 n.type = type; |
432 navigations.append(n); | 437 navigations.append(n); |
433 return true; | 438 return true; |
434 } | 439 } |
435 | 440 |
436 virtual QWebPage* createWindow(WebWindowType) { | 441 virtual QWebPage* createWindow(WebWindowType) { |
437 QWebPage* page = new TestPage(this); | 442 TestPage* page = new TestPage(this); |
438 createdWindows.append(page); | 443 createdWindows.append(page); |
439 return page; | 444 return page; |
440 } | 445 } |
| 446 |
| 447 private Q_SLOTS: |
| 448 void slotGeometryChangeRequested(const QRect& geom) { |
| 449 requestedGeometry = geom; |
| 450 } |
441 }; | 451 }; |
442 | 452 |
443 void tst_QWebPage::popupFormSubmission() | 453 void tst_QWebPage::popupFormSubmission() |
444 { | 454 { |
445 TestPage page; | 455 TestPage page; |
446 page.settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); | 456 page.settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); |
447 page.mainFrame()->setHtml("<form name=form1 method=get action='' target=myNe
wWin>"\ | 457 page.mainFrame()->setHtml("<form name=form1 method=get action='' target=myNe
wWin>"\ |
448 "<input type=hidden name=foo value='bar'>"\ | 458 "<input type=hidden name=foo value='bar'>"\ |
449 "</form>"); | 459 "</form>"); |
450 page.mainFrame()->evaluateJavaScript("window.open('', 'myNewWin', 'width=500
,height=300,toolbar=0')"); | 460 page.mainFrame()->evaluateJavaScript("window.open('', 'myNewWin', 'width=500
,height=300,toolbar=0')"); |
(...skipping 2794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3245 | 3255 |
3246 m_page->mainFrame()->evaluateJavaScript("document.execCommand('insertText',
true, 'Test');"); | 3256 m_page->mainFrame()->evaluateJavaScript("document.execCommand('insertText',
true, 'Test');"); |
3247 QString typingActionText = m_page->action(QWebPage::Undo)->text(); | 3257 QString typingActionText = m_page->action(QWebPage::Undo)->text(); |
3248 | 3258 |
3249 m_page->mainFrame()->evaluateJavaScript("document.execCommand('indent', true
);"); | 3259 m_page->mainFrame()->evaluateJavaScript("document.execCommand('indent', true
);"); |
3250 QString alignActionText = m_page->action(QWebPage::Undo)->text(); | 3260 QString alignActionText = m_page->action(QWebPage::Undo)->text(); |
3251 | 3261 |
3252 QVERIFY(typingActionText != alignActionText); | 3262 QVERIFY(typingActionText != alignActionText); |
3253 } | 3263 } |
3254 | 3264 |
| 3265 void tst_QWebPage::openWindowDefaultSize() |
| 3266 { |
| 3267 TestPage page; |
| 3268 page.settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); |
| 3269 // Open a default window. |
| 3270 page.mainFrame()->evaluateJavaScript("window.open()"); |
| 3271 // Open a too small window. |
| 3272 page.mainFrame()->evaluateJavaScript("window.open('', '', 'width=10,height=1
0')"); |
| 3273 |
| 3274 QTest::qWait(500); |
| 3275 // The number of popups created should be two. |
| 3276 QVERIFY(page.createdWindows.size() == 2); |
| 3277 |
| 3278 QRect requestedGeometry = page.createdWindows[0]->requestedGeometry; |
| 3279 // Check default size has been requested. |
| 3280 QVERIFY(requestedGeometry.width() == 0); |
| 3281 QVERIFY(requestedGeometry.height() == 0); |
| 3282 |
| 3283 requestedGeometry = page.createdWindows[1]->requestedGeometry; |
| 3284 // Check minimum size has been requested. |
| 3285 QVERIFY(requestedGeometry.width() == 100); |
| 3286 QVERIFY(requestedGeometry.height() == 100); |
| 3287 } |
| 3288 |
3255 QTEST_MAIN(tst_QWebPage) | 3289 QTEST_MAIN(tst_QWebPage) |
3256 #include "tst_qwebpage.moc" | 3290 #include "tst_qwebpage.moc" |
OLD | NEW |