mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
|
|
@ -0,0 +1,56 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "data:text/html, Custom User Agent test";
|
||||
const DEFAULT_UA = Cc["@mozilla.org/network/protocol;1?name=http"]
|
||||
.getService(Ci.nsIHttpProtocolHandler)
|
||||
.userAgent;
|
||||
const CHROME_UA = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36" +
|
||||
" (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
|
||||
add_task(function* () {
|
||||
yield addTab(TEST_URI);
|
||||
|
||||
let {rdm, manager} = yield openRDM();
|
||||
yield testUserAgent(DEFAULT_UA);
|
||||
|
||||
info("Setting UA to " + CHROME_UA);
|
||||
yield setUserAgent(CHROME_UA, rdm, manager);
|
||||
yield testUserAgent(CHROME_UA);
|
||||
|
||||
info("Resetting UA");
|
||||
yield setUserAgent("", rdm, manager);
|
||||
yield testUserAgent(DEFAULT_UA);
|
||||
|
||||
info("Setting UA to " + CHROME_UA);
|
||||
yield setUserAgent(CHROME_UA, rdm, manager);
|
||||
yield testUserAgent(CHROME_UA);
|
||||
|
||||
info("Closing responsive mode");
|
||||
|
||||
yield closeRDM(rdm);
|
||||
yield testUserAgent(DEFAULT_UA);
|
||||
});
|
||||
|
||||
function* setUserAgent(ua, rdm, manager) {
|
||||
let input = rdm.userAgentInput;
|
||||
input.focus();
|
||||
input.value = ua;
|
||||
let onUAChanged = once(manager, "userAgentChanged");
|
||||
input.blur();
|
||||
yield onUAChanged;
|
||||
|
||||
if (ua !== "") {
|
||||
ok(input.hasAttribute("attention"), "UA input should be highlighted");
|
||||
} else {
|
||||
ok(!input.hasAttribute("attention"), "UA input shouldn't be highlighted");
|
||||
}
|
||||
}
|
||||
|
||||
function* testUserAgent(value) {
|
||||
let ua = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
|
||||
return content.navigator.userAgent;
|
||||
});
|
||||
is(ua, value, `UA should be set to ${value}`);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue