⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listsearch.aspx

📁 AJAX 应用 实现页面的无刷新
💻 ASPX
📖 第 1 页 / 共 2 页
字号:
        testHarness = harness;
        
        listBox1 = testHarness.getElement('ctl00_ContentPlaceHolder1_ListBox1');
        extender1 = testHarness.getObject("ListSearchExtender1");
        
        listBox2 = testHarness.getElement('ctl00_ContentPlaceHolder1_ListBox2');
        extender2 = testHarness.getObject("ListSearchExtender2");
               
        dropDownList1 = testHarness.getElement('ctl00_ContentPlaceHolder1_DropDownList1');
        extender3 = testHarness.getObject("ListSearchExtender3");
        
        dropDownList2 = testHarness.getElement('ctl00_ContentPlaceHolder1_DropDownList2');
        extender4 = testHarness.getObject("ListSearchExtender4");
        
        var test = testHarness.addTest("ListBox Focus with default prompt");
        test.addStep( function() { testHarness.fireEvent(listBox2, 'onfocus');checkPrompt(extender2, 'Type to search'); });
        test.addStep( function() { testHarness.fireEvent(listBox2, 'onblur'); testHarness.assertFalse(extender2._promptDiv); });
                
        test = testHarness.addTest("ListBox Focus and blur with custom prompt");
        test.addStep( function() { testHarness.fireEvent(listBox1, 'onfocus');});
        test.addStep( function() { checkPrompt(extender1, 'a'); });
        test.addStep( function() { testHarness.fireEvent(listBox1, 'onblur'); testHarness.assertFalse(extender1._promptDiv); });
        
        test = testHarness.addTest("ListBox Type and delete characters that matches the second element in the list");
        test.addStep( function() { testHarness.fireEvent(listBox1, 'onfocus');});
        test.addStep( function() { checkPrompt(extender1, 'a'); });
        test.addStep( function() { sendKeyAndCheck(extender1, listBox1, 'd', dKey, 'd', 1); });
        test.addStep( function() { sendKeyAndCheck(extender1, listBox1, 'c', cKey, 'dc', 1); });
        test.addStep( function() { sendKeyAndCheck(extender1, listBox1, null, Sys.UI.Key.backspace, 'd', 1); });
        test.addStep( function() { sendKeyAndCheck(extender1, listBox1, null, Sys.UI.Key.backspace, '', 0); });
        test.addStep( function() { testHarness.fireEvent(listBox1, 'onblur'); testHarness.assertFalse(extender1._promptDiv); });
        
        test = testHarness.addTest("ListBox OnChange fires when losing focus");
        test.addStep( function() { attachOnChangeEvent(listBox1); });
        test.addStep( function() { testHarness.fireEvent(listBox1, 'onfocus');});
        test.addStep( function() { sendKeyAndCheck(extender1, listBox1, 'd', dKey, 'd', 1); });
        test.addStep( function() { checkNoOnChange(); });
        test.addStep( function() { testHarness.fireEvent(listBox1, 'onblur'); testHarness.assertFalse(extender1._promptDiv); });
        test.addStep( function() { checkLastOnChange(listBox1); });
        test.addStep( function() { removeOnChangeEvent(listBox1); });
        
        test = testHarness.addTest("ListBox OnChange fires only when enter pressed");
        test.addStep( function() { attachOnChangeEvent(listBox1); });
        test.addStep( function() { testHarness.fireEvent(listBox1, 'onfocus');});
        test.addStep( function() { sendKeyAndCheck(extender1, listBox1, 'd', dKey, 'd', 1); });
        test.addStep( function() { checkNoOnChange(); });
        test.addStep( function() { sendKeyAndCheck(extender1, listBox1, null, Sys.UI.Key.enter, 'd', 1); });
        test.addStep( function() { checkLastOnChange(listBox1); });
        test.addStep( function() { testHarness.fireEvent(listBox1, 'onblur'); testHarness.assertFalse(extender1._promptDiv); });
        test.addStep( function() { removeOnChangeEvent(listBox1); });

        test = testHarness.addTest("ListBox Type and delete & (can't be used for innerHTML)");
        test.addStep( function() { testHarness.fireEvent(listBox2, 'onfocus');});
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, '&', ampKey, '&', 0); });
        test.addStep( function() { testHarness.fireEvent(listBox2, 'onblur'); testHarness.assertFalse(extender2._promptDiv); });

        test = testHarness.addTest("ListBox Check that hitting enter does nothing and escape clears the text typed so far");
        test.addStep( function() { testHarness.fireEvent(listBox2, 'onfocus');});
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'a', aKey, 'a', 1); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, '\n', Sys.UI.Key.enter, 'a', 1); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'a', aKey, 'aa', 3); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'a', aKey, 'aaa', 4); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, null, Sys.UI.Key.esc, '', 0); });
        test.addStep( function() { testHarness.fireEvent(listBox2, 'onblur'); testHarness.assertFalse(extender2._promptDiv); });

        test = testHarness.addTest("ListBox Type and delete characters that closely match elements in the list");
        test.addStep( function() { testHarness.fireEvent(listBox2, 'onfocus');});
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'A', aKey, 'A', 1); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'a', aKey, 'Aa', 3); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'a', aKey, 'Aaa', 4); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, null, Sys.UI.Key.backspace, 'Aa', 3); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, null, Sys.UI.Key.backspace, 'A', 1); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, null, Sys.UI.Key.backspace, '', 0); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'b', bKey, 'b', 5); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'x', xKey, 'bx', 5); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, null, Sys.UI.Key.backspace, 'b', 5); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'c', cKey, 'bc', 6); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'd', dKey, 'bcd', 7); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'a', aKey, 'bcda', 7); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, null, Sys.UI.Key.backspace, 'bcd', 7); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, null, Sys.UI.Key.backspace, 'bc', 6); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, null, Sys.UI.Key.backspace, 'b', 5); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'd', dKey, 'bd', 8); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, null, Sys.UI.Key.backspace, 'b', 5); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, null, Sys.UI.Key.backspace, '', 0); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, 'c', cKey, 'c', 9); });
        test.addStep( function() { sendKeyAndCheck(extender2, listBox2, null, Sys.UI.Key.backspace, '', 0); });
        test.addStep( function() { testHarness.fireEvent(listBox2, 'onblur'); testHarness.assertFalse(extender2._promptDiv); });

        //
        test = testHarness.addTest("DropDownList Focus with default prompt");
        test.addStep( function() { testHarness.fireEvent(dropDownList2, 'onfocus');checkPrompt(extender4, 'Type to search'); });
        test.addStep( function() { testHarness.fireEvent(dropDownList2, 'onblur'); testHarness.assertFalse(extender4._promptDiv); });
                
        test = testHarness.addTest("DropDownList Focus and blur with custom prompt");
        test.addStep( function() { testHarness.fireEvent(dropDownList1, 'onfocus');});
        test.addStep( function() { checkPrompt(extender3, 'a'); });
        test.addStep( function() { testHarness.fireEvent(dropDownList1, 'onblur'); testHarness.assertFalse(extender3._promptDiv); });
        
        test = testHarness.addTest("DropDownList Type and delete characters that matches the second element in the list");
        test.addStep( function() { testHarness.fireEvent(dropDownList1, 'onfocus');});
        test.addStep( function() { checkPrompt(extender3, 'a'); });
        test.addStep( function() { sendKeyAndCheck(extender3, dropDownList1, 'd', dKey, 'd', 1); });
        test.addStep( function() { sendKeyAndCheck(extender3, dropDownList1, 'c', cKey, 'dc', 1); });
        test.addStep( function() { sendKeyAndCheck(extender3, dropDownList1, null, Sys.UI.Key.backspace, 'd', 1); });
        test.addStep( function() { sendKeyAndCheck(extender3, dropDownList1, null, Sys.UI.Key.backspace, '', 0); });
        test.addStep( function() { testHarness.fireEvent(dropDownList1, 'onblur'); testHarness.assertFalse(extender3._promptDiv); });
        
        test = testHarness.addTest("DropDownList OnChange fires when losing focus");
        test.addStep( function() { attachOnChangeEvent(dropDownList1); });
        test.addStep( function() { testHarness.fireEvent(dropDownList1, 'onfocus');});
        test.addStep( function() { sendKeyAndCheck(extender3, dropDownList1, 'd', dKey, 'd', 1); });
        test.addStep( function() { checkNoOnChange(); });
        test.addStep( function() { testHarness.fireEvent(dropDownList1, 'onblur'); testHarness.assertFalse(extender3._promptDiv); });
        test.addStep( function() { checkLastOnChange(dropDownList1); });
        test.addStep( function() { removeOnChangeEvent(dropDownList1); });
        
        test = testHarness.addTest("DropDownList OnChange fires only when enter pressed");
        test.addStep( function() { attachOnChangeEvent(dropDownList1); });
        test.addStep( function() { testHarness.fireEvent(dropDownList1, 'onfocus');});
        test.addStep( function() { sendKeyAndCheck(extender3, dropDownList1, 'd', dKey, 'd', 1); });
        test.addStep( function() { checkNoOnChange(); });
        test.addStep( function() { sendKeyAndCheck(extender3, dropDownList1, null, Sys.UI.Key.enter, 'd', 1); });
        test.addStep( function() { checkLastOnChange(dropDownList1); });
        test.addStep( function() { testHarness.fireEvent(dropDownList1, 'onblur'); testHarness.assertFalse(extender3._promptDiv); });
        test.addStep( function() { removeOnChangeEvent(dropDownList1); });

        test = testHarness.addTest("DropDownList Type and delete & (can't be used for innerHTML)");
        test.addStep( function() { testHarness.fireEvent(dropDownList2, 'onfocus');});
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, '&', ampKey, '&', 0); });
        test.addStep( function() { testHarness.fireEvent(dropDownList2, 'onblur'); testHarness.assertFalse(extender4._promptDiv); });


        test = testHarness.addTest("DropDownList Check that hitting enter does nothing and escape clears the text typed so far");
        test.addStep( function() { testHarness.fireEvent(dropDownList2, 'onfocus');});
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'a', aKey, 'a', 1); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, '\n', Sys.UI.Key.enter, 'a', 1); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'a', aKey, 'aa', 3); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'a', aKey, 'aaa', 4); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, null, Sys.UI.Key.esc, '', 0); });
        test.addStep( function() { testHarness.fireEvent(dropDownList2, 'onblur'); testHarness.assertFalse(extender4._promptDiv); });


        test = testHarness.addTest("DropDownList Type and delete characters that closely match elements in the list");
        test.addStep( function() { testHarness.fireEvent(dropDownList2, 'onfocus');});
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'A', aKey, 'A', 1); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'a', aKey, 'Aa', 3); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'a', aKey, 'Aaa', 4); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, null, Sys.UI.Key.backspace, 'Aa', 3); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, null, Sys.UI.Key.backspace, 'A', 1); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, null, Sys.UI.Key.backspace, '', 0); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'b', bKey, 'b', 5); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'x', xKey, 'bx', 5); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, null, Sys.UI.Key.backspace, 'b', 5); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'c', cKey, 'bc', 6); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'd', dKey, 'bcd', 7); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'a', aKey, 'bcda', 7); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, null, Sys.UI.Key.backspace, 'bcd', 7); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, null, Sys.UI.Key.backspace, 'bc', 6); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, null, Sys.UI.Key.backspace, 'b', 5); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'd', dKey, 'bd', 8); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, null, Sys.UI.Key.backspace, 'b', 5); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, null, Sys.UI.Key.backspace, '', 0); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, 'c', cKey, 'c', 9); });
        test.addStep( function() { sendKeyAndCheck(extender4, dropDownList2, null, Sys.UI.Key.backspace, '', 0); });
        test.addStep( function() { testHarness.fireEvent(dropDownList2, 'onblur'); testHarness.assertFalse(extender4._promptDiv); });

    }

    </script>


</asp:Content>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -