Commit 3b8fac5c authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

2011-02-11 Adam Klein <adamk@chromium.org>

        Reviewed by Darin Fisher.

        [fileapi] Add support for filesystem: URI handling
        https://bugs.webkit.org/show_bug.cgi?id=53529

        Tests for filesystem: URIs, testing both their security origin
        properties and the existence of the Entry.toURI method.

        * fast/filesystem/directory-entry-to-uri-expected.txt: Added.
        * fast/filesystem/directory-entry-to-uri.html: Added.
        * fast/filesystem/file-entry-to-uri-expected.txt: Added.
        * fast/filesystem/file-entry-to-uri.html: Added.
        * fast/filesystem/filesystem-uri-origin-expected.txt: Added.
        * fast/filesystem/filesystem-uri-origin.html: Added.
        * fast/filesystem/resources/directory-entry-to-uri.js: Added.
        (errorCallback):
        (entryToURI):
        (createTestDirectory):
        ():
        * fast/filesystem/resources/file-entry-to-uri.js: Added.
        (errorCallback):
        (entryToURI):
        (createTestFile):
        ():
        * http/tests/security/filesystem-iframe-from-remote-expected.txt: Added.
        * http/tests/security/filesystem-iframe-from-remote.html: Added.
        * http/tests/security/resources/create-filesystem-file.html: Added.
2011-02-11  Adam Klein  <adamk@chromium.org>

        Reviewed by Darin Fisher.

        [fileapi] Add support for filesystem: URI handling
        https://bugs.webkit.org/show_bug.cgi?id=53529

        There are two major parts to this patch: one is to add an
        implementation of Entry.toURI to the FileSystem API.
        The other is to implement security origin checking for this
        new scheme.

        All changes are guarded by the FILE_SYSTEM feature. An accompanying
        Chromium change, to support loading of filesystem: URIs, has recently
        been submitted as Chromium r74082.

        Spec:
          http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#methods-2
        Proposed URI format, and discussion of security origin issues:
          http://lists.w3.org/Archives/Public/public-webapps/2011JanMar/0218.html

        Tests: fast/filesystem/directory-entry-to-uri.html
               fast/filesystem/file-entry-to-uri.html
               fast/filesystem/filesystem-uri-origin.html
               http/tests/security/filesystem-iframe-from-remote.html

        * fileapi/Entry.cpp:
        (WebCore::Entry::toURI):
        * fileapi/Entry.h:
        * fileapi/Entry.idl:
        - Added toURI method to the IDL, omitting the MIME type argument
          specified in the spec as it will soon be removed.
        * page/SecurityOrigin.cpp:
        (WebCore::SecurityOrigin::SecurityOrigin):
        - crack the filesystem: URI to get at the origin of the site
        (WebCore::SecurityOrigin::canDisplay):
        - canDisplay for filesystem: URIs is equivalent to canRequest
        * platform/AsyncFileSystem.cpp:
        (WebCore::AsyncFileSystem::create):
        (WebCore::AsyncFileSystem::openFileSystem):
        * platform/AsyncFileSystem.h:
        (WebCore::AsyncFileSystem::type):
        - Exposed filesystem type to allow toURI to use it as part of the
          path.
        (WebCore::AsyncFileSystem::AsyncFileSystem):
        * platform/SchemeRegistry.cpp:
        (WebCore::canDisplayOnlyIfCanRequestSchemes):
        (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest):
        (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest):
        - Generalized canDisplayOnlyIfCanRequest as it applies to both
          filesystem: and blob: URIs.
        * platform/SchemeRegistry.h:
2011-02-11  Adam Klein  <adamk@chromium.org>

        Reviewed by Darin Fisher.

        [fileapi] Add support for filesystem: URI handling
        https://bugs.webkit.org/show_bug.cgi?id=53529

        Changes to Chromium WebKit API required to expose
        the FileSystem type to WebCore's fileapi code, since the
        type is part of the filesystem URI.

        * src/AsyncFileSystemChromium.cpp:
        (WebCore::AsyncFileSystemChromium::AsyncFileSystemChromium):
        * src/AsyncFileSystemChromium.h:
        (WebCore::AsyncFileSystemChromium::create):
        * src/LocalFileSystemChromium.cpp:
        (WebCore::LocalFileSystem::readFileSystem):
        (WebCore::LocalFileSystem::requestFileSystem):
        * src/WebFileSystemCallbacksImpl.cpp:
        (WebKit::WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl):
        (WebKit::WebFileSystemCallbacksImpl::didOpenFileSystem):
        * src/WebFileSystemCallbacksImpl.h:
        * src/WorkerAsyncFileSystemChromium.cpp:
        (WebCore::WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium):
        * src/WorkerAsyncFileSystemChromium.h:
        (WebCore::WorkerAsyncFileSystemChromium::create):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@78362 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 015da4ba
2011-02-11 Adam Klein <adamk@chromium.org>
Reviewed by Darin Fisher.
[fileapi] Add support for filesystem: URI handling
https://bugs.webkit.org/show_bug.cgi?id=53529
Tests for filesystem: URIs, testing both their security origin
properties and the existence of the Entry.toURI method.
* fast/filesystem/directory-entry-to-uri-expected.txt: Added.
* fast/filesystem/directory-entry-to-uri.html: Added.
* fast/filesystem/file-entry-to-uri-expected.txt: Added.
* fast/filesystem/file-entry-to-uri.html: Added.
* fast/filesystem/filesystem-uri-origin-expected.txt: Added.
* fast/filesystem/filesystem-uri-origin.html: Added.
* fast/filesystem/resources/directory-entry-to-uri.js: Added.
(errorCallback):
(entryToURI):
(createTestDirectory):
():
* fast/filesystem/resources/file-entry-to-uri.js: Added.
(errorCallback):
(entryToURI):
(createTestFile):
():
* http/tests/security/filesystem-iframe-from-remote-expected.txt: Added.
* http/tests/security/filesystem-iframe-from-remote.html: Added.
* http/tests/security/resources/create-filesystem-file.html: Added.
2011-02-11 Sailesh Agrawal <sail@chromium.org>
 
Reviewed by Kenneth Russell.
Obtaining URI from DirectoryEntry.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS testDirectoryURI is 'filesystem:file:///temporary/testDirectory'
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<link rel="stylesheet" href="../js/resources/js-test-style.css">
<script src="../js/resources/js-test-pre.js"></script>
<script src="resources/fs-test-util.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="resources/directory-entry-to-uri.js"></script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
Obtaining URI from FileEntry.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS testFileURI is 'filesystem:file:///temporary/testFileEntry.txt'
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<link rel="stylesheet" href="../js/resources/js-test-style.css">
<script src="../js/resources/js-test-pre.js"></script>
<script src="resources/fs-test-util.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="resources/file-entry-to-uri.js"></script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
PASSED: origin was http://www.webkit.org:8080
<a style="display:none" href="filesystem:http://www.webkit.org:8080/temporary/a/b/c/file.txt">foo</a>
<p>This text should not be visible. It should be overwritten by the running of the test.</p>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
var expectedOrigin = 'http://www.webkit.org:8080';
var actualOrigin = document.getElementsByTagName('a')[0].origin;
var resultElt = document.getElementsByTagName('p')[0];
if (actualOrigin == expectedOrigin)
resultElt.innerText = 'PASSED: origin was ' + expectedOrigin;
else
resultElt.innerText = 'FAILED: expected origin: ' + expectedOrigin + ' but got: ' + actualOrigin;
</script>
if (this.importScripts) {
importScripts('fs-worker-common.js');
importScripts('fs-test-util.js');
}
description("Obtaining URI from DirectoryEntry.");
var fileSystem = null;
var testDirectoryName = 'testDirectory';
var testDirectoryURI = null;
function errorCallback(error) {
testFailed("Error occured:" + error.code);
finishJSTest();
}
function entryToURI(entry) {
testDirectoryURI = entry.toURI();
shouldBe("testDirectoryURI", "'filesystem:file:///temporary/testDirectory'");
finishJSTest();
}
function createTestDirectory() {
fileSystem.root.getDirectory(testDirectoryName, {create:true}, entryToURI, errorCallback);
}
function fileSystemCallback(fs) {
fileSystem = fs;
removeAllInDirectory(fileSystem.root, createTestDirectory, errorCallback);
}
var jsTestIsAsync = true;
requestFileSystem(TEMPORARY, 100, fileSystemCallback, errorCallback);
var successfullyParsed = true;
if (this.importScripts) {
importScripts('fs-worker-common.js');
importScripts('fs-test-util.js');
}
description("Obtaining URI from FileEntry.");
var fileSystem = null;
var testFileName = 'testFileEntry.txt';
var testFileURI = null;
function errorCallback(error) {
testFailed("Error occured:" + error.code);
finishJSTest();
}
function entryToURI(entry) {
testFileURI = entry.toURI();
shouldBe("testFileURI", "'filesystem:file:///temporary/testFileEntry.txt'");
finishJSTest();
}
function createTestFile() {
fileSystem.root.getFile(testFileName, {create:true}, entryToURI, errorCallback);
}
function fileSystemCallback(fs) {
fileSystem = fs;
removeAllInDirectory(fileSystem.root, createTestFile, errorCallback);
}
var jsTestIsAsync = true;
requestFileSystem(TEMPORARY, 100, fileSystemCallback, errorCallback);
var successfullyParsed = true;
CONSOLE MESSAGE: line 0: Not allowed to load local resource: filesystem:http://localhost:8000/temporary/page.html
This test is to see if a remote file can include a local page via a filesystem: URI in an iFrame.
Test Passed. Local page not remotely loaded into iFrame.
<html> <head>
<script>
function done() {
var pageLocation = "filesystem:http://localhost:8000/temporary/page.html";
var localIframeElement = document.createElement("iframe");
localIframeElement.setAttribute("id", "myFrame");
localIframeElement.setAttribute("src", pageLocation);
document.body.appendChild(localIframeElement);
var result = document.getElementById("result");
var myFrameDocument = document.getElementById("myFrame").contentDocument;
if (myFrameDocument)
result.innerHTML = "Test Failed: Local page remotely loaded into iFrame.";
else
result.innerHTML = "Test Passed. Local page not remotely loaded into iFrame.";
if (window.layoutTestController)
layoutTestController.notifyDone();
}
function runTest() {
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
// Need to wait for the iframe to do its async work.
setTimeout(done, 1000);
}
</script>
</head>
<body>
<div id="div0">
This test is to see if a remote file can include a local page via a filesystem: URI in an iFrame.
</div>
<br>
<div id="result">
Test not run correctly.
</div>
<iframe src="http://localhost:8000/security/resources/create-filesystem-file.html" onload="runTest()"></iframe>
</body>
</html>
<html>
<head>
<script>
function createFile() {
requestFileSystem(TEMPORARY, 100, function(fs) {
fs.root.getFile("page.html", {create:true}, function(entry) {
entry.createWriter(function(writer) {
var bb = new BlobBuilder();
bb.append('<div id="innerDiv">Visible Contents</div>\n');
writer.write(bb.getBlob());
})
})
});
}
if (window.requestFileSystem)
createFile();
</script>
</head>
</html>
......@@ -2480,6 +2480,7 @@ fast/parser/pre-html5-parser-quirks.html
# FileSystem API is not supported.
fast/filesystem
http/tests/local/fileapi
http/tests/security/filesystem-iframe-from-remote.html
# Needs more investigation like QT
fast/dom/nodesFromRect-links-and-text.html
......
......@@ -257,6 +257,7 @@ http/tests/media/video-buffered.html
# FileSystem API is not supported.
fast/filesystem
http/tests/security/filesystem-iframe-from-remote.html
# https://bugs.webkit.org/show_bug.cgi?id=46223
# The WebKit plugin implementation does not support iframe shims.
......
......@@ -4910,6 +4910,7 @@ fast/parser/pre-html5-parser-quirks.html
# FileSystem API is not supported.
fast/filesystem
http/tests/security/filesystem-iframe-from-remote.html
# It fails, because 3D canvas is disabled by default.
http/tests/canvas/webgl/origin-clean-conformance.html
......
......@@ -1091,6 +1091,7 @@ fast/parser/pre-html5-parser-quirks.html
# FileSystem API is not supported.
fast/filesystem
http/tests/security/filesystem-iframe-from-remote.html
# LayoutTestController::nodesFromRect is not supported.
fast/dom/nodesFromRect-basic.html
......
2011-02-11 Adam Klein <adamk@chromium.org>
Reviewed by Darin Fisher.
[fileapi] Add support for filesystem: URI handling
https://bugs.webkit.org/show_bug.cgi?id=53529
There are two major parts to this patch: one is to add an
implementation of Entry.toURI to the FileSystem API.
The other is to implement security origin checking for this
new scheme.
All changes are guarded by the FILE_SYSTEM feature. An accompanying
Chromium change, to support loading of filesystem: URIs, has recently
been submitted as Chromium r74082.
Spec:
http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#methods-2
Proposed URI format, and discussion of security origin issues:
http://lists.w3.org/Archives/Public/public-webapps/2011JanMar/0218.html
Tests: fast/filesystem/directory-entry-to-uri.html
fast/filesystem/file-entry-to-uri.html
fast/filesystem/filesystem-uri-origin.html
http/tests/security/filesystem-iframe-from-remote.html
* fileapi/Entry.cpp:
(WebCore::Entry::toURI):
* fileapi/Entry.h:
* fileapi/Entry.idl:
- Added toURI method to the IDL, omitting the MIME type argument
specified in the spec as it will soon be removed.
* page/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::SecurityOrigin):
- crack the filesystem: URI to get at the origin of the site
(WebCore::SecurityOrigin::canDisplay):
- canDisplay for filesystem: URIs is equivalent to canRequest
* platform/AsyncFileSystem.cpp:
(WebCore::AsyncFileSystem::create):
(WebCore::AsyncFileSystem::openFileSystem):
* platform/AsyncFileSystem.h:
(WebCore::AsyncFileSystem::type):
- Exposed filesystem type to allow toURI to use it as part of the
path.
(WebCore::AsyncFileSystem::AsyncFileSystem):
* platform/SchemeRegistry.cpp:
(WebCore::canDisplayOnlyIfCanRequestSchemes):
(WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest):
(WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest):
- Generalized canDisplayOnlyIfCanRequest as it applies to both
filesystem: and blob: URIs.
* platform/SchemeRegistry.h:
2011-02-11 Beth Dakin <bdakin@apple.com>
 
Reviewed by Darin Adler.
......@@ -32,13 +32,17 @@
#if ENABLE(FILE_SYSTEM)
#include "AsyncFileSystem.h"
#include "DirectoryEntry.h"
#include "EntryCallback.h"
#include "ErrorCallback.h"
#include "FileError.h"
#include "FileSystemCallbacks.h"
#include "MetadataCallback.h"
#include "ScriptExecutionContext.h"
#include "SecurityOrigin.h"
#include "VoidCallback.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
......@@ -82,11 +86,15 @@ void Entry::getParent(PassRefPtr<EntryCallback> successCallback, PassRefPtr<Erro
filesystem()->scheduleCallback(errorCallback.release(), FileError::create(FileError::INVALID_MODIFICATION_ERR));
}
String Entry::toURI(const String&)
String Entry::toURI()
{
// FIXME: to be implemented.
ASSERT_NOT_REACHED();
return String();
StringBuilder uriBuilder;
uriBuilder.append("filesystem:");
uriBuilder.append(filesystem()->scriptExecutionContext()->securityOrigin()->toString());
uriBuilder.append("/");
uriBuilder.append(m_fileSystem->asyncFileSystem()->type() == AsyncFileSystem::Temporary ? "temporary" : "persistent");
uriBuilder.append(m_fullPath);
return uriBuilder.toString();
}
} // namespace WebCore
......
......@@ -57,7 +57,7 @@ public:
void remove(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
void getParent(PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
String toURI(const String& mimeType = String());
String toURI();
protected:
Entry(PassRefPtr<DOMFileSystemBase>, const String& fullPath);
......
......@@ -43,6 +43,7 @@ module storage {
void getMetadata(in [Optional, Callback] MetadataCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
void moveTo(in DirectoryEntry parent, in [Optional, ConvertUndefinedOrNullToNullString] DOMString name, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
void copyTo(in DirectoryEntry parent, in [Optional, ConvertUndefinedOrNullToNullString] DOMString name, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
DOMString toURI();
void remove(in [Optional, Callback] VoidCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
void getParent(in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment