mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Merge net and net_tests
This commit is contained in:
parent
a311e0f569
commit
697b9e2b87
127 changed files with 18 additions and 62 deletions
44
components/net/tests/chrome_loader.rs
Normal file
44
components/net/tests/chrome_loader.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* 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(()));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue