commit | 474923949524b5c05a9e6f28ec082fdca87078de | [log] [tgz] |
---|---|---|
author | Steve Becker <stevebe@microsoft.com> | Fri Oct 25 09:15:00 2019 |
committer | Blink WPT Bot <blink-w3c-test-autoroller@chromium.org> | Fri Oct 25 09:47:39 2019 |
tree | 5a7f88606755a8df0856463755b6e18e8dbe3414 | |
parent | 52aeca2db20bd3304407bf1a1fca4e5a827db243 [diff] |
[NativeFileSystem] Make FileSystemHandle cloneable Updates postMessage() to clone FileSystemFileHandle and FileSystemDirectoryHandle objects for same origin targets. Including a FileSystemHandle object with a cross origin message fails by dispatching a 'messageerror' event instead of 'message' event. The change consists of four parts: (1) Updates V8ScriptValueSerializerForModules to serialize FileSystemFileHandle and FileSystemDirectoryHandle into blink::SerializedScriptValue, by following these steps: * Write a tag for the handle type (file or directory). * Write the name of the file or directory. * Creates a mojom::blink::NativeFileSystemTransferTokenPtr by calling blink:NativeFileSystemHandle::Transfer(). This token informs the storage::NativeFileSystemManagerImpl that a transfer is in progress. The NativeFileSystemManagerImpl creates a NativeFileSystemTransferTokenImpl to store the information required to clone the handle. * Stores the token in blink::SerializedScriptValue::native_file_system_tokens_. This array tracks all cloned FileSystemFileHandle. The blink::mojom::CloneableMessage struct is also updated to hold this array for MessagePort and BroadcastChannels. * Write the index of the token in the native_file_system_tokens_ array. (2) Updates V8ScriptValueDeserializerForModules to deserialize FileSystemFileHandle objects when creating clones for the message targets. This is the inverse of (1). Deserializing uses mojom::blink::NativeFileSystemManager to redeem the token, which creates the mojom::blink::NativeFileSystemFileHandlePtr or mojom::blink::NativeFileSystemDirectoryHandlePtr using the info stored by NativeFileSystemTransferTokenImpl. (3) Updates content::NativeFileSystemManagerImpl to support token transfers. To redeem a token, NativeFileSystemManagerImpl receives a mojo message that includes the token as well as a request for a handle interface like mojom::blink::NativeFileSystemFileHandlePtr. NativeFileSystemManagerImpl finds the token and then binds the request. Token redemption does not return any results. Token redemption should never fail, unless a render process is misbehaving. NativeFileSystemManagerImpl performs a few sanity checks before binding the mojo request, including a token existence check, a handle type check and an origin check. If any of the sanity checks fail, NativeFileSystemManagerImpl silently fails closing the redeemed FileHandle's pipe. (4) Adds a cross origin check to window and message port messaging. Most message targets, like dedicated workers, are same origin only. However, both windows and message port messages can go cross origin. When a cross origin message includes a FileSystemHandle, the message must fail with a 'messageerror' event to prevent cross origin access to the FileSystemHandle. Messaging between windows already included origin information before this change. This change adds a NativeFileSystem origin check before dispatching a message event to a window. The message event is replaced with a message error when a cross origin NativeFileSystem object exists in the message data. For message ports, no sender origin information existed before this change. This change updates the CloneableMessage structs to include a 'sender_origin' url::Origin property. Message ports use this property to perform the same cross origin NativeFileSystem check as the window. The NativeFileSystemManagerImpl performs an additional origin check before binding the FileSystemHandle mojo request. The NativeFileSystemManagerImpl cannot trust the postMessage() origin check performed in the render process. Bug: 955192 Change-Id: Ieeb76bd8102067d70c5d7719622ecd4930c3a88f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1791942 Commit-Queue: Steve Becker <stevebe@microsoft.com> Reviewed-by: Jeremy Roman <jbroman@chromium.org> Reviewed-by: Yuki Shiino <yukishiino@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Marijn Kruisselbrink <mek@chromium.org> Reviewed-by: Olivier Yiptong <oyiptong@chromium.org> Cr-Commit-Position: refs/heads/master@{#709407}
The web-platform-tests Project is a W3C-coordinated attempt to build a cross-browser test suite for the Web-platform stack. Writing tests in a way that allows them to be run in all browsers gives browser projects confidence that they are shipping software that is compatible with other implementations, and that later implementations will be compatible with their implementations. This in turn gives Web authors/developers confidence that they can actually rely on the Web platform to deliver on the promise of working across browsers and devices without needing extra layers of abstraction to paper over the gaps left by specification editors and implementors.
The most important sources of information and activity are:
#testing
on irc.w3.org; includes participants located around the world, but busiest during the European working day; all discussion is archived hereIf you'd like clarification about anything, don't hesitate to ask in the chat room or on the mailing list.
Clone or otherwise get https://github.com/web-platform-tests/wpt.
Note: because of the frequent creation and deletion of branches in this repo, it is recommended to “prune” stale branches when fetching updates, i.e. use git pull --prune
(or git fetch -p && git merge
).
The tests are designed to be run from your local computer. The test environment requires Python 2.7+ (but not Python 3.x).
On Windows, be sure to add the Python directory (c:\python2x
, by default) to your %Path%
Environment Variable, and read the Windows Notes section below.
To get the tests running, you need to set up the test domains in your hosts
file.
The necessary content can be generated with ./wpt make-hosts-file
; on Windows, you will need to precede the prior command with python
or the path to the Python binary (python wpt make-hosts-file
).
For example, on most UNIX-like systems, you can setup the hosts file with:
./wpt make-hosts-file | sudo tee -a /etc/hosts
And on Windows (this must be run in a PowerShell session with Administrator privileges):
python wpt make-hosts-file | Out-File $env:systemroot\System32\drivers\etc\hosts -Encoding ascii -Append
If you are behind a proxy, you also need to make sure the domains above are excluded from your proxy lookups.
The test server can be started using
./wpt serve
On Windows: You will need to precede the prior command with python
or the path to the python binary.
python wpt serve
This will start HTTP servers on two ports and a websockets server on one port. By default the web servers start on ports 8000 and 8443 and the other ports are randomly-chosen free ports. Tests must be loaded from the first HTTP server in the output. To change the ports, create a config.json
file in the wpt root directory, and add port definitions of your choice e.g.:
{ "ports": { "http": [1234, "auto"], "https":[5678] } }
After your hosts
file is configured, the servers will be locally accessible at:
http://web-platform.test:8000/
https://web-platform.test:8443/ *
To use the web-based runner point your browser to:
http://web-platform.test:8000/tools/runner/index.html
https://web-platform.test:8443/tools/runner/index.html *
*See Trusting Root CA
Tests can be run automatically in a browser using the run
command of the wpt
script in the root of the checkout. This requires the hosts file setup documented above, but you must not have the test server already running when calling wpt run
. The basic command line syntax is:
./wpt run product [tests]
On Windows: You will need to precede the prior command with python
or the path to the python binary.
python wpt run product [tests]
where product
is currently firefox
or chrome
and [tests]
is a list of paths to tests. This will attempt to automatically locate a browser instance and install required dependencies. The command is very configurable; for example to specify a particular binary use wpt run --binary=path product
. The full range of options can be see with wpt run --help
and wpt run --wptrunner-help
.
Not all dependencies can be automatically installed; in particular the certutil
tool required to run https tests with Firefox must be installed using a system package manager or similar.
On Debian/Ubuntu certutil may be installed using:
sudo apt install libnss3-tools
And on macOS with homebrew using:
brew install nss
On other platforms, download the firefox archive and common.tests.tar.gz archive for your platform from Mozilla CI.
Then extract certutil[.exe]
from the tests.tar.gz package and libnss3[.so|.dll|.dynlib]
and put the former on your path and the latter on your library path.
The wpt
command provides a frontend to a variety of tools for working with and running web-platform-tests. Some of the most useful commands are:
wpt serve
- For starting the wpt http serverwpt run
- For running tests in a browserwpt lint
- For running the lint against all testswpt manifest
- For updating or generating a MANIFEST.json
test manifestwpt install
- For installing the latest release of a browser or webdriver server on the local machine.On Windows wpt
commands must be prefixed with python
or the path to the python binary (if python
is not in your %PATH%
).
python wpt [command]
Alternatively, you may also use Bash on Ubuntu on Windows in the Windows 10 Anniversary Update build, then access your windows partition from there to launch wpt
commands.
Please make sure git and your text editor do not automatically convert line endings, as it will cause lint errors. For git, please set git config core.autocrlf false
in your working tree.
The master branch is automatically synced to http://w3c-test.org/.
Pull requests are automatically mirrored except those that modify sensitive resources (such as .py
). The latter require someone with merge access to comment with “LGTM” or “w3c-test:mirror” to indicate the pull request has been checked.
In the vast majority of cases the only upstream branch that you should need to care about is master
. If you see other branches in the repository, you can generally safely ignore them.
Save the Web, Write Some Tests!
Absolutely everyone is welcome (and even encouraged) to contribute to test development, so long as you fulfill the contribution requirements detailed in the [Contributing Guidelines][contributing]. No test is too small or too simple, especially if it corresponds to something for which you've noted an interoperability bug in a browser.
The way to contribute is just as usual:
git checkout -b topic
.If you spot an issue with a test and are not comfortable providing a pull request per above to fix it, please file a new issue. Thank you!