selenium-webdriver 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. data/{common/src/rb/CHANGES → CHANGES} +13 -0
  2. data/{common/src/rb/README → README} +1 -1
  3. data/{common/src/rb/lib → lib}/selenium-webdriver.rb +0 -0
  4. data/{common/src/rb/lib → lib}/selenium/webdriver.rb +2 -1
  5. data/{common/src/rb/lib → lib}/selenium/webdriver/bridge_helper.rb +0 -0
  6. data/{common/src/rb/lib → lib}/selenium/webdriver/child_process.rb +0 -0
  7. data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome.rb +0 -0
  8. data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/bridge.rb +2 -2
  9. data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/command_executor.rb +0 -0
  10. data/lib/selenium/webdriver/chrome/extension.zip +0 -0
  11. data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/launcher.rb +26 -20
  12. data/{common/src/rb/lib → lib}/selenium/webdriver/core_ext/dir.rb +0 -0
  13. data/{common/src/rb/lib → lib}/selenium/webdriver/core_ext/string.rb +0 -0
  14. data/{common/src/rb/lib → lib}/selenium/webdriver/driver.rb +0 -0
  15. data/{common/src/rb/lib → lib}/selenium/webdriver/driver_extensions/takes_screenshot.rb +0 -0
  16. data/{common/src/rb/lib → lib}/selenium/webdriver/element.rb +0 -0
  17. data/{common/src/rb/lib → lib}/selenium/webdriver/error.rb +0 -0
  18. data/{common/src/rb/lib → lib}/selenium/webdriver/file_reaper.rb +2 -1
  19. data/{common/src/rb/lib → lib}/selenium/webdriver/find.rb +0 -0
  20. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox.rb +2 -1
  21. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/binary.rb +32 -6
  22. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/bridge.rb +0 -0
  23. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  24. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/launcher.rb +0 -0
  25. data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
  26. data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
  27. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/profile.rb +37 -72
  28. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/profiles_ini.rb +0 -0
  29. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/util.rb +0 -0
  30. data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie.rb +2 -2
  31. data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/bridge.rb +7 -2
  32. data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/lib.rb +0 -0
  33. data/{jobbie/prebuilt/Win32/Release → lib/selenium/webdriver/ie/native/win32}/InternetExplorerDriver.dll +0 -0
  34. data/lib/selenium/webdriver/ie/native/x64/InternetExplorerDriver.dll +0 -0
  35. data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/util.rb +0 -0
  36. data/{common/src/rb/lib → lib}/selenium/webdriver/keys.rb +0 -0
  37. data/{common/src/rb/lib → lib}/selenium/webdriver/navigation.rb +0 -0
  38. data/{common/src/rb/lib → lib}/selenium/webdriver/options.rb +0 -0
  39. data/{common/src/rb/lib → lib}/selenium/webdriver/platform.rb +5 -1
  40. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote.rb +0 -0
  41. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/bridge.rb +0 -0
  42. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/capabilities.rb +0 -0
  43. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/commands.rb +0 -0
  44. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/common.rb +0 -0
  45. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/curb.rb +0 -0
  46. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/default.rb +5 -1
  47. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/response.rb +0 -0
  48. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/server_error.rb +0 -0
  49. data/{common/src/rb/lib → lib}/selenium/webdriver/target_locator.rb +0 -0
  50. data/{common/src/rb/lib → lib}/selenium/webdriver/timeouts.rb +0 -0
  51. data/lib/selenium/webdriver/zip_helper.rb +30 -0
  52. metadata +73 -214
  53. data/COPYING +0 -204
  54. data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
  55. data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
  56. data/chrome/src/extension/background.html +0 -9
  57. data/chrome/src/extension/background.js +0 -1029
  58. data/chrome/src/extension/content_script.js +0 -1488
  59. data/chrome/src/extension/icons/busy.png +0 -0
  60. data/chrome/src/extension/icons/free.png +0 -0
  61. data/chrome/src/extension/manifest-nonwin.json +0 -19
  62. data/chrome/src/extension/manifest-win.json +0 -20
  63. data/chrome/src/extension/utils.js +0 -231
  64. data/common/src/js/abstractcommandprocessor.js +0 -132
  65. data/common/src/js/asserts.js +0 -296
  66. data/common/src/js/by.js +0 -149
  67. data/common/src/js/command.js +0 -380
  68. data/common/src/js/core/Blank.html +0 -7
  69. data/common/src/js/core/InjectedRemoteRunner.html +0 -8
  70. data/common/src/js/core/RemoteRunner.html +0 -101
  71. data/common/src/js/core/SeleniumLog.html +0 -109
  72. data/common/src/js/core/TestPrompt.html +0 -145
  73. data/common/src/js/core/TestRunner-splash.html +0 -55
  74. data/common/src/js/core/TestRunner.html +0 -165
  75. data/common/src/js/core/icons/all.png +0 -0
  76. data/common/src/js/core/icons/continue.png +0 -0
  77. data/common/src/js/core/icons/continue_disabled.png +0 -0
  78. data/common/src/js/core/icons/pause.png +0 -0
  79. data/common/src/js/core/icons/pause_disabled.png +0 -0
  80. data/common/src/js/core/icons/selected.png +0 -0
  81. data/common/src/js/core/icons/step.png +0 -0
  82. data/common/src/js/core/icons/step_disabled.png +0 -0
  83. data/common/src/js/core/lib/cssQuery/cssQuery-p.js +0 -6
  84. data/common/src/js/core/lib/cssQuery/src/cssQuery-level2.js +0 -142
  85. data/common/src/js/core/lib/cssQuery/src/cssQuery-level3.js +0 -150
  86. data/common/src/js/core/lib/cssQuery/src/cssQuery-standard.js +0 -53
  87. data/common/src/js/core/lib/cssQuery/src/cssQuery.js +0 -356
  88. data/common/src/js/core/lib/prototype.js +0 -2006
  89. data/common/src/js/core/lib/scriptaculous/builder.js +0 -101
  90. data/common/src/js/core/lib/scriptaculous/controls.js +0 -815
  91. data/common/src/js/core/lib/scriptaculous/dragdrop.js +0 -915
  92. data/common/src/js/core/lib/scriptaculous/effects.js +0 -958
  93. data/common/src/js/core/lib/scriptaculous/scriptaculous.js +0 -47
  94. data/common/src/js/core/lib/scriptaculous/slider.js +0 -283
  95. data/common/src/js/core/lib/scriptaculous/unittest.js +0 -383
  96. data/common/src/js/core/lib/snapsie.js +0 -91
  97. data/common/src/js/core/scripts/find_matching_child.js +0 -69
  98. data/common/src/js/core/scripts/htmlutils.js +0 -8716
  99. data/common/src/js/core/scripts/injection.html +0 -72
  100. data/common/src/js/core/scripts/selenium-api.js +0 -3291
  101. data/common/src/js/core/scripts/selenium-browserbot.js +0 -2457
  102. data/common/src/js/core/scripts/selenium-browserdetect.js +0 -153
  103. data/common/src/js/core/scripts/selenium-commandhandlers.js +0 -379
  104. data/common/src/js/core/scripts/selenium-executionloop.js +0 -175
  105. data/common/src/js/core/scripts/selenium-logging.js +0 -148
  106. data/common/src/js/core/scripts/selenium-remoterunner.js +0 -695
  107. data/common/src/js/core/scripts/selenium-testrunner.js +0 -1362
  108. data/common/src/js/core/scripts/selenium-version.js +0 -5
  109. data/common/src/js/core/scripts/ui-doc.html +0 -808
  110. data/common/src/js/core/scripts/ui-element.js +0 -1644
  111. data/common/src/js/core/scripts/ui-map-sample.js +0 -979
  112. data/common/src/js/core/scripts/user-extensions.js +0 -3
  113. data/common/src/js/core/scripts/user-extensions.js.sample +0 -75
  114. data/common/src/js/core/scripts/xmlextras.js +0 -153
  115. data/common/src/js/core/selenium-logo.png +0 -0
  116. data/common/src/js/core/selenium-test.css +0 -43
  117. data/common/src/js/core/selenium.css +0 -316
  118. data/common/src/js/core/xpath/dom.js +0 -566
  119. data/common/src/js/core/xpath/javascript-xpath-0.1.11.js +0 -2816
  120. data/common/src/js/core/xpath/util.js +0 -549
  121. data/common/src/js/core/xpath/xmltoken.js +0 -149
  122. data/common/src/js/core/xpath/xpath.js +0 -2481
  123. data/common/src/js/extension/README +0 -2
  124. data/common/src/js/extension/dommessenger.js +0 -152
  125. data/common/src/js/factory.js +0 -55
  126. data/common/src/js/future.js +0 -141
  127. data/common/src/js/jsunit.js +0 -40
  128. data/common/src/js/jsunit/app/css/jsUnitStyle.css +0 -50
  129. data/common/src/js/jsunit/app/css/readme +0 -10
  130. data/common/src/js/jsunit/app/emptyPage.html +0 -11
  131. data/common/src/js/jsunit/app/jsUnitCore.js +0 -534
  132. data/common/src/js/jsunit/app/jsUnitMockTimeout.js +0 -81
  133. data/common/src/js/jsunit/app/jsUnitTestManager.js +0 -705
  134. data/common/src/js/jsunit/app/jsUnitTestSuite.js +0 -44
  135. data/common/src/js/jsunit/app/jsUnitTracer.js +0 -102
  136. data/common/src/js/jsunit/app/jsUnitVersionCheck.js +0 -59
  137. data/common/src/js/jsunit/app/main-counts-errors.html +0 -12
  138. data/common/src/js/jsunit/app/main-counts-failures.html +0 -13
  139. data/common/src/js/jsunit/app/main-counts-runs.html +0 -13
  140. data/common/src/js/jsunit/app/main-counts.html +0 -21
  141. data/common/src/js/jsunit/app/main-data.html +0 -178
  142. data/common/src/js/jsunit/app/main-errors.html +0 -23
  143. data/common/src/js/jsunit/app/main-frame.html +0 -19
  144. data/common/src/js/jsunit/app/main-loader.html +0 -45
  145. data/common/src/js/jsunit/app/main-progress.html +0 -25
  146. data/common/src/js/jsunit/app/main-results.html +0 -67
  147. data/common/src/js/jsunit/app/main-status.html +0 -13
  148. data/common/src/js/jsunit/app/testContainer.html +0 -16
  149. data/common/src/js/jsunit/app/testContainerController.html +0 -77
  150. data/common/src/js/jsunit/app/xbDebug.js +0 -306
  151. data/common/src/js/jsunit/changelog.txt +0 -60
  152. data/common/src/js/jsunit/css/jsUnitStyle.css +0 -83
  153. data/common/src/js/jsunit/images/green.gif +0 -0
  154. data/common/src/js/jsunit/images/logo_jsunit.gif +0 -0
  155. data/common/src/js/jsunit/images/powerby-transparent.gif +0 -0
  156. data/common/src/js/jsunit/images/red.gif +0 -0
  157. data/common/src/js/jsunit/licenses/JDOM_license.txt +0 -56
  158. data/common/src/js/jsunit/licenses/Jetty_license.html +0 -213
  159. data/common/src/js/jsunit/licenses/MPL-1.1.txt +0 -470
  160. data/common/src/js/jsunit/licenses/gpl-2.txt +0 -340
  161. data/common/src/js/jsunit/licenses/index.html +0 -141
  162. data/common/src/js/jsunit/licenses/lgpl-2.1.txt +0 -504
  163. data/common/src/js/jsunit/licenses/mpl-tri-license-c.txt +0 -35
  164. data/common/src/js/jsunit/licenses/mpl-tri-license-html.txt +0 -35
  165. data/common/src/js/jsunit/readme.txt +0 -19
  166. data/common/src/js/jsunit/testRunner.html +0 -167
  167. data/common/src/js/jsunit/version.txt +0 -1
  168. data/common/src/js/key.js +0 -117
  169. data/common/src/js/localcommandprocessor.js +0 -171
  170. data/common/src/js/testcase.js +0 -219
  171. data/common/src/js/timing.js +0 -89
  172. data/common/src/js/webdriver.js +0 -860
  173. data/common/src/js/webelement.js +0 -483
  174. data/firefox/prebuilt/Win32/Release/webdriver-firefox.dll +0 -0
  175. data/firefox/prebuilt/amd64/libnoblur64.so +0 -0
  176. data/firefox/prebuilt/i386/libnoblur.so +0 -0
  177. data/firefox/prebuilt/linux/Release/libwebdriver-firefox.so +0 -0
  178. data/firefox/prebuilt/linux64/Release/libwebdriver-firefox.so +0 -0
  179. data/firefox/prebuilt/nsICommandProcessor.xpt +0 -0
  180. data/firefox/prebuilt/nsINativeEvents.xpt +0 -0
  181. data/firefox/prebuilt/nsIResponseHandler.xpt +0 -0
  182. data/firefox/src/extension/chrome.manifest +0 -3
  183. data/firefox/src/extension/components/badCertListener.js +0 -295
  184. data/firefox/src/extension/components/dispatcher.js +0 -495
  185. data/firefox/src/extension/components/driver-component.js +0 -130
  186. data/firefox/src/extension/components/errorcode.js +0 -70
  187. data/firefox/src/extension/components/firefoxDriver.js +0 -831
  188. data/firefox/src/extension/components/json2.js +0 -273
  189. data/firefox/src/extension/components/keytest.html +0 -554
  190. data/firefox/src/extension/components/nsCommandProcessor.js +0 -684
  191. data/firefox/src/extension/components/promptService.js +0 -208
  192. data/firefox/src/extension/components/request.js +0 -219
  193. data/firefox/src/extension/components/response.js +0 -276
  194. data/firefox/src/extension/components/screenshooter.js +0 -81
  195. data/firefox/src/extension/components/session.js +0 -314
  196. data/firefox/src/extension/components/sessionstore.js +0 -226
  197. data/firefox/src/extension/components/socketListener.js +0 -435
  198. data/firefox/src/extension/components/utils.js +0 -1335
  199. data/firefox/src/extension/components/webLoadingListener.js +0 -57
  200. data/firefox/src/extension/components/webdriverserver.js +0 -110
  201. data/firefox/src/extension/components/wrappedElement.js +0 -706
  202. data/firefox/src/extension/content/fxdriver.xul +0 -30
  203. data/firefox/src/extension/content/server.js +0 -95
  204. data/firefox/src/extension/idl/nsICommandProcessor.idl +0 -38
  205. data/firefox/src/extension/idl/nsIResponseHandler.idl +0 -34
  206. data/firefox/src/extension/install.rdf +0 -29
  207. data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
@@ -1,81 +0,0 @@
1
- // Mock setTimeout, clearTimeout
2
- // Contributed by Pivotal Computer Systems, www.pivotalsf.com
3
-
4
- var Clock = {
5
- timeoutsMade: 0,
6
- scheduledFunctions: {},
7
- nowMillis: 0,
8
- reset: function() {
9
- this.scheduledFunctions = {};
10
- this.nowMillis = 0;
11
- this.timeoutsMade = 0;
12
- },
13
- tick: function(millis) {
14
- var oldMillis = this.nowMillis;
15
- var newMillis = oldMillis + millis;
16
- this.runFunctionsWithinRange(oldMillis, newMillis);
17
- this.nowMillis = newMillis;
18
- },
19
- runFunctionsWithinRange: function(oldMillis, nowMillis) {
20
- var scheduledFunc;
21
- var funcsToRun = [];
22
- for (var timeoutKey in this.scheduledFunctions) {
23
- scheduledFunc = this.scheduledFunctions[timeoutKey];
24
- if (scheduledFunc != undefined &&
25
- scheduledFunc.runAtMillis >= oldMillis &&
26
- scheduledFunc.runAtMillis <= nowMillis) {
27
- funcsToRun.push(scheduledFunc);
28
- this.scheduledFunctions[timeoutKey] = undefined;
29
- }
30
- }
31
-
32
- if (funcsToRun.length > 0) {
33
- funcsToRun.sort(function(a, b) {
34
- return a.runAtMillis - b.runAtMillis;
35
- });
36
- for (var i = 0; i < funcsToRun.length; ++i) {
37
- try {
38
- this.nowMillis = funcsToRun[i].runAtMillis;
39
- funcsToRun[i].funcToCall();
40
- if (funcsToRun[i].recurring) {
41
- Clock.scheduleFunction(funcsToRun[i].timeoutKey,
42
- funcsToRun[i].funcToCall,
43
- funcsToRun[i].millis,
44
- true);
45
- }
46
- } catch(e) {
47
- }
48
- }
49
- this.runFunctionsWithinRange(oldMillis, nowMillis);
50
- }
51
- },
52
- scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
53
- Clock.scheduledFunctions[timeoutKey] = {
54
- runAtMillis: Clock.nowMillis + millis,
55
- funcToCall: funcToCall,
56
- recurring: recurring,
57
- timeoutKey: timeoutKey,
58
- millis: millis
59
- };
60
- }
61
- };
62
-
63
- function setTimeout(funcToCall, millis) {
64
- Clock.timeoutsMade = Clock.timeoutsMade + 1;
65
- Clock.scheduleFunction(Clock.timeoutsMade, funcToCall, millis, false);
66
- return Clock.timeoutsMade;
67
- }
68
-
69
- function setInterval(funcToCall, millis) {
70
- Clock.timeoutsMade = Clock.timeoutsMade + 1;
71
- Clock.scheduleFunction(Clock.timeoutsMade, funcToCall, millis, true);
72
- return Clock.timeoutsMade;
73
- }
74
-
75
- function clearTimeout(timeoutKey) {
76
- Clock.scheduledFunctions[timeoutKey] = undefined;
77
- }
78
-
79
- function clearInterval(timeoutKey) {
80
- Clock.scheduledFunctions[timeoutKey] = undefined;
81
- }
@@ -1,705 +0,0 @@
1
- function jsUnitTestManager() {
2
- this._windowForAllProblemMessages = null;
3
-
4
- this.container = top.frames.testContainer
5
- this.documentLoader = top.frames.documentLoader;
6
- this.mainFrame = top.frames.mainFrame;
7
-
8
- this.containerController = this.container.frames.testContainerController;
9
- this.containerTestFrame = this.container.frames.testFrame;
10
-
11
- var mainData = this.mainFrame.frames.mainData;
12
-
13
- // form elements on mainData frame
14
- this.testFileName = mainData.document.testRunnerForm.testFileName;
15
- this.runButton = mainData.document.testRunnerForm.runButton;
16
- this.traceLevel = mainData.document.testRunnerForm.traceLevel;
17
- this.closeTraceWindowOnNewRun = mainData.document.testRunnerForm.closeTraceWindowOnNewRun;
18
- this.timeout = mainData.document.testRunnerForm.timeout;
19
- this.setUpPageTimeout = mainData.document.testRunnerForm.setUpPageTimeout;
20
-
21
- // image output
22
- this.progressBar = this.mainFrame.frames.mainProgress.document.progress;
23
-
24
- this.problemsListField = this.mainFrame.frames.mainErrors.document.testRunnerForm.problemsList;
25
- this.testCaseResultsField = this.mainFrame.frames.mainResults.document.resultsForm.testCases;
26
- this.resultsTimeField = this.mainFrame.frames.mainResults.document.resultsForm.time;
27
-
28
- // 'layer' output frames
29
- this.uiFrames = new Object();
30
- this.uiFrames.mainStatus = this.mainFrame.frames.mainStatus;
31
-
32
- var mainCounts = this.mainFrame.frames.mainCounts;
33
-
34
- this.uiFrames.mainCountsErrors = mainCounts.frames.mainCountsErrors;
35
- this.uiFrames.mainCountsFailures = mainCounts.frames.mainCountsFailures;
36
- this.uiFrames.mainCountsRuns = mainCounts.frames.mainCountsRuns;
37
- this._baseURL = "";
38
-
39
- this.setup();
40
- }
41
-
42
- // seconds to wait for each test page to load
43
- jsUnitTestManager.TESTPAGE_WAIT_SEC = 120;
44
- jsUnitTestManager.TIMEOUT_LENGTH = 20;
45
-
46
- // seconds to wait for setUpPage to complete
47
- jsUnitTestManager.SETUPPAGE_TIMEOUT = 120;
48
-
49
- // milliseconds to wait between polls on setUpPages
50
- jsUnitTestManager.SETUPPAGE_INTERVAL = 100;
51
-
52
- jsUnitTestManager.RESTORED_HTML_DIV_ID = "jsUnitRestoredHTML";
53
-
54
- jsUnitTestManager.prototype.setup = function () {
55
- this.totalCount = 0;
56
- this.errorCount = 0;
57
- this.failureCount = 0;
58
- this._suiteStack = Array();
59
-
60
- var initialSuite = new top.jsUnitTestSuite();
61
- push(this._suiteStack, initialSuite);
62
- }
63
-
64
- jsUnitTestManager.prototype.start = function () {
65
- this._baseURL = this.resolveUserEnteredTestFileName();
66
- var firstQuery = this._baseURL.indexOf("?");
67
- if (firstQuery >= 0) {
68
- this._baseURL = this._baseURL.substring(0, firstQuery);
69
- }
70
- var lastSlash = this._baseURL.lastIndexOf("/");
71
- var lastRevSlash = this._baseURL.lastIndexOf("\\");
72
- if (lastRevSlash > lastSlash) {
73
- lastSlash = lastRevSlash;
74
- }
75
- if (lastSlash > 0) {
76
- this._baseURL = this._baseURL.substring(0, lastSlash + 1);
77
- }
78
-
79
- this._timeRunStarted = new Date();
80
- this.initialize();
81
- setTimeout('top.testManager._nextPage();', jsUnitTestManager.TIMEOUT_LENGTH);
82
- }
83
-
84
- jsUnitTestManager.prototype.getBaseURL = function () {
85
- return this._baseURL;
86
- }
87
-
88
- jsUnitTestManager.prototype.doneLoadingPage = function (pageName) {
89
- //this.containerTestFrame.setTracer(top.tracer);
90
- this._testFileName = pageName;
91
- if (this.isTestPageSuite())
92
- this._handleNewSuite();
93
- else
94
- {
95
- this._testIndex = 0;
96
- this._testsInPage = this.getTestFunctionNames();
97
- this._numberOfTestsInPage = this._testsInPage.length;
98
- this._runTest();
99
- }
100
- }
101
-
102
- jsUnitTestManager.prototype._handleNewSuite = function () {
103
- var allegedSuite = this.containerTestFrame.suite();
104
- if (allegedSuite.isjsUnitTestSuite) {
105
- var newSuite = allegedSuite.clone();
106
- if (newSuite.containsTestPages())
107
- push(this._suiteStack, newSuite);
108
- this._nextPage();
109
- }
110
- else {
111
- this.fatalError('Invalid test suite in file ' + this._testFileName);
112
- this.abort();
113
- }
114
- }
115
-
116
- jsUnitTestManager.prototype._runTest = function () {
117
- if (this._testIndex + 1 > this._numberOfTestsInPage)
118
- {
119
- // execute tearDownPage *synchronously*
120
- // (unlike setUpPage which is asynchronous)
121
- if (typeof this.containerTestFrame.tearDownPage == 'function') {
122
- this.containerTestFrame.tearDownPage();
123
- }
124
-
125
- this._nextPage();
126
- return;
127
- }
128
-
129
- if (this._testIndex == 0) {
130
- this.storeRestoredHTML();
131
- if (typeof(this.containerTestFrame.setUpPage) == 'function') {
132
- // first test for this page and a setUpPage is defined
133
- if (typeof(this.containerTestFrame.setUpPageStatus) == 'undefined') {
134
- // setUpPage() not called yet, so call it
135
- this.containerTestFrame.setUpPageStatus = false;
136
- this.containerTestFrame.startTime = new Date();
137
- this.containerTestFrame.setUpPage();
138
- // try test again later
139
- setTimeout('top.testManager._runTest()', jsUnitTestManager.SETUPPAGE_INTERVAL);
140
- return;
141
- }
142
-
143
- if (this.containerTestFrame.setUpPageStatus != 'complete') {
144
- top.status = 'setUpPage not completed... ' + this.containerTestFrame.setUpPageStatus + ' ' + (new Date());
145
- if ((new Date() - this.containerTestFrame.startTime) / 1000 > this.getsetUpPageTimeout()) {
146
- this.fatalError('setUpPage timed out without completing.');
147
- if (!this.userConfirm('Retry Test Run?')) {
148
- this.abort();
149
- return;
150
- }
151
- this.containerTestFrame.startTime = (new Date());
152
- }
153
- // try test again later
154
- setTimeout('top.testManager._runTest()', jsUnitTestManager.SETUPPAGE_INTERVAL);
155
- return;
156
- }
157
- }
158
- }
159
-
160
- top.status = '';
161
- // either not first test, or no setUpPage defined, or setUpPage completed
162
- this.executeTestFunction(this._testsInPage[this._testIndex]);
163
- this.totalCount++;
164
- this.updateProgressIndicators();
165
- this._testIndex++;
166
- setTimeout('top.testManager._runTest()', jsUnitTestManager.TIMEOUT_LENGTH);
167
- }
168
-
169
- jsUnitTestManager.prototype._done = function () {
170
- var secondsSinceRunBegan = (new Date() - this._timeRunStarted) / 1000;
171
- this.setStatus('Done (' + secondsSinceRunBegan + ' seconds)');
172
- this._cleanUp();
173
- if (top.shouldSubmitResults()) {
174
- this.resultsTimeField.value = secondsSinceRunBegan;
175
- top.submitResults();
176
- }
177
- }
178
-
179
- jsUnitTestManager.prototype._nextPage = function () {
180
- this._restoredHTML = null;
181
- if (this._currentSuite().hasMorePages()) {
182
- this.loadPage(this._currentSuite().nextPage());
183
- }
184
- else {
185
- pop(this._suiteStack);
186
- if (this._currentSuite() == null)
187
- this._done();
188
- else
189
- this._nextPage();
190
- }
191
- }
192
-
193
- jsUnitTestManager.prototype._currentSuite = function () {
194
- var suite = null;
195
-
196
- if (this._suiteStack && this._suiteStack.length > 0)
197
- suite = this._suiteStack[this._suiteStack.length - 1];
198
-
199
- return suite;
200
- }
201
-
202
- jsUnitTestManager.prototype.calculateProgressBarProportion = function () {
203
- if (this.totalCount == 0)
204
- return 0;
205
- var currentDivisor = 1;
206
- var result = 0;
207
-
208
- for (var i = 0; i < this._suiteStack.length; i++) {
209
- var aSuite = this._suiteStack[i];
210
- currentDivisor *= aSuite.testPages.length;
211
- result += (aSuite.pageIndex - 1) / currentDivisor;
212
- }
213
- result += (this._testIndex + 1) / (this._numberOfTestsInPage * currentDivisor);
214
- return result;
215
- }
216
-
217
- jsUnitTestManager.prototype._cleanUp = function () {
218
- this.containerController.setTestPage('./app/emptyPage.html');
219
- this.finalize();
220
- top.tracer.finalize();
221
- }
222
-
223
- jsUnitTestManager.prototype.abort = function () {
224
- this.setStatus('Aborted');
225
- this._cleanUp();
226
- }
227
-
228
- jsUnitTestManager.prototype.getTimeout = function () {
229
- var result = jsUnitTestManager.TESTPAGE_WAIT_SEC;
230
- try {
231
- result = eval(this.timeout.value);
232
- }
233
- catch (e) {
234
- }
235
- return result;
236
- }
237
-
238
- jsUnitTestManager.prototype.getsetUpPageTimeout = function () {
239
- var result = jsUnitTestManager.SETUPPAGE_TIMEOUT;
240
- try {
241
- result = eval(this.setUpPageTimeout.value);
242
- }
243
- catch (e) {
244
- }
245
- return result;
246
- }
247
-
248
- jsUnitTestManager.prototype.isTestPageSuite = function () {
249
- var result = false;
250
- if (typeof(this.containerTestFrame.suite) == 'function')
251
- {
252
- result = true;
253
- }
254
- return result;
255
- }
256
-
257
- jsUnitTestManager.prototype.getTestFunctionNames = function () {
258
- var testFrame = this.containerTestFrame;
259
- var testFunctionNames = new Array();
260
- var i;
261
-
262
- if (testFrame && typeof(testFrame.exposeTestFunctionNames) == 'function')
263
- return testFrame.exposeTestFunctionNames();
264
-
265
- if (testFrame &&
266
- testFrame.document &&
267
- typeof(testFrame.document.scripts) != 'undefined' &&
268
- testFrame.document.scripts.length > 0) { // IE5 and up
269
- var scriptsInTestFrame = testFrame.document.scripts;
270
-
271
- for (i = 0; i < scriptsInTestFrame.length; i++) {
272
- var someNames = this._extractTestFunctionNamesFromScript(scriptsInTestFrame[i]);
273
- if (someNames)
274
- testFunctionNames = testFunctionNames.concat(someNames);
275
- }
276
- }
277
- else {
278
- for (i in testFrame) {
279
- if (i.substring(0, 4) == 'test' && typeof(testFrame[i]) == 'function')
280
- push(testFunctionNames, i);
281
- }
282
- }
283
- return testFunctionNames;
284
- }
285
-
286
- jsUnitTestManager.prototype._extractTestFunctionNamesFromScript = function (aScript) {
287
- var result;
288
- var remainingScriptToInspect = aScript.text;
289
- var currentIndex = this._indexOfTestFunctionIn(remainingScriptToInspect);
290
- while (currentIndex != -1) {
291
- if (!result)
292
- result = new Array();
293
-
294
- var fragment = remainingScriptToInspect.substring(currentIndex, remainingScriptToInspect.length);
295
- result = result.concat(fragment.substring('function '.length, fragment.indexOf('(')));
296
- remainingScriptToInspect = remainingScriptToInspect.substring(currentIndex + 12, remainingScriptToInspect.length);
297
- currentIndex = this._indexOfTestFunctionIn(remainingScriptToInspect);
298
- }
299
- return result;
300
- }
301
-
302
- jsUnitTestManager.prototype._indexOfTestFunctionIn = function (string) {
303
- return string.indexOf('function test');
304
- }
305
-
306
- jsUnitTestManager.prototype.loadPage = function (testFileName) {
307
- this._testFileName = testFileName;
308
- this._loadAttemptStartTime = new Date();
309
- this.setStatus('Opening Test Page "' + this._testFileName + '"');
310
- this.containerController.setTestPage(this._testFileName);
311
- this._callBackWhenPageIsLoaded();
312
- }
313
-
314
- jsUnitTestManager.prototype._callBackWhenPageIsLoaded = function () {
315
- if ((new Date() - this._loadAttemptStartTime) / 1000 > this.getTimeout()) {
316
- this.fatalError('Reading Test Page ' + this._testFileName + ' timed out.\nMake sure that the file exists and is a Test Page.');
317
- if (this.userConfirm('Retry Test Run?')) {
318
- this.loadPage(this._testFileName);
319
- return;
320
- } else {
321
- this.abort();
322
- return;
323
- }
324
- }
325
- if (!this._isTestFrameLoaded()) {
326
- setTimeout('top.testManager._callBackWhenPageIsLoaded();', jsUnitTestManager.TIMEOUT_LENGTH);
327
- return;
328
- }
329
- this.doneLoadingPage(this._testFileName);
330
- }
331
-
332
- jsUnitTestManager.prototype._isTestFrameLoaded = function () {
333
- try {
334
- return this.containerController.isPageLoaded();
335
- }
336
- catch (e) {
337
- }
338
- return false;
339
- }
340
-
341
- jsUnitTestManager.prototype.executeTestFunction = function (functionName) {
342
- this._testFunctionName = functionName;
343
- this.setStatus('Running test "' + this._testFunctionName + '"');
344
- var excep = null;
345
- var timeBefore = new Date();
346
- try {
347
- if (this._restoredHTML)
348
- top.testContainer.testFrame.document.getElementById(jsUnitTestManager.RESTORED_HTML_DIV_ID).innerHTML = this._restoredHTML;
349
- if (this.containerTestFrame.setUp !== JSUNIT_UNDEFINED_VALUE)
350
- this.containerTestFrame.setUp();
351
- this.containerTestFrame[this._testFunctionName]();
352
- }
353
- catch (e1) {
354
- excep = e1;
355
- }
356
- finally {
357
- try {
358
- if (this.containerTestFrame.tearDown !== JSUNIT_UNDEFINED_VALUE)
359
- this.containerTestFrame.tearDown();
360
- }
361
- catch (e2) {
362
- //Unlike JUnit, only assign a tearDown exception to excep if there is not already an exception from the test body
363
- if (excep == null)
364
- excep = e2;
365
- }
366
- }
367
- var timeTaken = (new Date() - timeBefore) / 1000;
368
- if (excep != null)
369
- this._handleTestException(excep);
370
- var serializedTestCaseString = this._currentTestFunctionNameWithTestPageName(true) + "|" + timeTaken + "|";
371
- if (excep == null)
372
- serializedTestCaseString += "S||";
373
- else {
374
- if (typeof(excep.isJsUnitException) != 'undefined' && excep.isJsUnitException)
375
- serializedTestCaseString += "F|";
376
- else {
377
- serializedTestCaseString += "E|";
378
- }
379
- serializedTestCaseString += this._problemDetailMessageFor(excep);
380
- }
381
- this._addOption(this.testCaseResultsField,
382
- serializedTestCaseString,
383
- serializedTestCaseString);
384
- }
385
-
386
- jsUnitTestManager.prototype._currentTestFunctionNameWithTestPageName = function(useFullyQualifiedTestPageName) {
387
- var testURL = this.containerTestFrame.location.href;
388
- var testQuery = testURL.indexOf("?");
389
- if (testQuery >= 0) {
390
- testURL = testURL.substring(0, testQuery);
391
- }
392
- if (!useFullyQualifiedTestPageName) {
393
- if (testURL.substring(0, this._baseURL.length) == this._baseURL)
394
- testURL = testURL.substring(this._baseURL.length);
395
- }
396
- return testURL + ':' + this._testFunctionName;
397
- }
398
-
399
- jsUnitTestManager.prototype._addOption = function(listField, problemValue, problemMessage) {
400
- if (typeof(listField.ownerDocument) != 'undefined'
401
- && typeof(listField.ownerDocument.createElement) != 'undefined') {
402
- // DOM Level 2 HTML method.
403
- // this is required for Opera 7 since appending to the end of the
404
- // options array does not work, and adding an Option created by new Option()
405
- // and appended by listField.options.add() fails due to WRONG_DOCUMENT_ERR
406
- var problemDocument = listField.ownerDocument;
407
- var errOption = problemDocument.createElement('option');
408
- errOption.setAttribute('value', problemValue);
409
- errOption.appendChild(problemDocument.createTextNode(problemMessage));
410
- listField.appendChild(errOption);
411
- }
412
- else {
413
- // new Option() is DOM 0
414
- errOption = new Option(problemMessage, problemValue);
415
- if (typeof(listField.add) != 'undefined') {
416
- // DOM 2 HTML
417
- listField.add(errOption, null);
418
- }
419
- else if (typeof(listField.options.add) != 'undefined') {
420
- // DOM 0
421
- listField.options.add(errOption, null);
422
- }
423
- else {
424
- // DOM 0
425
- listField.options[listField.length] = errOption;
426
- }
427
- }
428
- }
429
-
430
- jsUnitTestManager.prototype._handleTestException = function (excep) {
431
- var problemMessage = this._currentTestFunctionNameWithTestPageName(false) + ' ';
432
- var errOption;
433
- if (typeof(excep.isJsUnitException) == 'undefined' || !excep.isJsUnitException) {
434
- problemMessage += 'had an error';
435
- this.errorCount++;
436
- }
437
- else {
438
- problemMessage += 'failed';
439
- this.failureCount++;
440
- }
441
- var listField = this.problemsListField;
442
- this._addOption(listField,
443
- this._problemDetailMessageFor(excep),
444
- problemMessage);
445
- }
446
-
447
- jsUnitTestManager.prototype._problemDetailMessageFor = function (excep) {
448
- var result = null;
449
- if (typeof(excep.isJsUnitException) != 'undefined' && excep.isJsUnitException) {
450
- result = '';
451
- if (excep.comment != null)
452
- result += ('"' + excep.comment + '"\n');
453
-
454
- result += excep.jsUnitMessage;
455
-
456
- if (excep.stackTrace)
457
- result += '\n\nStack trace follows:\n' + excep.stackTrace;
458
- }
459
- else {
460
- result = 'Error message is:\n"';
461
- result +=
462
- (typeof(excep.description) == 'undefined') ?
463
- excep :
464
- excep.description;
465
- result += '"';
466
- if (typeof(excep.stack) != 'undefined') // Mozilla only
467
- result += '\n\nStack trace follows:\n' + excep.stack;
468
- }
469
- return result;
470
- }
471
-
472
- jsUnitTestManager.prototype._setTextOnLayer = function (layerName, str) {
473
- try {
474
- var content;
475
- if (content = this.uiFrames[layerName].document.getElementById('content'))
476
- content.innerHTML = str;
477
- else
478
- throw 'No content div found.';
479
- }
480
- catch (e) {
481
- var html = '';
482
- html += '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
483
- html += '<html><head><link rel="stylesheet" type="text/css" href="css/jsUnitStyle.css"><\/head>';
484
- html += '<body><div id="content">';
485
- html += str;
486
- html += '<\/div><\/body>';
487
- html += '<\/html>';
488
- this.uiFrames[layerName].document.write(html);
489
- this.uiFrames[layerName].document.close();
490
- }
491
- }
492
-
493
- jsUnitTestManager.prototype.setStatus = function (str) {
494
- this._setTextOnLayer('mainStatus', '<b>Status:<\/b> ' + str);
495
- }
496
-
497
- jsUnitTestManager.prototype._setErrors = function (n) {
498
- this._setTextOnLayer('mainCountsErrors', '<b>Errors: <\/b>' + n);
499
- }
500
-
501
- jsUnitTestManager.prototype._setFailures = function (n) {
502
- this._setTextOnLayer('mainCountsFailures', '<b>Failures:<\/b> ' + n);
503
- }
504
-
505
- jsUnitTestManager.prototype._setTotal = function (n) {
506
- this._setTextOnLayer('mainCountsRuns', '<b>Runs:<\/b> ' + n);
507
- }
508
-
509
- jsUnitTestManager.prototype._setProgressBarImage = function (imgName) {
510
- this.progressBar.src = imgName;
511
- }
512
-
513
- jsUnitTestManager.prototype._setProgressBarWidth = function (w) {
514
- this.progressBar.width = w;
515
- }
516
-
517
- jsUnitTestManager.prototype.updateProgressIndicators = function () {
518
- this._setTotal(this.totalCount);
519
- this._setErrors(this.errorCount);
520
- this._setFailures(this.failureCount);
521
- this._setProgressBarWidth(300 * this.calculateProgressBarProportion());
522
-
523
- if (this.errorCount > 0 || this.failureCount > 0)
524
- this._setProgressBarImage('../images/red.gif');
525
- else
526
- this._setProgressBarImage('../images/green.gif');
527
- }
528
-
529
- jsUnitTestManager.prototype.showMessageForSelectedProblemTest = function () {
530
- var problemTestIndex = this.problemsListField.selectedIndex;
531
- if (problemTestIndex != -1)
532
- this.fatalError(this.problemsListField[problemTestIndex].value);
533
- }
534
-
535
- jsUnitTestManager.prototype.showMessagesForAllProblemTests = function () {
536
- if (this.problemsListField.length == 0)
537
- return;
538
-
539
- try {
540
- if (this._windowForAllProblemMessages && !this._windowForAllProblemMessages.closed)
541
- this._windowForAllProblemMessages.close();
542
- }
543
- catch(e) {
544
- }
545
-
546
- this._windowForAllProblemMessages = window.open('', '', 'width=600, height=350,status=no,resizable=yes,scrollbars=yes');
547
- var resDoc = this._windowForAllProblemMessages.document;
548
- resDoc.write('<html><head><link rel="stylesheet" href="../css/jsUnitStyle.css"><title>Tests with problems - JsUnit<\/title><head><body>');
549
- resDoc.write('<p class="jsUnitSubHeading">Tests with problems (' + this.problemsListField.length + ' total) - JsUnit<\/p>');
550
- resDoc.write('<p class="jsUnitSubSubHeading"><i>Running on ' + navigator.userAgent + '</i></p>');
551
- for (var i = 0; i < this.problemsListField.length; i++)
552
- {
553
- resDoc.write('<p class="jsUnitDefault">');
554
- resDoc.write('<b>' + (i + 1) + '. ');
555
- resDoc.write(this.problemsListField[i].text);
556
- resDoc.write('<\/b><\/p><p><pre>');
557
- resDoc.write(this._makeHTMLSafe(this.problemsListField[i].value));
558
- resDoc.write('<\/pre><\/p>');
559
- }
560
-
561
- resDoc.write('<\/body><\/html>');
562
- resDoc.close();
563
- }
564
-
565
- jsUnitTestManager.prototype._makeHTMLSafe = function (string) {
566
- string = string.replace(/&/g, '&amp;');
567
- string = string.replace(/</g, '&lt;');
568
- string = string.replace(/>/g, '&gt;');
569
- return string;
570
- }
571
-
572
- jsUnitTestManager.prototype._clearProblemsList = function () {
573
- var listField = this.problemsListField;
574
- var initialLength = listField.options.length;
575
-
576
- for (var i = 0; i < initialLength; i++)
577
- listField.remove(0);
578
- }
579
-
580
- jsUnitTestManager.prototype.initialize = function () {
581
- this.setStatus('Initializing...');
582
- this._setRunButtonEnabled(false);
583
- this._clearProblemsList();
584
- this.updateProgressIndicators();
585
- this.setStatus('Done initializing');
586
- }
587
-
588
- jsUnitTestManager.prototype.finalize = function () {
589
- this._setRunButtonEnabled(true);
590
- }
591
-
592
- jsUnitTestManager.prototype._setRunButtonEnabled = function (b) {
593
- this.runButton.disabled = !b;
594
- }
595
-
596
- jsUnitTestManager.prototype.getTestFileName = function () {
597
- var rawEnteredFileName = this.testFileName.value;
598
- var result = rawEnteredFileName;
599
-
600
- while (result.indexOf('\\') != -1)
601
- result = result.replace('\\', '/');
602
-
603
- return result;
604
- }
605
-
606
- jsUnitTestManager.prototype.getTestFunctionName = function () {
607
- return this._testFunctionName;
608
- }
609
-
610
- jsUnitTestManager.prototype.resolveUserEnteredTestFileName = function (rawText) {
611
- var userEnteredTestFileName = top.testManager.getTestFileName();
612
-
613
- // only test for file:// since Opera uses a different format
614
- if (userEnteredTestFileName.indexOf('http://') == 0 || userEnteredTestFileName.indexOf('https://') == 0 || userEnteredTestFileName.indexOf('file://') == 0)
615
- return userEnteredTestFileName;
616
-
617
- return getTestFileProtocol() + this.getTestFileName();
618
- }
619
-
620
- jsUnitTestManager.prototype.storeRestoredHTML = function () {
621
- if (document.getElementById && top.testContainer.testFrame.document.getElementById(jsUnitTestManager.RESTORED_HTML_DIV_ID))
622
- this._restoredHTML = top.testContainer.testFrame.document.getElementById(jsUnitTestManager.RESTORED_HTML_DIV_ID).innerHTML;
623
- }
624
-
625
- jsUnitTestManager.prototype.fatalError = function(aMessage) {
626
- if (top.shouldSubmitResults())
627
- this.setStatus(aMessage);
628
- else
629
- alert(aMessage);
630
- }
631
-
632
- jsUnitTestManager.prototype.userConfirm = function(aMessage) {
633
- if (top.shouldSubmitResults())
634
- return false;
635
- else
636
- return confirm(aMessage);
637
- }
638
-
639
- function getTestFileProtocol() {
640
- return getDocumentProtocol();
641
- }
642
-
643
- function getDocumentProtocol() {
644
- var protocol = top.document.location.protocol;
645
-
646
- if (protocol == "file:")
647
- return "file:///";
648
-
649
- if (protocol == "http:")
650
- return "http://";
651
-
652
- if (protocol == 'https:')
653
- return 'https://';
654
-
655
- if (protocol == "chrome:")
656
- return "chrome://";
657
-
658
- return null;
659
- }
660
-
661
- function browserSupportsReadingFullPathFromFileField() {
662
- return !isOpera() && !isIE7();
663
- }
664
-
665
- function isOpera() {
666
- return navigator.userAgent.toLowerCase().indexOf("opera") != -1;
667
- }
668
-
669
- function isIE7() {
670
- return navigator.userAgent.toLowerCase().indexOf("msie 7") != -1;
671
- }
672
-
673
- function isBeingRunOverHTTP() {
674
- return getDocumentProtocol() == "http://";
675
- }
676
-
677
- function getWebserver() {
678
- if (isBeingRunOverHTTP()) {
679
- var myUrl = location.href;
680
- var myUrlWithProtocolStripped = myUrl.substring(myUrl.indexOf("/") + 2);
681
- return myUrlWithProtocolStripped.substring(0, myUrlWithProtocolStripped.indexOf("/"));
682
- }
683
- return null;
684
- }
685
-
686
- // the functions push(anArray, anObject) and pop(anArray)
687
- // exist because the JavaScript Array.push(anObject) and Array.pop()
688
- // functions are not available in IE 5.0
689
-
690
- function push(anArray, anObject) {
691
- anArray[anArray.length] = anObject;
692
- }
693
-
694
- function pop(anArray) {
695
- if (anArray.length >= 1) {
696
- delete anArray[anArray.length - 1];
697
- anArray.length--;
698
- }
699
- }
700
-
701
- if (xbDEBUG.on) {
702
- xbDebugTraceObject('window', 'jsUnitTestManager');
703
- xbDebugTraceFunction('window', 'getTestFileProtocol');
704
- xbDebugTraceFunction('window', 'getDocumentProtocol');
705
- }