diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/plugins/test/mochitest/test_getauthenticationinfo.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/plugins/test/mochitest/test_getauthenticationinfo.html')
-rw-r--r-- | dom/plugins/test/mochitest/test_getauthenticationinfo.html | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/dom/plugins/test/mochitest/test_getauthenticationinfo.html b/dom/plugins/test/mochitest/test_getauthenticationinfo.html new file mode 100644 index 000000000..f249386c7 --- /dev/null +++ b/dom/plugins/test/mochitest/test_getauthenticationinfo.html @@ -0,0 +1,81 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test for Login Manager</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="plugin-utils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +Test for NPN_GetAuthenticationInfo +<p id="display"></p> + +<div id="content"> + <iframe id="iframe"></iframe> +</div> + +<script class="testbody" type="text/javascript"> + +const Ci = SpecialPowers.Ci; +const Cc = SpecialPowers.Cc; + +function iframeLoad() { + var plugin = iframe.contentDocument.getElementById("embedtest"); + // valid request + is(plugin.getAuthInfo("http", "mochi.test", 8888, "basic", "testrealm"), + "user1|password1", + "correct user/pass retrieved"); + try { + // invalid request -- wrong host + is(plugin.getAuthInfo("http", "example.com", 8888, "basic", "testrealm"), + "user1|password1", + "correct user/pass retrieved"); + ok(false, "no exception was thrown"); + } + catch (err) { + ok(true, "expected exception caught"); + } + try { + // invalid request -- wrong port + is(plugin.getAuthInfo("http", "mochi.test", 90, "basic", "testrealm"), + "user1|password1", + "correct user/pass retrieved"); + ok(false, "no exception was thrown"); + } + catch (err) { + ok(true, "expected exception caught"); + } + try { + // invalid request -- wrong realm + is(plugin.getAuthInfo("http", "mochi.test", 8888, "basic", "wrongrealm"), + "user1|password1", + "correct user/pass retrieved"); + ok(false, "no exception was thrown"); + } + catch (err) { + ok(true, "expected exception caught"); + } + SimpleTest.finish(); +} + +SimpleTest.waitForExplicitFinish(); +setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); + +// Authentication info is added twice here. In the non-e10s case, this does +// nothing. In the e10s case, we need to add auth info in both the child process, +// which the plugin checks for auth validity, and the parent process, which the +// http network objects use. +// TODO: Clean this up once HTTPAuthManager is made e10s compliant in bug 1249172 +var iframe = document.getElementById("iframe"); +var am = Cc["@mozilla.org/network/http-auth-manager;1"]. + getService(Ci.nsIHttpAuthManager); +am.setAuthIdentity("http", "mochi.test", 8888, "basic", "testrealm", "", + "mochi.test", "user1", "password1"); +SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("file_authident.js")); +iframe.onload = iframeLoad; +iframe.src = "http://mochi.test:8888/tests/toolkit/components/passwordmgr/" + + "test/authenticate.sjs?user=user1&pass=password1&realm=testrealm&plugin=1"; + +</script> +</body> +</html> |