diff options
Diffstat (limited to 'tests')
30 files changed, 526 insertions, 167 deletions
diff --git a/tests/html/form_html5_validations.html b/tests/html/form_html5_validations.html new file mode 100644 index 00000000000..edbbabd68d3 --- /dev/null +++ b/tests/html/form_html5_validations.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html> + <body> + <form> + Required: <input type="text" name="name" required><br> + Email : <input type="email" name="email"><br> + URL : <input type="url" name="email"><br> + Number(18-99): <input type="number" size="6" name="age" min="18" max="99"><br> + Pattern(MM/DD/YYYY): <input type="text" pattern="\d{1,2}/\d{1,2}/\d{4}"><br> + Length(10-20): <input minlength="10" maxlength="20"><br> + Length(10-20): <textarea required minlength="10" maxlength="20"></textarea><br> + Step(3.11)<input type="number" min="0" step="3.11"><br> + Required Select: <select required> + <option></option> + <option value="0">A</option> + <option value="1">B</option> + <option value="2">C</option> + </select><br> + Required Radio: <input type="radio" name="group1" value="1" required>1 + <input type="radio" name="group1" value="2">2 + <input type="radio" name="group1" value="3">3<br> + Required Checkbox: <input type="checkbox" name="group2" value="1" required>1 + <input type="checkbox" name="group2" value="2">2 + <input type="checkbox" name="group2" value="3">3<br> + Required File: <input type="file" required><br> + <input type="submit"> + </form> + </body> +</html>
\ No newline at end of file diff --git a/tests/unit/net/fetch.rs b/tests/unit/net/fetch.rs index 010d49e5732..1a6168f77d6 100644 --- a/tests/unit/net/fetch.rs +++ b/tests/unit/net/fetch.rs @@ -95,6 +95,20 @@ fn test_fetch_response_body_matches_const_message() { } #[test] +fn test_fetch_aboutblank() { + + let url = Url::parse("about:blank").unwrap(); + let origin = Origin::Origin(url.origin()); + let mut request = Request::new(url, Some(origin), false); + request.referer = Referer::NoReferer; + let wrapped_request = Rc::new(request); + + let fetch_response = fetch(wrapped_request); + assert!(!fetch_response.is_network_error()); + assert!(*fetch_response.body.lock().unwrap() == ResponseBody::Done(vec![])); +} + +#[test] fn test_fetch_response_is_basic_filtered() { static MESSAGE: &'static [u8] = b""; diff --git a/tests/unit/style/attr.rs b/tests/unit/style/attr.rs index 7aca499beae..aa7401113c7 100644 --- a/tests/unit/style/attr.rs +++ b/tests/unit/style/attr.rs @@ -2,8 +2,9 @@ * 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 style::attr::AttrValue; -use util::str::DOMString; +use app_units::Au; +use style::attr::{AttrValue, parse_length}; +use util::str::{DOMString, LengthOrPercentageOrAuto}; #[test] fn test_from_limited_i32_should_be_default_when_less_than_0() { @@ -31,3 +32,18 @@ fn test_from_limited_i32_should_keep_parsed_value_when_not_an_int() { _ => panic!("expected an successful parsing") } } + +#[test] +pub fn test_parse_length() { + fn check(input: &str, expected: LengthOrPercentageOrAuto) { + let parsed = parse_length(input); + assert_eq!(parsed, expected); + } + + check("0", LengthOrPercentageOrAuto::Length(Au::from_px(0))); + check("0.000%", LengthOrPercentageOrAuto::Percentage(0.0)); + check("+5.82%", LengthOrPercentageOrAuto::Percentage(0.0582)); + check("5.82", LengthOrPercentageOrAuto::Length(Au::from_f64_px(5.82))); + check("invalid", LengthOrPercentageOrAuto::Auto); + check("12 followed by invalid", LengthOrPercentageOrAuto::Length(Au::from_px(12))); +} diff --git a/tests/unit/util/str.rs b/tests/unit/util/str.rs index a9069a8dca2..be217b0c5ea 100644 --- a/tests/unit/util/str.rs +++ b/tests/unit/util/str.rs @@ -2,25 +2,7 @@ * 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 app_units::Au; -use util::str::LengthOrPercentageOrAuto; -use util::str::{parse_length, search_index, split_html_space_chars, str_join}; - - -#[test] -pub fn test_parse_length() { - fn check(input: &str, expected: LengthOrPercentageOrAuto) { - let parsed = parse_length(input); - assert_eq!(parsed, expected); - } - - check("0", LengthOrPercentageOrAuto::Length(Au::from_px(0))); - check("0.000%", LengthOrPercentageOrAuto::Percentage(0.0)); - check("+5.82%", LengthOrPercentageOrAuto::Percentage(0.0582)); - check("5.82", LengthOrPercentageOrAuto::Length(Au::from_f64_px(5.82))); - check("invalid", LengthOrPercentageOrAuto::Auto); - check("12 followed by invalid", LengthOrPercentageOrAuto::Length(Au::from_px(12))); -} +use util::str::{search_index, split_html_space_chars, str_join}; #[test] pub fn split_html_space_chars_whitespace() { diff --git a/tests/wpt/metadata/FileAPI/blob/Blob-constructor.html.ini b/tests/wpt/metadata/FileAPI/blob/Blob-constructor.html.ini index 3b34e8de52e..e47fa95e7df 100644 --- a/tests/wpt/metadata/FileAPI/blob/Blob-constructor.html.ini +++ b/tests/wpt/metadata/FileAPI/blob/Blob-constructor.html.ini @@ -3,22 +3,7 @@ [Passing non-objects, Dates and RegExps for blobParts should throw a TypeError.] expected: FAIL - [A plain object should be treated as a sequence for the blobParts argument.] - expected: FAIL - - [A plain object with a length property should be treated as a sequence for the blobParts argument.] - expected: FAIL - - [A Uint8Array object should be treated as a sequence for the blobParts argument.] - expected: FAIL - - [The length getter should be invoked and any exceptions should be propagated.] - expected: FAIL - - [A platform object that supports indexed properties should be treated as a sequence for the blobParts argument (overwritten 'length'.)] - expected: FAIL - - [ToUint32 should be applied to the length and any exceptions should be propagated.] + [Passing an platform object that supports indexed properties as the blobParts array should work (window).] expected: FAIL [Getters and value conversions should happen in order until an exception is thrown.] @@ -30,9 +15,6 @@ [Changes to the blobParts array should be reflected in the returned Blob (unshift).] expected: FAIL - [ToString should be called on elements of the blobParts array.] - expected: FAIL - [ArrayBuffer elements of the blobParts array should be supported.] expected: FAIL @@ -42,9 +24,6 @@ [Passing a Float64Array as element of the blobParts array should work.] expected: FAIL - [Passing an element as the blobParts array should work.] - expected: FAIL - [Passing an platform object that supports indexed properties as the blobParts array should work (window with custom toString).] expected: FAIL @@ -54,12 +33,6 @@ [Passing a platform array object as the blobParts array should work (MessagePort[\]).] expected: FAIL - [Passing a platform array object as the blobParts array should work (Attr[\]).] - expected: FAIL - - [Array with two blobs] - expected: FAIL - [Array with two buffers] expected: FAIL @@ -71,10 +44,3 @@ [no-argument Blob constructor without 'new'] expected: FAIL - - [A plain object with @@iterator should be treated as a sequence for the blobParts argument.] - expected: FAIL - - [A plain object with @@iterator and a length property should be treated as a sequence for the blobParts argument.] - expected: FAIL - diff --git a/tests/wpt/metadata/FileAPI/blob/Blob-slice.html.ini b/tests/wpt/metadata/FileAPI/blob/Blob-slice.html.ini index 9e78feb7d4e..efb90cbe024 100644 --- a/tests/wpt/metadata/FileAPI/blob/Blob-slice.html.ini +++ b/tests/wpt/metadata/FileAPI/blob/Blob-slice.html.ini @@ -1,65 +1,5 @@ [Blob-slice.html] type: testharness - [Slicing test: slice (1,0).] - expected: FAIL - - [Slicing test: slice (1,2).] - expected: FAIL - - [Slicing test: slice (1,3).] - expected: FAIL - - [Slicing test: slice (1,4).] - expected: FAIL - - [Slicing test: slice (1,5).] - expected: FAIL - - [Slicing test: slice (1,6).] - expected: FAIL - - [Slicing test: slice (1,7).] - expected: FAIL - - [Slicing test: slice (2,1).] - expected: FAIL - - [Slicing test: slice (2,2).] - expected: FAIL - - [Slicing test: slice (2,3).] - expected: FAIL - - [Slicing test: slice (3,0).] - expected: FAIL - - [Slicing test: slice (3,1).] - expected: FAIL - - [Slicing test: slice (3,2).] - expected: FAIL - - [Slicing test: slice (3,3).] - expected: FAIL - - [Slicing test: slice (3,4).] - expected: FAIL - - [Slicing test: slice (4,0).] - expected: FAIL - - [Slicing test: slice (4,1).] - expected: FAIL - - [Slicing test: slice (4,2).] - expected: FAIL - - [Slicing test: slice (4,3).] - expected: FAIL - - [Slicing test: slice (4,4).] - expected: FAIL - [Slicing test: slice (5,0).] expected: FAIL @@ -158,4 +98,3 @@ [Invalid contentType ("te xt/plain")] expected: FAIL - diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 6932cb31acb..b317fc48432 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -19242,6 +19242,14 @@ "url": "/html/semantics/scripting-1/the-script-element/script-before-after-events.html" }, { + "path": "html/semantics/scripting-1/the-script-element/script-charset-01.html", + "url": "/html/semantics/scripting-1/the-script-element/script-charset-01.html" + }, + { + "path": "html/semantics/scripting-1/the-script-element/script-charset-02.html", + "url": "/html/semantics/scripting-1/the-script-element/script-charset-02.html" + }, + { "path": "html/semantics/scripting-1/the-script-element/script-for-event-xhtml.xhtml", "url": "/html/semantics/scripting-1/the-script-element/script-for-event-xhtml.xhtml" }, @@ -34786,6 +34794,12 @@ "deleted": [], "items": { "testharness": { + "XMLHttpRequest/responseurl.html": [ + { + "path": "XMLHttpRequest/responseurl.html", + "url": "/XMLHttpRequest/responseurl.html" + } + ], "html/semantics/forms/textfieldselection/selection-after-content-change.html": [ { "path": "html/semantics/forms/textfieldselection/selection-after-content-change.html", diff --git a/tests/wpt/metadata/XMLHttpRequest/responsexml-document-properties.htm.ini b/tests/wpt/metadata/XMLHttpRequest/responsexml-document-properties.htm.ini index 743902575c9..32ef6273117 100644 --- a/tests/wpt/metadata/XMLHttpRequest/responsexml-document-properties.htm.ini +++ b/tests/wpt/metadata/XMLHttpRequest/responsexml-document-properties.htm.ini @@ -3,12 +3,6 @@ [domain] expected: FAIL - [URL] - expected: FAIL - - [documentURI] - expected: FAIL - [referrer] expected: FAIL diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index 3f6344d9026..ac375fb2b8c 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -5346,39 +5346,6 @@ [AutocompleteErrorEvent interface: attribute reason] expected: FAIL - [ValidityState interface: attribute valueMissing] - expected: FAIL - - [ValidityState interface: attribute typeMismatch] - expected: FAIL - - [ValidityState interface: attribute patternMismatch] - expected: FAIL - - [ValidityState interface: attribute tooLong] - expected: FAIL - - [ValidityState interface: attribute tooShort] - expected: FAIL - - [ValidityState interface: attribute rangeUnderflow] - expected: FAIL - - [ValidityState interface: attribute rangeOverflow] - expected: FAIL - - [ValidityState interface: attribute stepMismatch] - expected: FAIL - - [ValidityState interface: attribute badInput] - expected: FAIL - - [ValidityState interface: attribute customError] - expected: FAIL - - [ValidityState interface: attribute valid] - expected: FAIL - [ValidityState must be primary interface of document.createElement("input").validity] expected: FAIL diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index deee3a3eeb2..73d57a5c311 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -2072,6 +2072,30 @@ "url": "/_mozilla/css/incremental_text_color_a.html" } ], + "css/incremental_visibility_a.html": [ + { + "path": "css/incremental_visibility_a.html", + "references": [ + [ + "/_mozilla/css/incremental_visibility_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/incremental_visibility_a.html" + } + ], + "css/incremental_visibility_ref.html": [ + { + "path": "css/incremental_visibility_ref.html", + "references": [ + [ + "/_mozilla/css/incremental_visibility_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/incremental_visibility_ref.html" + } + ], "css/inline_absolute_hypothetical_clip_a.html": [ { "path": "css/inline_absolute_hypothetical_clip_a.html", @@ -5416,6 +5440,30 @@ "url": "/_mozilla/mozilla/canvas/drawimage_html_image_9.html" } ], + "mozilla/details_ui_closed.html": [ + { + "path": "mozilla/details_ui_closed.html", + "references": [ + [ + "/_mozilla/mozilla/details_ui_closed_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/details_ui_closed.html" + } + ], + "mozilla/details_ui_opened.html": [ + { + "path": "mozilla/details_ui_opened.html", + "references": [ + [ + "/_mozilla/mozilla/details_ui_opened_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/details_ui_opened.html" + } + ], "mozilla/iframe/resize_after_load.html": [ { "path": "mozilla/iframe/resize_after_load.html", @@ -6000,6 +6048,12 @@ "url": "/_mozilla/mozilla/mozbrowser/mozbrowsericonchange_event.html" } ], + "mozilla/mozbrowser/mozbrowserlocationchange_event.html": [ + { + "path": "mozilla/mozbrowser/mozbrowserlocationchange_event.html", + "url": "/_mozilla/mozilla/mozbrowser/mozbrowserlocationchange_event.html" + } + ], "mozilla/mozbrowser/mozbrowsersecuritychange_event.html": [ { "path": "mozilla/mozbrowser/mozbrowsersecuritychange_event.html", @@ -8308,6 +8362,30 @@ "url": "/_mozilla/css/incremental_text_color_a.html" } ], + "css/incremental_visibility_a.html": [ + { + "path": "css/incremental_visibility_a.html", + "references": [ + [ + "/_mozilla/css/incremental_visibility_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/incremental_visibility_a.html" + } + ], + "css/incremental_visibility_ref.html": [ + { + "path": "css/incremental_visibility_ref.html", + "references": [ + [ + "/_mozilla/css/incremental_visibility_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/incremental_visibility_ref.html" + } + ], "css/inline_absolute_hypothetical_clip_a.html": [ { "path": "css/inline_absolute_hypothetical_clip_a.html", @@ -11652,6 +11730,30 @@ "url": "/_mozilla/mozilla/canvas/drawimage_html_image_9.html" } ], + "mozilla/details_ui_closed.html": [ + { + "path": "mozilla/details_ui_closed.html", + "references": [ + [ + "/_mozilla/mozilla/details_ui_closed_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/details_ui_closed.html" + } + ], + "mozilla/details_ui_opened.html": [ + { + "path": "mozilla/details_ui_opened.html", + "references": [ + [ + "/_mozilla/mozilla/details_ui_opened_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/details_ui_opened.html" + } + ], "mozilla/iframe/resize_after_load.html": [ { "path": "mozilla/iframe/resize_after_load.html", diff --git a/tests/wpt/mozilla/tests/css/filter_inline_a.html b/tests/wpt/mozilla/tests/css/filter_inline_a.html index faf692e1589..9392ab01de8 100644 --- a/tests/wpt/mozilla/tests/css/filter_inline_a.html +++ b/tests/wpt/mozilla/tests/css/filter_inline_a.html @@ -14,6 +14,6 @@ </style> </head> <body> - <img class="ex" src="rust.png"> + <img class="ex" src="rust-0.png"> </body> </html> diff --git a/tests/wpt/mozilla/tests/css/filter_inline_ref.html b/tests/wpt/mozilla/tests/css/filter_inline_ref.html index 0bc34849029..420d796e4b1 100644 --- a/tests/wpt/mozilla/tests/css/filter_inline_ref.html +++ b/tests/wpt/mozilla/tests/css/filter_inline_ref.html @@ -13,6 +13,6 @@ </style> </head> <body> - <img class="ex" src="rust.png"> + <img class="ex" src="rust-0.png"> </body> </html> diff --git a/tests/wpt/mozilla/tests/css/incremental_visibility_a.html b/tests/wpt/mozilla/tests/css/incremental_visibility_a.html new file mode 100644 index 00000000000..b52a7814549 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/incremental_visibility_a.html @@ -0,0 +1,29 @@ +<!doctype html> +<html class="reftest-wait"> + <head> + <meta charset="UTF-8"> + <title>Incremental visibility test</title> + <link rel="match" href="incremental_visibility_ref.html"> + <style> + div { + background: green; + height: 100px; + width: 100px; + visibility: hidden; + } + div.show { + visibility: visible; + } + </style> + </head> + <body> + <div></div> + <script> + window.onload = function() { + document.body.offsetWidth; // force layout + document.querySelector('div').classList.add('show'); + document.documentElement.classList.remove('reftest-wait'); + } + </script> + </body> +</html> diff --git a/tests/wpt/mozilla/tests/css/incremental_visibility_ref.html b/tests/wpt/mozilla/tests/css/incremental_visibility_ref.html new file mode 100644 index 00000000000..a90c2b184e3 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/incremental_visibility_ref.html @@ -0,0 +1,18 @@ +<!doctype html> +<html> + <head> + <meta charset="UTF-8"> + <title>Incremental visibility reference</title> + <link rel="match" href="incremental_visibility_ref.html"> + <style> + div { + background: green; + height: 100px; + width: 100px; + } + </style> + </head> + <body> + <div></div> + </body> +</html> diff --git a/tests/wpt/mozilla/tests/css/inline_margin_multiple_fragments_a.html b/tests/wpt/mozilla/tests/css/inline_margin_multiple_fragments_a.html index 9e93b7bc55e..f45aa1916ea 100644 --- a/tests/wpt/mozilla/tests/css/inline_margin_multiple_fragments_a.html +++ b/tests/wpt/mozilla/tests/css/inline_margin_multiple_fragments_a.html @@ -10,7 +10,6 @@ span { </style> </head> <body> -<span><img src=rust.png><img src=rust.png><img src=rust.png></span> +<span><img src=rust-0.png><img src=rust-0.png><img src=rust-0.png></span> </body> </html> - diff --git a/tests/wpt/mozilla/tests/css/inline_margin_multiple_fragments_ref.html b/tests/wpt/mozilla/tests/css/inline_margin_multiple_fragments_ref.html index 7e791b9eb76..6d6755c9d41 100644 --- a/tests/wpt/mozilla/tests/css/inline_margin_multiple_fragments_ref.html +++ b/tests/wpt/mozilla/tests/css/inline_margin_multiple_fragments_ref.html @@ -11,8 +11,6 @@ </style> </head> <body> -<span id=first><img src=rust.png></span><img src=rust.png><span id=last><img src=rust.png></span> +<span id=first><img src=rust-0.png></span><img src=rust-0.png><span id=last><img src=rust-0.png></span> </body> </html> - - diff --git a/tests/wpt/mozilla/tests/mozilla/details_ui_closed.html b/tests/wpt/mozilla/tests/mozilla/details_ui_closed.html new file mode 100644 index 00000000000..cf5c046a983 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/details_ui_closed.html @@ -0,0 +1,9 @@ +<!doctype html> +<meta charset="utf-8"> +<title></title> +<link rel="match" href="details_ui_closed_ref.html"> +<details> +<summary>Test</summary> +Contents +</details> + diff --git a/tests/wpt/mozilla/tests/mozilla/details_ui_closed_ref.html b/tests/wpt/mozilla/tests/mozilla/details_ui_closed_ref.html new file mode 100644 index 00000000000..b7db1ce810c --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/details_ui_closed_ref.html @@ -0,0 +1,12 @@ +<!doctype html> +<meta charset="utf-8"> +<title></title> +<style> +#s { display: list-item; list-style: disclosure-closed; margin-left: 40px } +#c { display: none } +</style> +<div id=d> +<div id=s>Test</div> +<div id=c>Contents</div> +</div> + diff --git a/tests/wpt/mozilla/tests/mozilla/details_ui_opened.html b/tests/wpt/mozilla/tests/mozilla/details_ui_opened.html new file mode 100644 index 00000000000..10e65e98d81 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/details_ui_opened.html @@ -0,0 +1,9 @@ +<!doctype html> +<meta charset="utf-8"> +<title></title> +<link rel="match" href="details_ui_opened_ref.html"> +<details open> +<summary>Test</summary> +Contents +</details> + diff --git a/tests/wpt/mozilla/tests/mozilla/details_ui_opened_ref.html b/tests/wpt/mozilla/tests/mozilla/details_ui_opened_ref.html new file mode 100644 index 00000000000..57ae10d082a --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/details_ui_opened_ref.html @@ -0,0 +1,12 @@ +<!doctype html> +<meta charset="utf-8"> +<title></title> +<style> +#s { display: list-item; list-style: disclosure-open; margin-left: 40px } +#c { margin-left: 40px } +</style> +<div id=d> +<div id=s>Test</div> +<div id=c>Contents</div> +</div> + diff --git a/tests/wpt/mozilla/tests/mozilla/mozbrowser/iframe_goback.html b/tests/wpt/mozilla/tests/mozilla/mozbrowser/iframe_goback.html index 518bb3d5a47..e8c7299e55a 100644 --- a/tests/wpt/mozilla/tests/mozilla/mozbrowser/iframe_goback.html +++ b/tests/wpt/mozilla/tests/mozilla/mozbrowser/iframe_goback.html @@ -19,8 +19,8 @@ async_test(function(t) { iframe.src = url1; iframe.addEventListener("mozbrowserlocationchange", e => { - locations.push(e.detail); - if (e.detail == url2) { + locations.push(e.detail.uri); + if (e.detail.uri == url2) { iframe.goBack(); } if (locations.length == expected_locations.length) { diff --git a/tests/wpt/mozilla/tests/mozilla/mozbrowser/mozbrowserlocationchange_event.html b/tests/wpt/mozilla/tests/mozilla/mozbrowser/mozbrowserlocationchange_event.html new file mode 100644 index 00000000000..4198ed66397 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/mozbrowser/mozbrowserlocationchange_event.html @@ -0,0 +1,59 @@ +<head> +<title>Browser API; mozbrowserlocationchange event</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<script> + +async_test(function(t) { + + var url1 = "data:,1"; + var url2 = "data:,2"; + var url3 = "data:,3"; + + var received_events = [] + var expected_events = [ + url1, false, false, + url2, true, false, + url3, true, false, + url2, true, true, + url1, false, true, + url2, true, true, + url3, true, false, + ]; + + var iframe = document.createElement("iframe"); + iframe.mozbrowser = "true"; + iframe.src = url1; + + var actions = [ + function() {iframe.src = url2}, + function() {iframe.src = url3}, + function() {iframe.goBack()}, + function() {iframe.goBack()}, + function() {iframe.goForward()}, + function() {iframe.goForward()}, + ]; + + var action_idx = 0; + + iframe.addEventListener("mozbrowserlocationchange", e => { + received_events.push(e.detail.uri); + received_events.push(e.detail.canGoBack); + received_events.push(e.detail.canGoForward); + + if (action_idx < actions.length) { + actions[action_idx++](); + } else { + assert_array_equals(received_events, expected_events); + t.done(); + } + }); + + document.body.appendChild(iframe); + +}); + +</script> +</body> diff --git a/tests/wpt/mozilla/tests/mozilla/mozbrowser/redirect.html b/tests/wpt/mozilla/tests/mozilla/mozbrowser/redirect.html index 6d9c11fdbe2..b90871b8197 100644 --- a/tests/wpt/mozilla/tests/mozilla/mozbrowser/redirect.html +++ b/tests/wpt/mozilla/tests/mozilla/mozbrowser/redirect.html @@ -10,7 +10,7 @@ iframe.mozbrowser = "true"; iframe.src = "redirect_init.html?pipe=status(302)|header(Location,redirect_final.html)"; iframe.addEventListener("mozbrowserlocationchange", t.step_func(e => { - assert_equals(e.detail, new URL("redirect_final.html", location).href); + assert_equals(e.detail.uri, new URL("redirect_final.html", location).href); t.done(); })); document.body.appendChild(iframe); diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/OWNERS b/tests/wpt/web-platform-tests/XMLHttpRequest/OWNERS index 7a809e70f6c..27421d921a0 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/OWNERS +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/OWNERS @@ -1,4 +1,4 @@ -@ecoal95 +@emilio @hallvors @kangxu @caitp diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/responseurl.html b/tests/wpt/web-platform-tests/XMLHttpRequest/responseurl.html new file mode 100644 index 00000000000..b730e045d8d --- /dev/null +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/responseurl.html @@ -0,0 +1,37 @@ +<!doctype html> +<html> + <head> + <title>XMLHttpRequest: responseURL test</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <link rel="help" href="https://xhr.spec.whatwg.org/#the-responseurl-attribute"/> + </head> + <body> + <div id="log"></div> + <script> + test(function() { + var client = new XMLHttpRequest() + assert_equals(client.responseURL, "") + + client.open("GET", "foo.html", false) + client.send() + + expected = location.href.replace(/[^/]*$/, 'foo.html') + assert_equals(client.status, 404) + assert_equals(client.responseURL, expected) + }, "404 response has proper responseURL") + test(function() { + var client = new XMLHttpRequest() + assert_equals(client.responseURL, "") + + target = "image.gif" + client.open("GET", "resources/redirect.py?location=" + target, false) + client.send() + + expected = location.href.replace(/[^/]*$/, "resources/" + target) + assert_equals(client.status, 200) + assert_equals(client.responseURL, expected) + }, "Redirected response has proper responseURL") + </script> + </body> +</html> diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/external-script-utf8.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/external-script-utf8.js new file mode 100644 index 00000000000..eb442c97bc9 --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/external-script-utf8.js @@ -0,0 +1,5 @@ +(function() { + window.getSomeString = function() { + return "śćążź"; //<- these are five Polish letters, similar to scazz. It can be read correctly only with windows 1250 encoding. + }; +})(); diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/external-script-windows1250.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/external-script-windows1250.js new file mode 100644 index 00000000000..50de6932ba2 --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/external-script-windows1250.js @@ -0,0 +1,5 @@ +(function() { + window.getSomeString = function() { + return "œæ¹¿Ÿ"; //<- these are five Polish letters, similar to scazz. It can be read correctly only with windows 1250 encoding. + }; +})(); diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-01.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-01.html new file mode 100644 index 00000000000..c5ac0d0a62a --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-01.html @@ -0,0 +1,89 @@ +<!DOCTYPE html> +<head> + <meta charset="utf-8"> + <title>Script @type: unknown parameters</title> + <link rel="author" title="askalski" href="github.com/askalski"> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <div id="log"></div> + + <!-- "Step1" tests --> + <!-- charset is set incorrectly via Content Type "text/javascript;charset=utf-8" in response + which has priority before a correct setting in "charset" attribute of script tag. + --> + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript%3Bcharset=utf-8" charset="windows-1250"> + </script> + <script> + test(function() { + //these strings should not match, since the file charset is set incorrectly + assert_not_equals(window.getSomeString(), "śćążź"); + }); + </script> + <!-- charset is set correctly via Content Type "text/javascript;charset=utf-8" in response + which has priority before a incorrect setting in "charset" attribute of script tag. + --> + + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript%3Bcharset=windows-1250" charset="utf-8"> + </script> + <script> + //the charset is set correctly via Content Type "text/javascript;charset=windows-1250" in respones + test(function() { + assert_equals(window.getSomeString(), "śćążź"); + }); + </script> + + <!-- end of step1 tests, now step2 tests --> + <!-- in this case, the response's Content Type does not bring charset information. + Second step takes block character encoding if available.--> + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript" charset="utf-8"> + </script> + <script> + test(function() { + //these strings should not match, since the file charset is set incorrectly in "charset" tag of <script> above + assert_not_equals(window.getSomeString(), "śćążź"); + }); + </script> + <!-- charset is set correctly via Content Type "text/javascript;charset=utf-8" in response + which has priority before a incorrect setting in "charset" attribute of script tag. + --> + + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript" charset="windows-1250"> + </script> + <script> + //the charset is set correctly via content attribute in <script> above + test(function() { + assert_equals(window.getSomeString(), "śćążź"); + }); + </script> + + <!-- end of step2 tests, now step3 tests --> + <!-- in this case, neither response's Content Type nor charset attribute bring correct charset information. + Third step takes this document's character encoding (declared correctly as UTF-8).--> + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript"> + </script> + <script> + test(function() { + //these strings should not match, since the tested file is in windows-1250, and document is utf-8 + assert_not_equals(window.getSomeString(), "śćążź"); + }); + </script> + + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-utf8.js&ct=text/javascript"> + </script> + <script> + //these strings should match, both document and tested file are utf-8 + test(function() { + assert_equals(window.getSomeString(), "śćążź"); + }); + </script> + + <!-- the last portion of tests (step4) are in file script-charset-02.html + +</head> diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-02.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-02.html new file mode 100644 index 00000000000..77a015bb71f --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-02.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<head> + <!-- TODO: + askalski: while this test pass, it does not test anything now. + It should test, whether with no document.charset set in any way, the + external scripts will get decoded using utf-8 as fallback character encoding. + It seems like utf-8 is also a fallback encoding to html (my guess), so + the part of the code I was attempting to test is never reached. + --> + <title>Script @type: unknown parameters</title> + <link rel="author" title="askalski" href="github.com/askalski"> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <div id="log"></div> + + <!-- test of step4, which is taking utf-8 as fallback --> + <!-- in this case, neither response's Content Type nor charset attribute bring correct charset information. + Furthermore, document's encoding is not set.--> + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript"> + </script> + <script> + test(function() { + //these strings should not match, since the tested file is in windows-1250, and fallback is defined as utf-8 + assert_not_equals(window.getSomeString().length, 5); + }); + </script> + + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-utf8.js&ct=text/javascript"> + </script> + <script> + //these strings should match, since fallback utf-8 is the correct setting. + test(function() { + assert_equals(window.getSomeString().length, 5); + }); + </script> + +</head> diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py new file mode 100644 index 00000000000..7cfe6f4cec3 --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py @@ -0,0 +1,15 @@ +import os + +def main(request, response): + directory = os.path.dirname(__file__) + + try: + file_name = request.GET.first("fn") + content_type = request.GET.first("ct") + with open(os.path.join(directory, file_name), "rb") as fh: + content = fh.read() + + response.headers.set("Content-Type", content_type) + response.content = content + except: + response.set_error(400, "Not enough parameters or file not found") |