Przeglądaj źródła

Test WebIdl::origin

CC https://github.com/w3c/web-platform-tests/pull/2584
Simon Sapin 10 lat temu
rodzic
commit
8eba0ce106
2 zmienionych plików z 8 dodań i 29 usunięć
  1. 0 24
      tests/urltestdata.json
  2. 8 5
      tests/wpt.rs

+ 0 - 24
tests/urltestdata.json

@@ -919,7 +919,6 @@
     "input": "file:/example.com/",
     "base": "http://example.org/foo/bar",
     "href": "file:///example.com/",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1295,7 +1294,6 @@
     "input": "file:c:\\foo\\bar.html",
     "base": "file:///tmp/mock/path",
     "href": "file:///c:/foo/bar.html",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1310,7 +1308,6 @@
     "input": "  File:c|////foo\\bar.html",
     "base": "file:///tmp/mock/path",
     "href": "file:///c:////foo/bar.html",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1325,7 +1322,6 @@
     "input": "C|/foo/bar",
     "base": "file:///tmp/mock/path",
     "href": "file:///C:/foo/bar",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1340,7 +1336,6 @@
     "input": "/C|\\foo\\bar",
     "base": "file:///tmp/mock/path",
     "href": "file:///C:/foo/bar",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1355,7 +1350,6 @@
     "input": "//C|/foo/bar",
     "base": "file:///tmp/mock/path",
     "href": "file:///C:/foo/bar",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1370,7 +1364,6 @@
     "input": "//server/file",
     "base": "file:///tmp/mock/path",
     "href": "file://server/file",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1385,7 +1378,6 @@
     "input": "\\\\server\\file",
     "base": "file:///tmp/mock/path",
     "href": "file://server/file",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1400,7 +1392,6 @@
     "input": "/\\server/file",
     "base": "file:///tmp/mock/path",
     "href": "file://server/file",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1415,7 +1406,6 @@
     "input": "file:///foo/bar.txt",
     "base": "file:///tmp/mock/path",
     "href": "file:///foo/bar.txt",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1430,7 +1420,6 @@
     "input": "file:///home/me",
     "base": "file:///tmp/mock/path",
     "href": "file:///home/me",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1445,7 +1434,6 @@
     "input": "//",
     "base": "file:///tmp/mock/path",
     "href": "file:///",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1460,7 +1448,6 @@
     "input": "///",
     "base": "file:///tmp/mock/path",
     "href": "file:///",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1475,7 +1462,6 @@
     "input": "///test",
     "base": "file:///tmp/mock/path",
     "href": "file:///test",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1490,7 +1476,6 @@
     "input": "file://test",
     "base": "file:///tmp/mock/path",
     "href": "file://test/",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1505,7 +1490,6 @@
     "input": "file://localhost",
     "base": "file:///tmp/mock/path",
     "href": "file:///",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1520,7 +1504,6 @@
     "input": "file://localhost/",
     "base": "file:///tmp/mock/path",
     "href": "file:///",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1535,7 +1518,6 @@
     "input": "file://localhost/test",
     "base": "file:///tmp/mock/path",
     "href": "file:///test",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1550,7 +1532,6 @@
     "input": "test",
     "base": "file:///tmp/mock/path",
     "href": "file:///tmp/mock/test",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -1565,7 +1546,6 @@
     "input": "file:test",
     "base": "file:///tmp/mock/path",
     "href": "file:///tmp/mock/test",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -2587,7 +2567,6 @@
     "input": "file:/example.com/",
     "base": "about:blank",
     "href": "file:///example.com/",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -3344,7 +3323,6 @@
     "input": "file:...",
     "base": "http://www.example.com/test",
     "href": "file:///...",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -3359,7 +3337,6 @@
     "input": "file:..",
     "base": "http://www.example.com/test",
     "href": "file:///",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",
@@ -3374,7 +3351,6 @@
     "input": "file:a",
     "base": "http://www.example.com/test",
     "href": "file:///a",
-    "origin": "file://",
     "protocol": "file:",
     "username": "",
     "password": "",

+ 8 - 5
tests/wpt.rs

@@ -29,17 +29,20 @@ fn run_one(input: String, base: String, expected: Result<TestCase, ()>) {
     };
 
     macro_rules! assert_getter {
-        ($attribute: ident) => {
+        ($attribute: ident) => { assert_getter!($attribute, expected.$attribute) };
+        ($attribute: ident, $expected: expr) => {
             {
                 let a = WebIdl::$attribute(&url);
-                let b = expected.$attribute;
+                let b = $expected;
                 assert!(a == b, "{:?} != {:?} for URL {:?}", a, b, url);
             }
         }
     }
 
     assert_getter!(href);
-    //assert_getter!(origin);  FIXME
+    if let Some(expected_origin) = expected.origin {
+        assert_getter!(origin, expected_origin);
+    }
     assert_getter!(protocol);
     assert_getter!(username);
     assert_getter!(password);
@@ -53,7 +56,7 @@ fn run_one(input: String, base: String, expected: Result<TestCase, ()>) {
 
 struct TestCase {
     href: String,
-    origin: String,
+    origin: Option<String>,
     protocol: String,
     username: String,
     password: String,
@@ -80,7 +83,7 @@ fn main() {
         } else {
             Ok(TestCase {
                 href: string("href"),
-                origin: string("origin"),
+                origin: entry.find("origin").map(|j| j.as_string().unwrap().to_owned()),
                 protocol: string("protocol"),
                 username: string("username"),
                 password: string("password"),