Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!--This test should be updated each time new functionality is added to SimpleTest--> |
michael@0 | 2 | <!DOCTYPE HTML> |
michael@0 | 3 | <html> |
michael@0 | 4 | <head> |
michael@0 | 5 | <title>Profiling test suite for SimpleTest</title> |
michael@0 | 6 | <script type="text/javascript"> |
michael@0 | 7 | var start = new Date(); |
michael@0 | 8 | </script> |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 11 | <script type="text/javascript"> |
michael@0 | 12 | var loadTime = new Date(); |
michael@0 | 13 | </script> |
michael@0 | 14 | </head> |
michael@0 | 15 | <body> |
michael@0 | 16 | <input id="textB"/> |
michael@0 | 17 | <script class="testbody" type="text/javascript"> |
michael@0 | 18 | info("Profile::SimpleTestLoadTime: " + (loadTime - start)); |
michael@0 | 19 | var startTime = new Date(); |
michael@0 | 20 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 21 | function starttest() { |
michael@0 | 22 | SimpleTest.waitForFocus( |
michael@0 | 23 | function() { |
michael@0 | 24 | //test log |
michael@0 | 25 | info("Logging some info") |
michael@0 | 26 | |
michael@0 | 27 | //basic usage |
michael@0 | 28 | ok(true, "test ok", "This should be true"); |
michael@0 | 29 | is(0, 0, "is() test failed"); |
michael@0 | 30 | isnot(0, 1, "isnot() test failed"); |
michael@0 | 31 | |
michael@0 | 32 | //todo tests |
michael@0 | 33 | todo(false, "test todo", "todo() test should not pass"); |
michael@0 | 34 | todo_is(false, true, "test todo_is"); |
michael@0 | 35 | todo_isnot(true, true, "test todo_isnot"); |
michael@0 | 36 | |
michael@0 | 37 | //misc |
michael@0 | 38 | is(typeof(SimpleTest.testPluginIsOOP()), "boolean", 'testPluginIsOOP should be bool'); |
michael@0 | 39 | SimpleTest.requestLongerTimeout(1); |
michael@0 | 40 | |
michael@0 | 41 | //note: this test may alter runtimes as it waits |
michael@0 | 42 | var check = false; |
michael@0 | 43 | $('textB').focus(); |
michael@0 | 44 | SimpleTest.waitForClipboard("a", |
michael@0 | 45 | function () { |
michael@0 | 46 | SpecialPowers.clipboardCopyString("a"); |
michael@0 | 47 | }, |
michael@0 | 48 | function () { |
michael@0 | 49 | check = true; |
michael@0 | 50 | }, |
michael@0 | 51 | function () { |
michael@0 | 52 | check = false; |
michael@0 | 53 | } |
michael@0 | 54 | ); |
michael@0 | 55 | is(check, true, "waitForClipboard should work"); |
michael@0 | 56 | |
michael@0 | 57 | //use helper functions |
michael@0 | 58 | var div1 = createEl('div', {'id': 'somediv', 'display': 'block'}, "I am a div"); |
michael@0 | 59 | document.body.appendChild(div1); |
michael@0 | 60 | var divObj = this.getElement('somediv'); |
michael@0 | 61 | is(divObj, div1, 'createEl did not create element as expected'); |
michael@0 | 62 | is($('somediv'), divObj, '$ helper did not get element as expected'); |
michael@0 | 63 | is(computedStyle(divObj, 'display'), 'block', 'computedStyle did not get right display value'); |
michael@0 | 64 | document.body.removeChild(div1); |
michael@0 | 65 | |
michael@0 | 66 | /* note: expectChildProcessCrash is not being tested here, as it causes wildly variable |
michael@0 | 67 | * run times. It is currently being tested in: |
michael@0 | 68 | * dom/plugins/test/test_hanging.html and dom/plugins/test/test_crashing.html |
michael@0 | 69 | */ |
michael@0 | 70 | |
michael@0 | 71 | //note: this also adds a short wait period |
michael@0 | 72 | SimpleTest.executeSoon( |
michael@0 | 73 | function () { |
michael@0 | 74 | //finish() calls a slew of SimpleTest functions |
michael@0 | 75 | SimpleTest.finish(); |
michael@0 | 76 | //call this after finish so we can make sure it works and doesn't hang our process |
michael@0 | 77 | var endTime = new Date(); |
michael@0 | 78 | info("Profile::SimpleTestRunTime: " + (endTime-startTime)); |
michael@0 | 79 | //expect and throw exception here. Otherwise, any code that follows the throw call will never be executed |
michael@0 | 80 | SimpleTest.expectUncaughtException(); |
michael@0 | 81 | //make sure we catch this error |
michael@0 | 82 | throw "i am an uncaught exception" |
michael@0 | 83 | } |
michael@0 | 84 | ); |
michael@0 | 85 | } |
michael@0 | 86 | ); |
michael@0 | 87 | }; |
michael@0 | 88 | //use addLoadEvent |
michael@0 | 89 | addLoadEvent( |
michael@0 | 90 | function() { |
michael@0 | 91 | starttest(); |
michael@0 | 92 | } |
michael@0 | 93 | ); |
michael@0 | 94 | </script> |
michael@0 | 95 | </body> |
michael@0 | 96 | </html> |