1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test for redirection.
const TEST_URL = `${URL_ROOT}sjs_redirection.sjs`;
const CUSTOM_USER_AGENT = "Mozilla/5.0 (Test Device) Firefox/74.0";
addRDMTask(
null,
async () => {
reloadOnUAChange(true);
registerCleanupFunction(() => {
reloadOnUAChange(false);
});
const tab = await addTab(TEST_URL);
const browser = tab.linkedBrowser;
const { ui } = await openRDM(tab);
await waitForDeviceAndViewportState(ui);
info("Change the user agent");
await changeUserAgentInput(ui, CUSTOM_USER_AGENT);
await testUserAgent(ui, CUSTOM_USER_AGENT);
info("Load a page which redirects");
const onRedirectedPageLoaded = BrowserTestUtils.browserLoaded(
browser,
false,
// wait specifically for the redirected page
url => url.includes(`?redirected`)
);
BrowserTestUtils.loadURIString(browser, `${TEST_URL}?redirect`);
await onRedirectedPageLoaded;
info("Check the user agent for each requests");
await SpecialPowers.spawn(
browser,
[CUSTOM_USER_AGENT],
expectedUserAgent => {
is(
content.wrappedJSObject.redirectRequestUserAgent,
expectedUserAgent,
`Sent user agent is correct for request that caused the redirect`
);
is(
content.wrappedJSObject.requestUserAgent,
expectedUserAgent,
`Sent user agent is correct for the redirected page`
);
}
);
await closeRDM(tab);
await removeTab(tab);
},
{ onlyPrefAndTask: true }
);
|