Changeset 90403 in webkit
- Timestamp:
- Jul 5, 2011 12:45:00 PM (13 years ago)
- Location:
- trunk/Source/WebKit/qt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/qt/ChangeLog
r90341 r90403 1 2011-07-05 Rafael Brandao <rafael.lobo@openbossa.org> 2 3 [Qt] Fix tst_QWebFrame::setHtmlWithResource() API test 4 https://bugs.webkit.org/show_bug.cgi?id=63235 5 6 Modified baseUrl to be a local file in order to get a security origin 7 that is allowed to request local resources. Removed QSignalSpy from it 8 as loadFinished always happens, and the original test was split into two. 9 10 Reviewed by Benjamin Poulain. 11 12 * tests/qwebframe/tst_qwebframe.cpp: 13 (tst_QWebFrame::setHtmlWithImageResource): 14 (tst_QWebFrame::setHtmlWithStylesheetResource): 15 (tst_QWebFrame::setHtmlWithBaseURL): 16 1 17 2011-04-02 Robert Hogan <robert@webkit.org> 2 18 -
trunk/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
r90181 r90403 620 620 void javaScriptWindowObjectClearedOnEvaluate(); 621 621 void setHtml(); 622 void setHtmlWithResource(); 622 void setHtmlWithImageResource(); 623 void setHtmlWithStylesheetResource(); 623 624 void setHtmlWithBaseURL(); 624 625 void setHtmlWithJSAlert(); … … 2489 2490 } 2490 2491 2491 void tst_QWebFrame::setHtmlWithResource() 2492 { 2493 QString html("<html><body><p>hello world</p><img src='qrc:/image.png'/></body></html>"); 2494 2492 void tst_QWebFrame::setHtmlWithImageResource() 2493 { 2494 // By default, only security origins of local files can load local resources. 2495 // So we should specify baseUrl to be a local file in order to get a proper origin and load the local image. 2496 2497 QLatin1String html("<html><body><p>hello world</p><img src='qrc:/image.png'/></body></html>"); 2495 2498 QWebPage page; 2496 2499 QWebFrame* frame = page.mainFrame(); 2497 2500 2498 // in few seconds, the image should be completey loaded 2499 QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); 2501 frame->setHtml(html, QUrl(QLatin1String("file:///path/to/file"))); 2502 waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); 2503 2504 QCOMPARE(frame->evaluateJavaScript("document.images.length").toInt(), 1); 2505 QCOMPARE(frame->evaluateJavaScript("document.images[0].width").toInt(), 128); 2506 QCOMPARE(frame->evaluateJavaScript("document.images[0].height").toInt(), 128); 2507 2508 // Now we test the opposite: without a baseUrl as a local file, we cannot request local resources. 2509 2500 2510 frame->setHtml(html); 2501 2511 waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); 2502 QCOMPARE(spy.count(), 1);2503 2504 2512 QCOMPARE(frame->evaluateJavaScript("document.images.length").toInt(), 1); 2505 QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=63235", Continue); 2506 QCOMPARE(frame->evaluateJavaScript("document.images[0].width").toInt(), 128); 2507 QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=63235", Continue); 2508 QCOMPARE(frame->evaluateJavaScript("document.images[0].height").toInt(), 128); 2509 2510 QString html2 = 2513 QCOMPARE(frame->evaluateJavaScript("document.images[0].width").toInt(), 0); 2514 QCOMPARE(frame->evaluateJavaScript("document.images[0].height").toInt(), 0); 2515 } 2516 2517 void tst_QWebFrame::setHtmlWithStylesheetResource() 2518 { 2519 // By default, only security origins of local files can load local resources. 2520 // So we should specify baseUrl to be a local file in order to be able to download the local stylesheet. 2521 2522 const char* htmlData = 2511 2523 "<html>" 2512 2524 "<head>" … … 2517 2529 "</body>" 2518 2530 "</html>"; 2519 2520 // in few seconds, the CSS should be completey loaded 2521 frame->setHtml(html2); 2531 QLatin1String html(htmlData); 2532 QWebPage page; 2533 QWebFrame* frame = page.mainFrame(); 2534 QWebElement webElement; 2535 2536 frame->setHtml(html, QUrl(QLatin1String("qrc:///file"))); 2522 2537 waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); 2523 QCOMPARE(spy.size(), 2); 2524 2525 QWebElement p = frame->documentElement().findAll("p").at(0); 2526 QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=63235", Continue); 2527 QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("red")); 2538 webElement = frame->documentElement().findFirst("p"); 2539 QCOMPARE(webElement.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("red")); 2540 2541 // Now we test the opposite: without a baseUrl as a local file, we cannot request local resources. 2542 2543 frame->setHtml(html, QUrl(QLatin1String("http://www.example.com/"))); 2544 waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); 2545 webElement = frame->documentElement().findFirst("p"); 2546 QCOMPARE(webElement.styleProperty("color", QWebElement::CascadedStyle), QString()); 2528 2547 } 2529 2548 2530 2549 void tst_QWebFrame::setHtmlWithBaseURL() 2531 2550 { 2551 // This tests if baseUrl is indeed affecting the relative paths from resources. 2552 // As we are using a local file as baseUrl, its security origin should be able to load local resources. 2553 2532 2554 if (!QDir(TESTS_SOURCE_DIR).exists()) 2533 2555 QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll);
Note: See TracChangeset
for help on using the changeset viewer.