-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Add statusText validation for Response constructor
Implemented validation to ensure `statusText` matches the `reason-phrase` token production. This change fixes a WPT subtest which I have imported.
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Tests/LibWeb/Text/expected/wpt-import/fetch/api/response/response-error.any.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Harness status: OK | ||
|
||
Found 10 tests | ||
|
||
10 Pass | ||
Pass Throws RangeError when responseInit's status is 0 | ||
Pass Throws RangeError when responseInit's status is 100 | ||
Pass Throws RangeError when responseInit's status is 199 | ||
Pass Throws RangeError when responseInit's status is 600 | ||
Pass Throws RangeError when responseInit's status is 1000 | ||
Pass Throws TypeError when responseInit's statusText is | ||
|
||
Pass Throws TypeError when responseInit's statusText is Ā | ||
Pass Throws TypeError when building a response with body and a body status of 204 | ||
Pass Throws TypeError when building a response with body and a body status of 205 | ||
Pass Throws TypeError when building a response with body and a body status of 304 |
15 changes: 15 additions & 0 deletions
15
Tests/LibWeb/Text/input/wpt-import/fetch/api/response/response-error.any.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>Response error</title> | ||
<script> | ||
self.GLOBAL = { | ||
isWindow: function() { return true; }, | ||
isWorker: function() { return false; }, | ||
isShadowRealm: function() { return false; }, | ||
}; | ||
</script> | ||
<script src="../../../resources/testharness.js"></script> | ||
<script src="../../../resources/testharnessreport.js"></script> | ||
|
||
<div id=log></div> | ||
<script src="../../../fetch/api/response/response-error.any.js"></script> |
27 changes: 27 additions & 0 deletions
27
Tests/LibWeb/Text/input/wpt-import/fetch/api/response/response-error.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// META: global=window,worker | ||
// META: title=Response error | ||
|
||
var invalidStatus = [0, 100, 199, 600, 1000]; | ||
invalidStatus.forEach(function(status) { | ||
test(function() { | ||
assert_throws_js(RangeError, function() { new Response("", { "status" : status }); }, | ||
"Expect RangeError exception when status is " + status); | ||
},"Throws RangeError when responseInit's status is " + status); | ||
}); | ||
|
||
var invalidStatusText = ["\n", "Ā"]; | ||
invalidStatusText.forEach(function(statusText) { | ||
test(function() { | ||
assert_throws_js(TypeError, function() { new Response("", { "statusText" : statusText }); }, | ||
"Expect TypeError exception " + statusText); | ||
},"Throws TypeError when responseInit's statusText is " + statusText); | ||
}); | ||
|
||
var nullBodyStatus = [204, 205, 304]; | ||
nullBodyStatus.forEach(function(status) { | ||
test(function() { | ||
assert_throws_js(TypeError, | ||
function() { new Response("body", {"status" : status }); }, | ||
"Expect TypeError exception "); | ||
},"Throws TypeError when building a response with body and a body status of " + status); | ||
}); |