зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1002724
- Test that HTTPS is tried if typed host name doesn't respond via HTTP. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D75085
This commit is contained in:
Родитель
485d080bae
Коммит
4f2852cbc8
|
@ -153,3 +153,4 @@ skip-if = !e10s # e10s specific test.
|
|||
[browser_tab_replace_while_loading.js]
|
||||
skip-if = (os == 'linux' && bits == 64 && os_version == '18.04') # Bug 1604237
|
||||
[browser_browsing_context_discarded.js]
|
||||
[browser_fall_back_to_https.js]
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* This test is for bug 1002724.
|
||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=1002724
|
||||
*
|
||||
* When a user enters a host name or IP address in the URL bar, "http" is
|
||||
* assumed. If the host rejects connections on port 80, we try HTTPS as a
|
||||
* fall-back and only fail if HTTPS connection fails.
|
||||
*
|
||||
* This tests that when a user enters "example.com", it attempts to load
|
||||
* http://example.com:80 (not rejected), and when trying 127.0.0.2
|
||||
* (which rejects connections on port 80), it fails then loads
|
||||
* https://127.0.0.2:443 instead.
|
||||
*/
|
||||
|
||||
const { UrlbarTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/UrlbarTestUtils.jsm"
|
||||
);
|
||||
|
||||
const bug1002724_tests = [
|
||||
{
|
||||
original: "example.com",
|
||||
expected: "http://example.com",
|
||||
explanation: "Should load HTTP version of example.com",
|
||||
},
|
||||
{
|
||||
original: "127.0.0.2",
|
||||
expected: "https://127.0.0.2",
|
||||
explanation: "Should reject 127.0.0.2 on HTTP but load the HTTPS version",
|
||||
},
|
||||
];
|
||||
|
||||
async function test_one(test_obj) {
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
"about:blank"
|
||||
);
|
||||
gURLBar.focus();
|
||||
gURLBar.value = test_obj.original;
|
||||
|
||||
let loadPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false);
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
await loadPromise;
|
||||
|
||||
ok(
|
||||
tab.linkedBrowser.currentURI.spec.startsWith(test_obj.expected),
|
||||
test_obj.explanation
|
||||
);
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
||||
add_task(async function test_bug1002724() {
|
||||
await SpecialPowers.pushPrefEnv(
|
||||
// Disable HSTS preload just in case.
|
||||
{ set: [["network.stricttransportsecurity.preloadlist", false]] }
|
||||
);
|
||||
|
||||
for (let test of bug1002724_tests) {
|
||||
await test_one(test);
|
||||
}
|
||||
});
|
Загрузка…
Ссылка в новой задаче