LayoutTests:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Feb 2007 03:51:00 +0000 (03:51 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Feb 2007 03:51:00 +0000 (03:51 +0000)
        Reviewed by Maciej.

        <rdar://problem/4886776>
        REGRESSION: After opening a web archive, location shows the actual URL, not the webarchive file

        * webarchive/loading/resources/helloworld.webarchive: Added.
        * webarchive/loading/test-loading-archive-expected.txt: Added.
        * webarchive/loading/test-loading-archive.html: Added.

WebCore:

        Reviewed by Maciej.

        <rdar://problem/4886776>
        REGRESSION: After opening a web archive, location shows the actual URL, not the webarchive file

        * WebCore.exp:
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::continueLoadWithData):
        * loader/FrameLoader.h:
        New function which continues a load but using a given buffer instead.

WebKit:

        Reviewed by Maciej.

        <rdar://problem/4886776>
        REGRESSION: After opening a web archive, location shows the actual URL, not the webarchive file

        "Revert" the change done in 13734.

        * WebView/WebHTMLRepresentation.mm:
        (-[WebHTMLRepresentation loadArchive]):
        Don't do a new load here, as this would cancel the current load and call the resource load
        delegate's didFailLoadingWithError: method. Instead, call continueLoadWithData.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@19322 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webarchive/loading/resources/helloworld.webarchive [new file with mode: 0644]
LayoutTests/webarchive/loading/test-loading-archive-expected.txt [new file with mode: 0644]
LayoutTests/webarchive/loading/test-loading-archive.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/loader/FrameLoader.cpp
WebCore/loader/FrameLoader.h
WebKit/ChangeLog
WebKit/WebView/WebHTMLRepresentation.mm

index 587fe60..d9c34fe 100644 (file)
@@ -1,3 +1,14 @@
+2007-01-31  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej.
+
+        <rdar://problem/4886776>
+        REGRESSION: After opening a web archive, location shows the actual URL, not the webarchive file
+
+        * webarchive/loading/resources/helloworld.webarchive: Added.
+        * webarchive/loading/test-loading-archive-expected.txt: Added.
+        * webarchive/loading/test-loading-archive.html: Added.
+
 2007-01-31  Adele Peterson  <adele@apple.com>
 
         Reviewed by Darin.
diff --git a/LayoutTests/webarchive/loading/resources/helloworld.webarchive b/LayoutTests/webarchive/loading/resources/helloworld.webarchive
new file mode 100644 (file)
index 0000000..5099b1a
Binary files /dev/null and b/LayoutTests/webarchive/loading/resources/helloworld.webarchive differ
diff --git a/LayoutTests/webarchive/loading/test-loading-archive-expected.txt b/LayoutTests/webarchive/loading/test-loading-archive-expected.txt
new file mode 100644 (file)
index 0000000..16dd5b5
--- /dev/null
@@ -0,0 +1,4 @@
+resources/helloworld.webarchive - willSendRequest <NSURLRequest resources/helloworld.webarchive> redirectResponse (null)
+<unknown> - didFinishLoading
+resources/helloworld.webarchive - didReceiveResponse <NSURLResponse resources/helloworld.webarchive>
+ This tests that doing a "normal load" of a webarchive (not using loadArchive) does not cause a cancelled error to be called.
diff --git a/LayoutTests/webarchive/loading/test-loading-archive.html b/LayoutTests/webarchive/loading/test-loading-archive.html
new file mode 100644 (file)
index 0000000..897ff13
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.dumpResourceLoadCallbacks();
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+    
+    function frameLoaded() {
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+</script>
+<body>
+    <iframe onload="frameLoaded();" src="resources/helloworld.webarchive"></iframe>
+    This tests that doing a "normal load" of a webarchive (not using loadArchive) does not cause a cancelled error to be called.
+</body>
+</html>
index c22df0a..3a180d7 100644 (file)
@@ -1,3 +1,16 @@
+2007-01-31  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej.
+
+        <rdar://problem/4886776>
+        REGRESSION: After opening a web archive, location shows the actual URL, not the webarchive file
+
+        * WebCore.exp:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::continueLoadWithData):
+        * loader/FrameLoader.h:
+        New function which continues a load but using a given buffer instead.
+        
 2007-01-31  Adele Peterson  <adele@apple.com>
 
         Reviewed by Adam.
index 6a4a23d..b6da31c 100644 (file)
@@ -138,6 +138,7 @@ __ZN7WebCore11FrameLoader14scrollToAnchorERKNS_4KURLE
 __ZN7WebCore11FrameLoader14stopAllLoadersEv
 __ZN7WebCore11FrameLoader16detachFromParentEv
 __ZN7WebCore11FrameLoader18currentHistoryItemEv
+__ZN7WebCore11FrameLoader20continueLoadWithDataEPNS_12SharedBufferERKNS_6StringES5_RKNS_4KURLE
 __ZN7WebCore11FrameLoader21addPlugInStreamLoaderEPNS_14ResourceLoaderE
 __ZN7WebCore11FrameLoader21setCurrentHistoryItemEN3WTF10PassRefPtrINS_11HistoryItemEEE
 __ZN7WebCore11FrameLoader22cancelMainResourceLoadERKNS_13ResourceErrorE
index 930c8b3..c400721 100644 (file)
@@ -4278,4 +4278,23 @@ void FrameLoader::didChangeTitle(DocumentLoader* loader)
     }
 }
 
+void FrameLoader::continueLoadWithData(SharedBuffer* buffer, const String& mimeType, const String& textEncoding, const KURL& url)
+{
+    m_responseMIMEType = mimeType;
+    didOpenURL(url);
+
+    String encoding;
+    if (m_frame)
+        encoding = documentLoader()->overrideEncoding();
+    bool userChosen = !encoding.isNull();
+    if (encoding.isNull())
+        encoding = textEncoding;
+    setEncoding(encoding, userChosen);
+
+    if (!m_frame->document())
+        return;
+
+    addData(buffer->data(), buffer->size());
+}
+
 } // namespace WebCore
index 5f6da6a..f4fc11b 100644 (file)
@@ -420,6 +420,7 @@ namespace WebCore {
         void setPreviousHistoryItem(PassRefPtr<HistoryItem>);
         void setProvisionalHistoryItem(PassRefPtr<HistoryItem>);
         
+        void continueLoadWithData(SharedBuffer*, const String& mimeType, const String& textEncoding, const KURL&); 
     private:        
         PassRefPtr<HistoryItem> createHistoryItem(bool useOriginal);
         PassRefPtr<HistoryItem> createHistoryItemTree(Frame* targetFrame, bool clipAtTarget);
index 1e4fbeb..ad72c72 100644 (file)
@@ -1,3 +1,17 @@
+2007-01-31  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej.
+
+        <rdar://problem/4886776>
+        REGRESSION: After opening a web archive, location shows the actual URL, not the webarchive file
+        
+        "Revert" the change done in 13734.
+        
+        * WebView/WebHTMLRepresentation.mm:
+        (-[WebHTMLRepresentation loadArchive]):
+        Don't do a new load here, as this would cancel the current load and call the resource load
+        delegate's didFailLoadingWithError: method. Instead, call continueLoadWithData.
+
 2007-02-01  Nikolas Zimmermann  <zimmermann@kde.org>
 
         Reviewed by Maciej.
index c907644..da1f651 100644 (file)
@@ -46,6 +46,7 @@
 #import <JavaScriptCore/Assertions.h>
 #import <WebCore/Document.h>
 #import <WebCore/DocumentLoader.h>
+#import <WebCore/FrameLoader.h>
 #import <WebCore/FrameMac.h>
 #import <WebCore/MimeTypeRegistry.h>
 #import <WebCore/Range.h>
@@ -189,10 +190,29 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
     }
 }
 
-- (void)loadArchive
+- (void)_loadDataSourceAsWebArchive
 {
     WebArchive *archive = [[WebArchive alloc] initWithData:[_private->dataSource data]];
-    [[_private->dataSource webFrame] loadArchive:archive];
+    WebResource *mainResource = [archive mainResource];
+    if (!mainResource) {
+        [archive release];
+        return;
+    }
+    
+    NSData *data = [mainResource data];
+    [data retain];
+    [_private->parsedArchiveData release];
+    _private->parsedArchiveData = data;
+    
+    [_private->dataSource _addToUnarchiveState:archive];
+    [archive release];
+    
+    WebFrame *webFrame = [_private->dataSource webFrame];
+    
+    if (!webFrame)
+        return;
+    
+    core(webFrame)->loader()->continueLoadWithData(SharedBuffer::wrapNSData(data).get(), [mainResource MIMEType], [mainResource textEncodingName], [mainResource URL]);
 }
 
 - (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
@@ -206,7 +226,7 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
 
     if (frame) {
         if ([self _isDisplayingWebArchive])
-            [self loadArchive];
+            [self _loadDataSourceAsWebArchive];
         else
             // Telling the bridge we received some data and passing nil as the data is our
             // way to get work done that is normally done when the first bit of data is
@@ -231,6 +251,9 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
 
 - (NSString *)documentSource
 {
+    if ([self _isDisplayingWebArchive])
+        return [[[NSString alloc] initWithData:_private->parsedArchiveData encoding:NSUTF8StringEncoding] autorelease]; 
+
     return [_private->bridge stringWithData:[_private->dataSource data]];
 }