Title: [100577] branches/chromium/912
- Revision
- 100577
- Author
- cev...@google.com
- Date
- 2011-11-17 00:48:29 -0800 (Thu, 17 Nov 2011)
Log Message
Merge 100550
BUG=104223
Review URL: http://codereview.chromium.org/8585026
Modified Paths
Added Paths
Diff
Copied: branches/chromium/912/LayoutTests/mhtml/check_domain-expected.txt (from rev 100550, trunk/LayoutTests/mhtml/check_domain-expected.txt) (0 => 100577)
--- branches/chromium/912/LayoutTests/mhtml/check_domain-expected.txt (rev 0)
+++ branches/chromium/912/LayoutTests/mhtml/check_domain-expected.txt 2011-11-17 08:48:29 UTC (rev 100577)
@@ -0,0 +1,4 @@
+This is a very simple page
+
+Very basic page.
+PASS
Copied: branches/chromium/912/LayoutTests/mhtml/check_domain.mht (from rev 100550, trunk/LayoutTests/mhtml/check_domain.mht) (0 => 100577)
--- branches/chromium/912/LayoutTests/mhtml/check_domain.mht (rev 0)
+++ branches/chromium/912/LayoutTests/mhtml/check_domain.mht 2011-11-17 08:48:29 UTC (rev 100577)
@@ -0,0 +1,45 @@
+From: <Saved by UnMHT>
+Subject: =?iso-2022-jp?B?QSBzaW1wbGUgcGFnZQ==?=
+Date: Wed, May 11 2011 15:36:36 GMT-0700
+MIME-Version: 1.0
+Content-Type: multipart/related;
+ boundary="----=_NextPart_000_0000_87206557.D2C008B0";
+ type="text/html"
+
+------=_NextPart_000_0000_87206557.D2C008B0
+Content-Type: text/html; charset="ISO-8859-1"
+Content-Transfer-Encoding: quoted-printable
+Content-Location: http://localhost/simple_page.html
+
+<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
+=3Diso-8859-1">
+
+
+<title>A simple page</title>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+window._onload_ = function() {
+ var span=3Ddocument.createElement("span");
+ if (window.location !=3D 'http://localhost/simple_page.html' &&
+ document.domain !=3D 'localhost') {
+ span.innerHTML = "PASS";
+ } else {
+ span.innerHTML = "FAIL window.location=" + window.location +
+ " document.domain=" + document.domain;
+ }
+
+ document.getElementById('locDiv').appendChild(span);
+ layoutTestController.notifyDone();
+}
+
+</script>
+<base href=""
+<h1>This is a very simple page</h1>
+Very <b>basic</b> page.
+<div id=3D'locDiv'></div>
+</body></html>
+------=_NextPart_000_0000_87206557.D2C008B0--
Modified: branches/chromium/912/Source/WebCore/dom/Document.cpp (100576 => 100577)
--- branches/chromium/912/Source/WebCore/dom/Document.cpp 2011-11-17 08:42:18 UTC (rev 100576)
+++ branches/chromium/912/Source/WebCore/dom/Document.cpp 2011-11-17 08:48:29 UTC (rev 100577)
@@ -2377,12 +2377,16 @@
// DOM 3 Core: When the Document supports the feature "HTML" [DOM Level 2 HTML], the base URI is computed using
// first the value of the href attribute of the HTML BASE element if any, and the value of the documentURI attribute
// from the Document interface otherwise.
- if (m_baseElementURL.isEmpty()) {
+ if (!m_baseElementURL.isEmpty())
+ m_baseURL = m_baseElementURL;
+ else if (!m_baseURLOverride.isEmpty())
+ m_baseURL = m_baseURLOverride;
+ else {
// The documentURI attribute is an arbitrary string. DOM 3 Core does not specify how it should be resolved,
// so we use a null base URL.
m_baseURL = KURL(KURL(), documentURI());
- } else
- m_baseURL = m_baseElementURL;
+ }
+
if (!m_baseURL.isValid())
m_baseURL = KURL();
@@ -2392,6 +2396,12 @@
m_mappedElementSheet->setFinalURL(m_baseURL);
}
+void Document::setBaseURLOverride(const KURL& url)
+{
+ m_baseURLOverride = url;
+ updateBaseURL();
+}
+
void Document::processBaseElement()
{
// Find the first href attribute in a base element and the first target attribute in a base element.
Modified: branches/chromium/912/Source/WebCore/dom/Document.h (100576 => 100577)
--- branches/chromium/912/Source/WebCore/dom/Document.h 2011-11-17 08:42:18 UTC (rev 100576)
+++ branches/chromium/912/Source/WebCore/dom/Document.h 2011-11-17 08:48:29 UTC (rev 100577)
@@ -605,6 +605,8 @@
void setURL(const KURL&);
const KURL& baseURL() const { return m_baseURL; }
+ void setBaseURLOverride(const KURL&);
+ const KURL& baseURLOverride() const { return m_baseURLOverride; }
const String& baseTarget() const { return m_baseTarget; }
void processBaseElement();
@@ -1174,6 +1176,7 @@
// Document URLs.
KURL m_url; // Document.URL: The URL from which this document was retrieved.
KURL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs.
+ KURL m_baseURLOverride; // An alternative base URL that takes precedence ove m_baseURL (but not m_baseElementURL).
KURL m_baseElementURL; // The URL set by the <base> element.
KURL m_cookieURL; // The URL to use for cookie access.
KURL m_firstPartyForCookies; // The policy URL for third-party cookie blocking.
Modified: branches/chromium/912/Source/WebCore/loader/FrameLoader.cpp (100576 => 100577)
--- branches/chromium/912/Source/WebCore/loader/FrameLoader.cpp 2011-11-17 08:42:18 UTC (rev 100576)
+++ branches/chromium/912/Source/WebCore/loader/FrameLoader.cpp 2011-11-17 08:48:29 UTC (rev 100577)
@@ -568,7 +568,7 @@
void FrameLoader::receivedFirstData()
{
KURL workingURL = activeDocumentLoader()->documentURL();
-#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
+#if ENABLE(WEB_ARCHIVE)
// FIXME: The document loader, not the frame loader, should be in charge of loading web archives.
// Once this is done, we can just make DocumentLoader::documentURL() return the right URL
// based on whether it has a non-null archive or not.
@@ -581,7 +581,15 @@
dispatchDidCommitLoad();
dispatchDidClearWindowObjectsInAllWorlds();
-
+
+#if ENABLE(MHTML)
+ if (m_archive) {
+ // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so
+ // relative URLs are resolved properly.
+ m_frame->document()->setBaseURLOverride(m_archive->mainResource()->url());
+ }
+#endif
+
if (m_documentLoader) {
StringWithDirection ptitle = m_documentLoader->title();
// If we have a title let the WebView know about it.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes