mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 02:35:41 +00:00
9747761479
<!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin Source-Repo: https://github.com/servo/servo Source-Revision: 22aebdf5d41a3509cd6515ccf5edcdf33715a76d
45 lines
2.3 KiB
Rust
45 lines
2.3 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
use net::test::resolve_chrome_url;
|
|
use servo_url::ServoUrl;
|
|
|
|
fn c(s: &str) -> Result<ServoUrl, ()> {
|
|
resolve_chrome_url(&ServoUrl::parse(s).unwrap())
|
|
}
|
|
|
|
#[test]
|
|
fn test_resolve_chrome_url() {
|
|
assert_eq!(c("chrome://resources/nonexistent.jpg"), Err(()));
|
|
assert_eq!(c("chrome://not-resources/badcert.jpg"), Err(()));
|
|
assert_eq!(c("chrome://resources/badcert.jpg").unwrap().scheme(), "file");
|
|
assert_eq!(c("chrome://resources/subdir/../badcert.jpg").unwrap().scheme(), "file");
|
|
assert_eq!(c("chrome://resources/subdir/../../badcert.jpg").unwrap().scheme(), "file");
|
|
assert_eq!(c("chrome://resources/../badcert.jpg").unwrap().scheme(), "file");
|
|
assert_eq!(c("chrome://resources/../README.md"), Err(()));
|
|
assert_eq!(c("chrome://resources/%2e%2e/README.md"), Err(()));
|
|
|
|
assert_eq!(c("chrome://resources/etc/passwd"), Err(()));
|
|
assert_eq!(c("chrome://resources//etc/passwd"), Err(()));
|
|
assert_eq!(c("chrome://resources/%2Fetc%2Fpasswd"), Err(()));
|
|
|
|
assert_eq!(c("chrome://resources/C:/Windows/notepad.exe"), Err(()));
|
|
assert_eq!(c("chrome://resources/C:\\Windows\\notepad.exe"), Err(()));
|
|
|
|
assert_eq!(c("chrome://resources/localhost/C:/Windows/notepad.exe"), Err(()));
|
|
assert_eq!(c("chrome://resources//localhost/C:/Windows/notepad.exe"), Err(()));
|
|
assert_eq!(c("chrome://resources///localhost/C:/Windows/notepad.exe"), Err(()));
|
|
assert_eq!(c("chrome://resources/\\\\localhost\\C:\\Windows\\notepad.exe"), Err(()));
|
|
|
|
assert_eq!(c("chrome://resources/%3F/C:/Windows/notepad.exe"), Err(()));
|
|
assert_eq!(c("chrome://resources//%3F/C:/Windows/notepad.exe"), Err(()));
|
|
assert_eq!(c("chrome://resources///%3F/C:/Windows/notepad.exe"), Err(()));
|
|
assert_eq!(c("chrome://resources/\\\\%3F\\C:\\Windows\\notepad.exe"), Err(()));
|
|
|
|
assert_eq!(c("chrome://resources/%3F/UNC/localhost/C:/Windows/notepad.exe"), Err(()));
|
|
assert_eq!(c("chrome://resources//%3F/UNC/localhost/C:/Windows/notepad.exe"), Err(()));
|
|
assert_eq!(c("chrome://resources///%3F/UNC/localhost/C:/Windows/notepad.exe"), Err(()));
|
|
assert_eq!(c("chrome://resources/\\\\%3F\\UNC\\localhost\\C:\\Windows\\notepad.exe"), Err(()));
|
|
}
|