mirror of
https://github.com/servo/servo.git
synced 2025-06-19 22:59:03 +01:00
Auto merge of #14632 - servo:multi-global-fetch, r=jdm
Use the API base URL in Fetch APIs. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14632) <!-- Reviewable:end -->
This commit is contained in:
commit
89cdcbc420
10 changed files with 11 additions and 23 deletions
|
@ -92,8 +92,7 @@ impl Request {
|
||||||
let mut fallback_credentials: Option<NetTraitsRequestCredentials> = None;
|
let mut fallback_credentials: Option<NetTraitsRequestCredentials> = None;
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
// TODO: `entry settings object` is not implemented in Servo yet.
|
let base_url = global.api_base_url();
|
||||||
let base_url = global.get_url();
|
|
||||||
|
|
||||||
match input {
|
match input {
|
||||||
// Step 5
|
// Step 5
|
||||||
|
|
|
@ -149,8 +149,7 @@ impl Response {
|
||||||
// https://fetch.spec.whatwg.org/#dom-response-redirect
|
// https://fetch.spec.whatwg.org/#dom-response-redirect
|
||||||
pub fn Redirect(global: &GlobalScope, url: USVString, status: u16) -> Fallible<Root<Response>> {
|
pub fn Redirect(global: &GlobalScope, url: USVString, status: u16) -> Fallible<Root<Response>> {
|
||||||
// Step 1
|
// Step 1
|
||||||
// TODO: `entry settings object` is not implemented in Servo yet.
|
let base_url = global.api_base_url();
|
||||||
let base_url = global.get_url();
|
|
||||||
let parsed_url = base_url.join(&url.0);
|
let parsed_url = base_url.join(&url.0);
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[url-parsing.html]
|
|
||||||
type: testharness
|
|
||||||
[should parse the URL relative to the current settings object]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[url-parsing.html]
|
|
||||||
type: testharness
|
|
||||||
[should parse the redirect Location URL relative to the current settings object]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<title>Current page used as a test helper</title>
|
<title>Current page used as a test helper</title>
|
||||||
|
<base href="success/">
|
||||||
|
|
|
@ -6,9 +6,8 @@
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const current = document.querySelector('#c').contentWindow;
|
|
||||||
|
|
||||||
window.createRequest = (...args) => {
|
window.createRequest = (...args) => {
|
||||||
|
const current = document.querySelector('#c').contentWindow;
|
||||||
return new current.Request(...args);
|
return new current.Request(...args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ const loadPromise = new Promise(resolve => {
|
||||||
|
|
||||||
promise_test(() => {
|
promise_test(() => {
|
||||||
return loadPromise.then(() => {
|
return loadPromise.then(() => {
|
||||||
const req = frames[0].createRequest("url");
|
const req = document.querySelector('iframe').contentWindow.createRequest("url");
|
||||||
|
|
||||||
assert_equals(req.url, new URL("current/url", location.href).href);
|
assert_equals(req.url, new URL("current/success/url", location.href).href);
|
||||||
});
|
});
|
||||||
}, "should parse the URL relative to the current settings object");
|
}, "should parse the URL relative to the current settings object");
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<title>Current page used as a test helper</title>
|
<title>Current page used as a test helper</title>
|
||||||
|
<base href="success/">
|
||||||
|
|
|
@ -7,10 +7,9 @@
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const current = document.querySelector('#c').contentWindow;
|
|
||||||
const relevant = document.querySelector('#r').contentWindow;
|
|
||||||
|
|
||||||
window.createRedirectResponse = (...args) => {
|
window.createRedirectResponse = (...args) => {
|
||||||
|
const current = document.querySelector('#c').contentWindow;
|
||||||
|
const relevant = document.querySelector('#r').contentWindow;
|
||||||
return current.Response.redirect.call(relevant.Response, ...args);
|
return current.Response.redirect.call(relevant.Response, ...args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ const loadPromise = new Promise(resolve => {
|
||||||
|
|
||||||
promise_test(() => {
|
promise_test(() => {
|
||||||
return loadPromise.then(() => {
|
return loadPromise.then(() => {
|
||||||
const res = frames[0].createRedirectResponse("url");
|
const res = document.querySelector('iframe').contentWindow.createRedirectResponse("url");
|
||||||
|
|
||||||
assert_equals(res.headers.get("Location"), new URL("current/url", location.href).href);
|
assert_equals(res.headers.get("Location"), new URL("current/success/url", location.href).href);
|
||||||
});
|
});
|
||||||
}, "should parse the redirect Location URL relative to the current settings object");
|
}, "should parse the redirect Location URL relative to the current settings object");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue