diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2018-01-19 12:52:54 +0100 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2018-01-20 15:36:09 +0100 |
commit | 697b9e2b87147a0f3767226c52097549d65b96da (patch) | |
tree | a96860efc9fa6d1200141cf2392c04137b82b28c /components/net/tests/chrome_loader.rs | |
parent | a311e0f569f8aba447aeef3034a37ee900720307 (diff) | |
download | servo-697b9e2b87147a0f3767226c52097549d65b96da.tar.gz servo-697b9e2b87147a0f3767226c52097549d65b96da.zip |
Merge net and net_tests
Diffstat (limited to 'components/net/tests/chrome_loader.rs')
-rw-r--r-- | components/net/tests/chrome_loader.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/components/net/tests/chrome_loader.rs b/components/net/tests/chrome_loader.rs new file mode 100644 index 00000000000..c7669d9a0ac --- /dev/null +++ b/components/net/tests/chrome_loader.rs @@ -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(())); +} |