Reviewed by Tony Gentilcore.
Add beforeload to icon and prefetch link rel types
https://bugs.webkit.org/show_bug.cgi?id=56424
Unfortunately, there's lots of skipped tests, and a chrome failure
expectation here, in a strange disjoint set. On the chromium
port, favicon loads don't occur in DRT, so the favicon changes are
expected to fail. On the ports without prefetching, we expect the
prefetching test to fail.
* fast/dom/HTMLLinkElement/prefetch-beforeload-expected.txt: Added.
* fast/dom/HTMLLinkElement/prefetch-beforeload.html: Added.
* http/tests/misc/link-rel-icon-beforeload-expected.txt: Added.
* http/tests/misc/link-rel-icon-beforeload.html: Added.
* platform/chromium/test_expectations.txt:
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* webarchive/test-link-rel-icon-beforeload-expected.webarchive: Added.
* webarchive/test-link-rel-icon-beforeload.html: Added.
2011-03-29 Gavin Peters <gavinp@chromium.org>
Reviewed by Tony Gentilcore.
Add beforeload to icon and prefetch link rel types
https://bugs.webkit.org/show_bug.cgi?id=56424
Over in https://lists.webkit.org/pipermail/webkit-dev/2011-February/016034.html , a webkit-dev
thread, I've discussed my hopes for the link element, and adding the link header. This
change helps improve the link header by making it participate in the beforeload event in
two more important cases.
Tests: fast/dom/HTMLLinkElement/prefetch-beforeload.html
http/tests/misc/link-rel-icon-beforeload.html
webarchive/test-link-rel-icon-beforeload.html
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::checkBeforeLoadEvent):
(WebCore::HTMLLinkElement::process):
* html/HTMLLinkElement.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82342
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-03-29 Gavin Peters <gavinp@chromium.org>
+
+ Reviewed by Tony Gentilcore.
+
+ Add beforeload to icon and prefetch link rel types
+ https://bugs.webkit.org/show_bug.cgi?id=56424
+
+ Unfortunately, there's lots of skipped tests, and a chrome failure
+ expectation here, in a strange disjoint set. On the chromium
+ port, favicon loads don't occur in DRT, so the favicon changes are
+ expected to fail. On the ports without prefetching, we expect the
+ prefetching test to fail.
+
+ * fast/dom/HTMLLinkElement/prefetch-beforeload-expected.txt: Added.
+ * fast/dom/HTMLLinkElement/prefetch-beforeload.html: Added.
+ * http/tests/misc/link-rel-icon-beforeload-expected.txt: Added.
+ * http/tests/misc/link-rel-icon-beforeload.html: Added.
+ * platform/chromium/test_expectations.txt:
+ * platform/gtk/Skipped:
+ * platform/mac/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+ * webarchive/test-link-rel-icon-beforeload-expected.webarchive: Added.
+ * webarchive/test-link-rel-icon-beforeload.html: Added.
+
2011-03-29 Adam Barth <abarth@webkit.org>
Moar pixel expectations.
--- /dev/null
+PASS beforeload called
+This test will only print "PASS" or "FAIL" if link prefetches are enabled, otherwise it will show nothing below.
--- /dev/null
+<body>
+<div id="console"></div>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+}
+</script>
+<html>
+<p>This test will only print "PASS" or "FAIL" if link prefetches are
+enabled, otherwise it will show nothing below.</p>
+<link href="prefetch.link" rel="prefetch" onbeforeload="testPassed('beforeload called');return false" onload="testFailed('onload')" onerror="testFailed('onerror')" />
+</html>
+
--- /dev/null
+<unknown> - didFinishLoading
+http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html, main document URL http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html, http method GET> redirectResponse (null)
+http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html, http status code 200>
+http://127.0.0.1:8000/favicon.ico - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/favicon.ico, main document URL http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html, http method GET> redirectResponse (null)
+http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html - didFinishLoading
+http://127.0.0.1:8000/favicon.ico - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/favicon.ico, http status code 200>
+This test should not show a request for the favicon dont-load-this.ico, since the beforeload handler on the favicon link returns false. Therefore, if the resource request list below shows a request for dont-load-this.ico, then this test has failed.
--- /dev/null
+<html>
+<head>
+<script>
+function runTest()
+{
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.dumpResourceLoadCallbacks();
+ layoutTestController.setIconDatabaseEnabled(true);
+ layoutTestController.queueReload();
+ }
+}
+</script>
+</head>
+<body onload="runTest()">
+<link rel="icon" onbeforeload="return false" href="dont-load-this.ico">
+<p>This test should not show a request for the favicon
+dont-load-this.ico, since the beforeload handler on the favicon link
+returns false. Therefore, if the resource request list below shows a
+request for dont-load-this.ico, then this test has failed.
+</body>
+</html>
BUGXXX GPU MAC SNOWLEOPARD : compositing/overflow/scroll-ancestor-update.html = FAIL
BUGXXX GPU MAC SNOWLEOPARD : compositing/reflections/load-video-in-reflection.html = FAIL
BUGXXX GPU MAC SNOWLEOPARD : compositing/self-painting-layers.html = FAIL
+
+// Chrome doesn't load favicons in DRT tests.
+BUGWK57259 : http/tests/misc/link-rel-icon-beforeload.html = FAIL PASS
fast/dom/HTMLLinkElement/prefetch.html
fast/dom/HTMLLinkElement/prefetch-onerror.html
fast/dom/HTMLLinkElement/prefetch-onload.html
+fast/dom/HTMLLinkElement/prefetch-beforeload.html
# Tests failing because the context menu is grabbing mouse events.
# https://bugs.webkit.org/show_bug.cgi?id=40601
# Link prefetch is disabled by default
fast/dom/HTMLLinkElement/link-and-subresource-test.html
fast/dom/HTMLLinkElement/prefetch.html
+fast/dom/HTMLLinkElement/prefetch-beforeload.html
fast/dom/HTMLLinkElement/prefetch-onerror.html
fast/dom/HTMLLinkElement/prefetch-onload.html
http/tests/misc/prefetch-purpose.html
# Link prefetch is disabled by default
fast/dom/HTMLLinkElement/link-and-subresource-test.html
fast/dom/HTMLLinkElement/prefetch.html
+fast/dom/HTMLLinkElement/prefetch-beforeload.html
fast/dom/HTMLLinkElement/prefetch-onerror.html
fast/dom/HTMLLinkElement/prefetch-onload.html
http/tests/misc/prefetch-purpose.html
# Link prefetch is disabled by default
fast/dom/HTMLLinkElement/link-and-subresource-test.html
fast/dom/HTMLLinkElement/prefetch.html
+fast/dom/HTMLLinkElement/prefetch-beforeload.html
fast/dom/HTMLLinkElement/prefetch-onerror.html
fast/dom/HTMLLinkElement/prefetch-onload.html
http/tests/misc/prefetch-purpose.html
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>WebMainResource</key>
+ <dict>
+ <key>WebResourceData</key>
+ <string><html><head>
+<script>
+function runTest()
+{
+ if (window.layoutTestController) {
+ layoutTestController.setIconDatabaseEnabled(true);
+ layoutTestController.dumpDOMAsWebArchive();
+ layoutTestController.queueReload();
+ }
+}
+</script>
+</head>
+<body onload="runTest()">
+<div id="console"><div style="font-family: monospace; color: green; ">PASS</div></div>
+<script>
+function print(message, color)
+{
+ var paragraph = document.createElement("div");
+ paragraph.appendChild(document.createTextNode(message));
+ paragraph.style.fontFamily = "monospace";
+ if (color)
+ paragraph.style.color = color;
+ document.getElementById("console").appendChild(paragraph);
+}
+</script>
+<p>This test should have a green 'PASS' just above this line. If it doesn't, you failed.
+<link rel="icon" onbeforeload="print('PASS','green');return false" href="resources/favicon.ico" type="image/x-icon">
+
+
+</p></body></html></string>
+ <key>WebResourceFrameName</key>
+ <string></string>
+ <key>WebResourceMIMEType</key>
+ <string>text/html</string>
+ <key>WebResourceTextEncodingName</key>
+ <string>UTF-8</string>
+ <key>WebResourceURL</key>
+ <string>file:///LayoutTests/webarchive/test-link-rel-icon-beforeload.html</string>
+ </dict>
+</dict>
+</plist>
--- /dev/null
+<html>
+<head>
+<script>
+function runTest()
+{
+ if (window.layoutTestController) {
+ layoutTestController.setIconDatabaseEnabled(true);
+ layoutTestController.dumpDOMAsWebArchive();
+ layoutTestController.queueReload();
+ }
+}
+</script>
+</head>
+<body onload="runTest()">
+<div id="console"></div>
+<script>
+function print(message, color)
+{
+ var paragraph = document.createElement("div");
+ paragraph.appendChild(document.createTextNode(message));
+ paragraph.style.fontFamily = "monospace";
+ if (color)
+ paragraph.style.color = color;
+ document.getElementById("console").appendChild(paragraph);
+}
+</script>
+<p>This test should have a green 'PASS' just above this line. If it doesn't, you failed.
+<link rel="icon" onbeforeload="print('PASS','green');return false" href="resources/favicon.ico" type="image/x-icon">
+</body>
+</html>
+2011-03-29 Gavin Peters <gavinp@chromium.org>
+
+ Reviewed by Tony Gentilcore.
+
+ Add beforeload to icon and prefetch link rel types
+ https://bugs.webkit.org/show_bug.cgi?id=56424
+
+ Over in https://lists.webkit.org/pipermail/webkit-dev/2011-February/016034.html , a webkit-dev
+ thread, I've discussed my hopes for the link element, and adding the link header. This
+ change helps improve the link header by making it participate in the beforeload event in
+ two more important cases.
+
+ Tests: fast/dom/HTMLLinkElement/prefetch-beforeload.html
+ http/tests/misc/link-rel-icon-beforeload.html
+ webarchive/test-link-rel-icon-beforeload.html
+
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::checkBeforeLoadEvent):
+ (WebCore::HTMLLinkElement::process):
+ * html/HTMLLinkElement.h:
+
2011-03-29 Eric Seidel <eric@webkit.org>
Reviewed by Dimitri Glazkov.
}
}
+bool HTMLLinkElement::checkBeforeLoadEvent()
+{
+ RefPtr<Document> originalDocument = document();
+ if (!dispatchBeforeLoadEvent(m_url))
+ return false;
+ // A beforeload handler might have removed us from the document or changed the document.
+ if (!inDocument() || document() != originalDocument)
+ return false;
+ return true;
+}
+
void HTMLLinkElement::process()
{
if (!inDocument() || m_isInShadowTree) {
// IE extension: location of small icon for locationbar / bookmarks
// We'll record this URL per document, even if we later only use it in top level frames
- if (m_relAttribute.m_isIcon && m_url.isValid() && !m_url.isEmpty())
+ if (m_relAttribute.m_isIcon && m_url.isValid() && !m_url.isEmpty()) {
+ if (!checkBeforeLoadEvent())
+ return;
document()->setIconURL(m_url.string(), type);
+ }
if (m_relAttribute.m_isDNSPrefetch) {
Settings* settings = document()->settings();
#if ENABLE(LINK_PREFETCH)
if (m_relAttribute.m_isLinkPrefetch && m_url.isValid() && document()->frame()) {
+ if (!checkBeforeLoadEvent())
+ return;
m_cachedLinkPrefetch = document()->cachedResourceLoader()->requestLinkPrefetch(m_url);
if (m_cachedLinkPrefetch)
m_cachedLinkPrefetch->addClient(this);
m_cachedSheet = 0;
}
- RefPtr<Document> originalDocument = document();
- if (!dispatchBeforeLoadEvent(m_url))
- return;
- // A beforeload handler might have removed us from the document or changed the document.
- if (!inDocument() || document() != originalDocument)
+ if (!checkBeforeLoadEvent())
return;
m_loading = true;
#if ENABLE(LINK_PREFETCH)
void onloadTimerFired(Timer<HTMLLinkElement>*);
#endif
+ bool checkBeforeLoadEvent();
void process();
static void processCallback(Node*);