📄 passwordstrength.aspx
字号:
<%@ Page
Language="C#"
MasterPageFile="~/Default.master"
CodeFile="PasswordStrength.aspx.cs"
Inherits="Automated_PasswordStrength"
Title="PasswordStrength Tests" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<asp:Label ID="helpLabel" runat="server"></asp:Label><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
<asp:Label ID="helpLabel2" runat="server"></asp:Label>
<ajaxToolkit:PasswordStrength ID="p1" runat="server" TargetControlID="TextBox1" PreferredPasswordLength="10" HelpStatusLabelID="helpLabel" />
<ajaxToolkit:PasswordStrength ID="p2" runat="server" TargetControlID="TextBox2" PreferredPasswordLength="10" HelpStatusLabelID="helpLabel2" MinimumNumericCharacters="1" MinimumSymbolCharacters="1" RequiresUpperAndLowerCaseCharacters="true" StrengthIndicatorType="BarIndicator" />
<script type="text/javascript">
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.
// Script objects that should be loaded before we run
var typeDependencies = ['AjaxControlToolkit.PasswordStrengthExtenderBehavior'];
// Test Harness
var testHarness = null;
// Controls in the page
var tb1 = null;
var tb1_indicator = null;
var tb1_helpLabel = null;
var tb2 = null;
var tb2_indicator1 = null;
var tb2_indicator2 = null;
var tb2_helpLabel = null;
// Ensure the textbox and strength indicator is in its empty/initial state
function checkEmptyState() {
testHarness.assertEqual('', tb1_helpLabel.innerHTML, "TextBox1's Strength help text should be an empty string instead of '" + tb1_helpLabel.innerHTML + "'");
testHarness.assertTrue(tb1_indicator.style.display == '' || tb1_indicator.style.display == 'none', "TextBox1's Strength Indicator display style should be 'none' instead of '" + tb1_indicator.style.display + "'");
testHarness.assertEqual('hidden', tb1_indicator.style.visibility, "TextBox1's Strength Indicator visibility style should be 'hidden' or an empty string instead of '" + tb1_indicator.style.visibility + "'");
testHarness.assertEqual('', tb2_helpLabel.innerHTML, "TextBox2's Strength help text should be an empty string instead of '" + tb2_helpLabel.innerHTML + "'");
testHarness.assertTrue(tb2_indicator1.style.display == '' || tb2_indicator1.style.display == 'none', "TextBox2's Strength Indicator display style should be 'none' instead of '" + tb2_indicator1.style.display + "'");
testHarness.assertEqual('hidden', tb2_indicator1.style.visibility, "TextBox2's Strength Indicator visibility style should be 'hidden' or an empty string instead of '" + tb2_indicator1.style.visibility + "'");
testHarness.assertTrue(tb2_indicator2.style.display == '' || tb2_indicator2.style.display == 'none', "TextBox2's Strength Indicator display style should be 'none' instead of '" + tb2_indicator2.style.display + "'");
testHarness.assertEqual('hidden', tb2_indicator2.style.visibility, "TextBox2's Strength Indicator visibility style should be 'hidden' or an empty string instead of '" + tb2_indicator2.style.visibility + "'");
}
// Reset the controls to their initial state
function resetControlState() {
tb1.value = '';
tb2.value = '';
tb1.readOnly = false;
tb2.readOnly = false;
tb1_helpLabel.innerHTML = '';
tb1_indicator.style.display = 'none';
tb1_indicator.style.visibility = 'hidden';
tb2_helpLabel.innerHTML = '';
tb2_indicator1.style.display = 'none';
tb2_indicator1.style.visibility = 'hidden';
tb2_indicator2.style.display = 'none';
tb2_indicator2.style.visibility = 'hidden';
testHarness.fireEvent(tb1, 'onBlur');
testHarness.fireEvent(tb2, 'onblur');
}
// Test the initial state of the control
function testInitialState() {
checkEmptyState();
}
// Test entering some data (not a strong password) into the control for a textual indicator
function testPartialKeyPress() {
tb1.value = '123';
testHarness.fireEvent(tb1, 'onkeyup');
testHarness.assertNotEqual('', tb1_helpLabel.innerHTML, "TextBox1's Strength help text should NOT be empty instead of '" + tb1_helpLabel.innerHTML + "'");
testHarness.assertNotEqual('none', tb1_indicator.style.display, "TextBox1's Strength Indicator display style should NOT be 'none'");
testHarness.assertNotEqual('', tb1.value, "TextBox1's value should NOT be an empty string");
testHarness.assertEqual('visible', tb1_indicator.style.visibility, "TextBox1's Strength Indicator visibility style should be 'visible' instead of '" + tb1_indicator.style.visibility + "'");
}
// Test entering some data (not a strong password) into the control for a bar indicator
function testPartialKeyPress2() {
tb2.value = '123';
testHarness.fireEvent(tb2, 'onkeyup');
testHarness.assertNotEqual('', tb2_helpLabel.innerHTML, "TextBox2's Strength help text should NOT be empty instead of '" + tb2_helpLabel.innerHTML + "'");
testHarness.assertNotEqual('', tb2.value, "TextBox2's value should NOT be an empty string");
testHarness.assertNotEqual('none', tb2_indicator1.style.display, "TextBox2's Strength Indicator display style should NOT be 'none'");
testHarness.assertEqual('visible', tb2_indicator1.style.visibility, "TextBox2's Strength Indicator visibility style should be 'visible' instead of '" + tb2_indicator1.style.visibility + "'");
testHarness.assertNotEqual('none', tb2_indicator2.style.display, "TextBox2's Strength Indicator display style should NOT be 'none'");
testHarness.assertEqual('visible', tb2_indicator2.style.visibility, "TextBox2's Strength Indicator visibility style should be 'visible' instead of '" + tb2_indicator2.style.visibility + "'");
}
// Test removing focus from the control with only some characters entered for a textual indicator
function testPartialEntryBlur() {
testHarness.fireEvent(tb1, 'onblur');
testHarness.assertNotEqual('', tb1_helpLabel.innerHTML, "TextBox1's Strength help text should NOT be an empty string instead of '" + tb1_helpLabel.innerHTML + "'");
testHarness.assertTrue(tb1_indicator.style.display == '' || tb1_indicator.style.display == 'none', "TextBox1's Strength Indicator display style should be 'none' or an empty string instead of '" + tb1_indicator.style.display + "'");
testHarness.assertEqual('hidden', tb1_indicator.style.visibility, "TextBox1's Strength Indicator visibility style should be 'hidden' or an empty string instead of '" + tb1_indicator.style.visibility + "'");
}
// Test removing focus from the control with only some characters entered for a textual indicator
function testPartialEntryBlur2() {
testHarness.fireEvent(tb2, 'onblur');
testHarness.assertNotEqual('', tb2_helpLabel.innerHTML, "TextBox2's Strength help text should NOT be an empty string instead of '" + tb2_helpLabel.innerHTML + "'");
testHarness.assertTrue(tb2_indicator1.style.display == '' || tb2_indicator1.style.display == 'none', "TextBox2's Strength Indicator display style should be 'none' or an empty string instead of '" + tb2_indicator1.style.display + "'");
testHarness.assertEqual('hidden', tb2_indicator1.style.visibility, "TextBox2's Strength Indicator visibility style should be 'hidden' or an empty string instead of '" + tb2_indicator1.style.visibility + "'");
testHarness.assertTrue(tb2_indicator2.style.display == '' || tb2_indicator2.style.display == 'none', "TextBox2's Strength Indicator display style should be 'none' or an empty string instead of '" + tb2_indicator2.style.display + "'");
testHarness.assertEqual('hidden', tb2_indicator2.style.visibility, "TextBox2's Strength Indicator visibility style should be 'hidden' or an empty string instead of '" + tb2_indicator2.style.visibility + "'");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -