selenium-webdriver 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
  2. data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
  3. data/chrome/src/extension/background.js +1 -0
  4. data/chrome/src/extension/content_script.js +182 -177
  5. data/chrome/src/extension/manifest-nonwin.json +1 -1
  6. data/chrome/src/extension/manifest-win.json +1 -1
  7. data/chrome/src/rb/lib/selenium/webdriver/chrome/bridge.rb +9 -3
  8. data/chrome/src/rb/lib/selenium/webdriver/chrome/launcher.rb +1 -1
  9. data/common/src/js/core/Blank.html +7 -0
  10. data/common/src/js/core/InjectedRemoteRunner.html +8 -0
  11. data/common/src/js/core/RemoteRunner.html +101 -0
  12. data/common/src/js/core/SeleniumLog.html +109 -0
  13. data/common/src/js/core/TestPrompt.html +145 -0
  14. data/common/src/js/core/TestRunner-splash.html +55 -0
  15. data/common/src/js/core/TestRunner.html +177 -0
  16. data/common/src/js/core/icons/all.png +0 -0
  17. data/common/src/js/core/icons/continue.png +0 -0
  18. data/common/src/js/core/icons/continue_disabled.png +0 -0
  19. data/common/src/js/core/icons/pause.png +0 -0
  20. data/common/src/js/core/icons/pause_disabled.png +0 -0
  21. data/common/src/js/core/icons/selected.png +0 -0
  22. data/common/src/js/core/icons/step.png +0 -0
  23. data/common/src/js/core/icons/step_disabled.png +0 -0
  24. data/common/src/js/core/lib/cssQuery/cssQuery-p.js +6 -0
  25. data/common/src/js/core/lib/cssQuery/src/cssQuery-level2.js +142 -0
  26. data/common/src/js/core/lib/cssQuery/src/cssQuery-level3.js +150 -0
  27. data/common/src/js/core/lib/cssQuery/src/cssQuery-standard.js +53 -0
  28. data/common/src/js/core/lib/cssQuery/src/cssQuery.js +356 -0
  29. data/common/src/js/core/lib/prototype.js +2006 -0
  30. data/common/src/js/core/lib/scriptaculous/builder.js +101 -0
  31. data/common/src/js/core/lib/scriptaculous/controls.js +815 -0
  32. data/common/src/js/core/lib/scriptaculous/dragdrop.js +915 -0
  33. data/common/src/js/core/lib/scriptaculous/effects.js +958 -0
  34. data/common/src/js/core/lib/scriptaculous/scriptaculous.js +47 -0
  35. data/common/src/js/core/lib/scriptaculous/slider.js +283 -0
  36. data/common/src/js/core/lib/scriptaculous/unittest.js +383 -0
  37. data/common/src/js/core/lib/snapsie.js +91 -0
  38. data/common/src/js/core/scripts/find_matching_child.js +69 -0
  39. data/common/src/js/core/scripts/htmlutils.js +1623 -0
  40. data/common/src/js/core/scripts/injection.html +72 -0
  41. data/common/src/js/core/scripts/selenium-api.js +3294 -0
  42. data/common/src/js/core/scripts/selenium-browserbot.js +2430 -0
  43. data/common/src/js/core/scripts/selenium-browserdetect.js +153 -0
  44. data/common/src/js/core/scripts/selenium-commandhandlers.js +379 -0
  45. data/common/src/js/core/scripts/selenium-executionloop.js +175 -0
  46. data/common/src/js/core/scripts/selenium-logging.js +148 -0
  47. data/common/src/js/core/scripts/selenium-remoterunner.js +695 -0
  48. data/common/src/js/core/scripts/selenium-testrunner.js +1362 -0
  49. data/common/src/js/core/scripts/selenium-version.js +5 -0
  50. data/common/src/js/core/scripts/ui-doc.html +808 -0
  51. data/common/src/js/core/scripts/ui-element.js +1644 -0
  52. data/common/src/js/core/scripts/ui-map-sample.js +979 -0
  53. data/common/src/js/core/scripts/user-extensions.js +3 -0
  54. data/common/src/js/core/scripts/user-extensions.js.sample +75 -0
  55. data/common/src/js/core/scripts/xmlextras.js +153 -0
  56. data/common/src/js/core/selenium-logo.png +0 -0
  57. data/common/src/js/core/selenium-test.css +43 -0
  58. data/common/src/js/core/selenium.css +316 -0
  59. data/common/src/js/core/xpath/dom.js +566 -0
  60. data/common/src/js/core/xpath/javascript-xpath-0.1.11.js +2816 -0
  61. data/common/src/js/core/xpath/util.js +549 -0
  62. data/common/src/js/core/xpath/xmltoken.js +149 -0
  63. data/common/src/js/core/xpath/xpath.js +2481 -0
  64. data/common/src/js/jsunit/app/css/jsUnitStyle.css +50 -0
  65. data/common/src/js/jsunit/app/css/readme +10 -0
  66. data/common/src/js/jsunit/app/emptyPage.html +11 -0
  67. data/common/src/js/jsunit/app/jsUnitCore.js +534 -0
  68. data/common/src/js/jsunit/app/jsUnitMockTimeout.js +81 -0
  69. data/common/src/js/jsunit/app/jsUnitTestManager.js +705 -0
  70. data/common/src/js/jsunit/app/jsUnitTestSuite.js +44 -0
  71. data/common/src/js/jsunit/app/jsUnitTracer.js +102 -0
  72. data/common/src/js/jsunit/app/jsUnitVersionCheck.js +59 -0
  73. data/common/src/js/jsunit/app/main-counts-errors.html +12 -0
  74. data/common/src/js/jsunit/app/main-counts-failures.html +13 -0
  75. data/common/src/js/jsunit/app/main-counts-runs.html +13 -0
  76. data/common/src/js/jsunit/app/main-counts.html +21 -0
  77. data/common/src/js/jsunit/app/main-data.html +178 -0
  78. data/common/src/js/jsunit/app/main-errors.html +23 -0
  79. data/common/src/js/jsunit/app/main-frame.html +19 -0
  80. data/common/src/js/jsunit/app/main-loader.html +45 -0
  81. data/common/src/js/jsunit/app/main-progress.html +25 -0
  82. data/common/src/js/jsunit/app/main-results.html +67 -0
  83. data/common/src/js/jsunit/app/main-status.html +13 -0
  84. data/common/src/js/jsunit/app/testContainer.html +16 -0
  85. data/common/src/js/jsunit/app/testContainerController.html +77 -0
  86. data/common/src/js/jsunit/app/xbDebug.js +306 -0
  87. data/common/src/js/jsunit/changelog.txt +60 -0
  88. data/common/src/js/jsunit/css/jsUnitStyle.css +83 -0
  89. data/common/src/js/jsunit/images/green.gif +0 -0
  90. data/common/src/js/jsunit/images/logo_jsunit.gif +0 -0
  91. data/common/src/js/jsunit/images/powerby-transparent.gif +0 -0
  92. data/common/src/js/jsunit/images/red.gif +0 -0
  93. data/common/src/js/jsunit/licenses/JDOM_license.txt +56 -0
  94. data/common/src/js/jsunit/licenses/Jetty_license.html +213 -0
  95. data/common/src/js/jsunit/licenses/MPL-1.1.txt +470 -0
  96. data/common/src/js/jsunit/licenses/gpl-2.txt +340 -0
  97. data/common/src/js/jsunit/licenses/index.html +141 -0
  98. data/common/src/js/jsunit/licenses/lgpl-2.1.txt +504 -0
  99. data/common/src/js/jsunit/licenses/mpl-tri-license-c.txt +35 -0
  100. data/common/src/js/jsunit/licenses/mpl-tri-license-html.txt +35 -0
  101. data/common/src/js/jsunit/readme.txt +19 -0
  102. data/common/src/js/jsunit/testRunner.html +167 -0
  103. data/common/src/js/jsunit/version.txt +1 -0
  104. data/common/src/rb/README +29 -0
  105. data/common/src/rb/lib/selenium/webdriver/driver.rb +124 -12
  106. data/common/src/rb/lib/selenium/webdriver/element.rb +119 -3
  107. data/common/src/rb/lib/selenium/webdriver/error.rb +1 -2
  108. data/common/src/rb/lib/selenium/webdriver/find.rb +19 -2
  109. data/common/src/rb/lib/selenium/webdriver/keys.rb +5 -1
  110. data/common/src/rb/lib/selenium/webdriver/navigation.rb +8 -4
  111. data/common/src/rb/lib/selenium/webdriver/platform.rb +4 -2
  112. data/common/src/rb/lib/selenium/webdriver/target_locator.rb +18 -0
  113. data/firefox/prebuilt/Win32/Release/webdriver-firefox.dll +0 -0
  114. data/firefox/prebuilt/linux/Release/libwebdriver-firefox.so +0 -0
  115. data/firefox/prebuilt/linux/Release/x_ignore_nofocus.so +0 -0
  116. data/firefox/prebuilt/linux64/Release/libwebdriver-firefox.so +0 -0
  117. data/firefox/prebuilt/linux64/Release/x_ignore_nofocus.so +0 -0
  118. data/firefox/src/extension/components/utils.js +13 -2
  119. data/firefox/src/extension/install.rdf +1 -1
  120. data/firefox/src/rb/lib/selenium/webdriver/firefox.rb +3 -2
  121. data/firefox/src/rb/lib/selenium/webdriver/firefox/binary.rb +1 -7
  122. data/firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb +11 -4
  123. data/firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb +56 -15
  124. data/firefox/src/rb/lib/selenium/webdriver/firefox/util.rb +1 -1
  125. data/jobbie/prebuilt/Win32/Release/InternetExplorerDriver.dll +0 -0
  126. data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
  127. data/jobbie/src/rb/lib/selenium/webdriver/ie/bridge.rb +10 -5
  128. data/jobbie/src/rb/lib/selenium/webdriver/ie/util.rb +9 -10
  129. data/remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb +4 -2
  130. data/remote/client/src/rb/lib/selenium/webdriver/remote/capabilities.rb +23 -23
  131. metadata +103 -6
  132. data/jobbie/prebuilt/Win32/Release/webdriver-ie-test.dll +0 -0
  133. data/jobbie/prebuilt/Win32/Release/webdriver-ie.dll +0 -0
  134. data/jobbie/prebuilt/x64/Release/webdriver-ie-test.dll +0 -0
  135. data/jobbie/prebuilt/x64/Release/webdriver-ie.dll +0 -0
@@ -0,0 +1,23 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>JsUnit main-errors.html</title>
6
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
7
+ </head>
8
+
9
+ <body>
10
+ <hr>
11
+
12
+ <form name="testRunnerForm" action="javascript:top.testManager.showMessageForSelectedProblemTest()">
13
+ <p>Errors and failures:&nbsp;</p>
14
+ <select size="5" ondblclick="top.testManager.showMessageForSelectedProblemTest()" name="problemsList">
15
+ <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
16
+ </select>
17
+ <br>
18
+ <input type="button" value="Show selected" onclick="top.testManager.showMessageForSelectedProblemTest()">
19
+ &nbsp;&nbsp;&nbsp;
20
+ <input type="button" value="Show all" onclick="top.testManager.showMessagesForAllProblemTests()">
21
+ </form>
22
+ </body>
23
+ </html>
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
2
+ <html>
3
+ <head>
4
+ <title>jsUnit Main Frame</title>
5
+ </head>
6
+ <frameset rows="230,30,30,30,0,*" border="0">>
7
+ <frame name="mainData" src="main-data.html" scrolling="no" frameborder="0">
8
+ <frame name="mainStatus" src="main-status.html" scrolling="no" frameborder="0">
9
+ <frame name="mainProgress" src="main-progress.html" scrolling="no" frameborder="0">
10
+ <frame name="mainCounts" src="main-counts.html" scrolling="no" frameborder="0">
11
+ <frame name="mainResults" src="main-results.html" scrolling="no" frameborder="0">
12
+ <frame name="mainErrors" src="main-errors.html" scrolling="no" frameborder="0">
13
+ <noframes>
14
+ <body>
15
+ <p>Sorry, JsUnit requires frames.</p>
16
+ </body>
17
+ </noframes>
18
+ </frameset>
19
+ </html>
@@ -0,0 +1,45 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>jsUnit External Data Document loader</title>
6
+ <script language="JavaScript" type="text/javascript">
7
+
8
+ var loadStatus;
9
+ var callback = function () {
10
+ };
11
+
12
+ function buffer() {
13
+ return window.frames.documentBuffer;
14
+ }
15
+
16
+ function load(uri) {
17
+ loadStatus = 'loading';
18
+ buffer().document.location.href = uri;
19
+ }
20
+
21
+ function loadComplete() {
22
+ top.xbDEBUG.dump('main-loader.html:loadComplete(): loadStatus = ' + loadStatus + ' href=' + buffer().document.location.href);
23
+ if (loadStatus == 'loading') {
24
+ loadStatus = 'complete';
25
+ callback();
26
+ callback = function () {
27
+ };
28
+ }
29
+ }
30
+
31
+ if (top.xbDEBUG.on) {
32
+ var scopeName = 'main_loader_' + (new Date()).getTime();
33
+ top[scopeName] = window;
34
+ top.xbDebugTraceFunction(scopeName, 'buffer');
35
+ top.xbDebugTraceFunction(scopeName, 'load');
36
+ top.xbDebugTraceFunction(scopeName, 'loadComplete');
37
+ }
38
+
39
+ </script>
40
+ </head>
41
+
42
+ <body>
43
+ <iframe name="documentBuffer" onload="loadComplete()"></iframe>
44
+ </body>
45
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>JsUnit main-progress.html</title>
6
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
7
+ </head>
8
+
9
+ <body>
10
+ <table width="375" cellpadding="0" cellspacing="0" border="0" summary="Test progress indicator">
11
+ <tr>
12
+ <td width="65" valign="top"><b>Progress:</b></td>
13
+
14
+ <td width="300" height="14" valign="middle">
15
+ <table width="300" cellpadding="0" cellspacing="0" border="1" summary="Progress image">
16
+ <tr>
17
+ <td width="300" height="14" valign="top"><img name="progress" height="14" width="0"
18
+ alt="progress image" src="../images/green.gif"></td>
19
+ </tr>
20
+ </table>
21
+ </td>
22
+ </tr>
23
+ </table>
24
+ </body>
25
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>JsUnit main-results.html</title>
6
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
7
+ </head>
8
+
9
+ <body>
10
+ <script language="javascript" type="text/javascript">
11
+ var DEFAULT_SUBMIT_WEBSERVER = "localhost:8080";
12
+
13
+ function submitUrlFromSpecifiedUrl() {
14
+ var result = "";
15
+ var specifiedUrl = top.getSpecifiedResultUrl();
16
+ if (specifiedUrl.indexOf("http://") != 0)
17
+ result = "http://";
18
+ result += specifiedUrl;
19
+ return result;
20
+ }
21
+
22
+ function submitUrlFromTestRunnerLocation() {
23
+ var result = "http://";
24
+ var webserver = top.getWebserver();
25
+ if (webserver == null) // running over file:///
26
+ webserver = DEFAULT_SUBMIT_WEBSERVER;
27
+ result += webserver;
28
+ result += "/jsunit/acceptor";
29
+ return result;
30
+ }
31
+
32
+ var submitUrl = "";
33
+ if (top.wasResultUrlSpecified()) {
34
+ submitUrl = submitUrlFromSpecifiedUrl();
35
+ } else {
36
+ submitUrl = submitUrlFromTestRunnerLocation();
37
+ }
38
+
39
+ var formString = "<form name=\"resultsForm\" action=\"" + submitUrl + "\" method=\"post\" target=\"_top\">";
40
+ document.write(formString);
41
+ </script>
42
+ <input type="hidden" name="id">
43
+ <input type="hidden" name="userAgent">
44
+ <input type="hidden" name="jsUnitVersion">
45
+ <input type="hidden" name="time">
46
+ <input type="hidden" name="url">
47
+ <input type="hidden" name="cacheBuster">
48
+ <select size="5" name="testCases" multiple></select>
49
+ </form>
50
+ <script language="javascript" type="text/javascript">
51
+ function populateHeaderFields(id, userAgent, jsUnitVersion, baseURL) {
52
+ document.resultsForm.id.value = id;
53
+ document.resultsForm.userAgent.value = userAgent;
54
+ document.resultsForm.jsUnitVersion.value = jsUnitVersion;
55
+ document.resultsForm.url.value = baseURL;
56
+ document.resultsForm.cacheBuster.value = new Date().getTime();
57
+ }
58
+ function submitResults() {
59
+ var testCasesField = document.resultsForm.testCases;
60
+ for (var i = 0; i < testCasesField.length; i++) {
61
+ testCasesField[i].selected = true;
62
+ }
63
+ document.resultsForm.submit();
64
+ }
65
+ </script>
66
+ </body>
67
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>JsUnit main-status.html</title>
6
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
7
+ </head>
8
+
9
+ <body>
10
+ <div id="content"><b>Status:</b> (Idle)</div>
11
+
12
+ </body>
13
+ </html>
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>JsUnit Test Container</title>
6
+ </head>
7
+ <frameset rows="0, *" border="0">
8
+ <frame name="testContainerController" src="testContainerController.html">
9
+ <frame name="testFrame" src="emptyPage.html">
10
+ <noframes>
11
+ <body>
12
+ <p>Sorry, JsUnit requires frames.</p>
13
+ </body>
14
+ </noframes>
15
+ </frameset>
16
+ </html>
@@ -0,0 +1,77 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>JsUnit Test Container Controller</title>
6
+ <script language="javascript" type="text/javascript">
7
+ var containerReady = false;
8
+
9
+ function init() {
10
+ containerReady = true;
11
+ }
12
+
13
+ function isPageLoaded() {
14
+ if (!containerReady)
15
+ return false;
16
+
17
+ var isTestPageLoaded = false;
18
+
19
+ try {
20
+ // attempt to access the var isTestPageLoaded in the testFrame
21
+ if (typeof(top.testManager.containerTestFrame.isTestPageLoaded) != 'undefined') {
22
+ isTestPageLoaded = top.testManager.containerTestFrame.isTestPageLoaded;
23
+ }
24
+
25
+ // ok, if the above did not throw an exception, then the
26
+ // variable is defined. If the onload has not fired in the
27
+ // testFrame then isTestPageLoaded is still false. Otherwise
28
+ // the testFrame has set it to true
29
+ }
30
+ catch (e) {
31
+ // an error occured while attempting to access the isTestPageLoaded
32
+ // in the testFrame, therefore the testFrame has not loaded yet
33
+ isTestPageLoaded = false;
34
+ }
35
+ return isTestPageLoaded;
36
+ }
37
+
38
+ function isContainerReady() {
39
+ return containerReady;
40
+ }
41
+
42
+ function setNotReady() {
43
+ try {
44
+ // attempt to set the isTestPageLoaded variable
45
+ // in the test frame to false.
46
+ top.testManager.containerTestFrame.isTestPageLoaded = false;
47
+ }
48
+ catch (e) {
49
+ // testFrame.isTestPageLoaded not available... ignore
50
+ }
51
+ }
52
+ function setTestPage(testPageURI) {
53
+ setNotReady();
54
+ top.jsUnitParseParms(testPageURI);
55
+ testPageURI = appendCacheBusterParameterTo(testPageURI);
56
+ try {
57
+ top.testManager.containerTestFrame.location.href = testPageURI;
58
+ } catch (e) {
59
+ }
60
+ }
61
+
62
+ function appendCacheBusterParameterTo(testPageURI) {
63
+ if (testPageURI.indexOf("?") == -1)
64
+ testPageURI += "?";
65
+ else
66
+ testPageURI += "&";
67
+ testPageURI += "cacheBuster=";
68
+ testPageURI += new Date().getTime();
69
+ return testPageURI;
70
+ }
71
+ </script>
72
+ </head>
73
+
74
+ <body onload="init()">
75
+ Test Container Controller
76
+ </body>
77
+ </html>
@@ -0,0 +1,306 @@
1
+ // xbDebug.js revision: 0.003 2002-02-26
2
+
3
+ /* ***** BEGIN LICENSE BLOCK *****
4
+ * Licensed under Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
+ * Full Terms at /xbProjects-srce/license/mpl-tri-license.txt
6
+ *
7
+ * Software distributed under the License is distributed on an "AS IS" basis,
8
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9
+ * for the specific language governing rights and limitations under the
10
+ * License.
11
+ *
12
+ * The Original Code is Netscape code.
13
+ *
14
+ * The Initial Developer of the Original Code is
15
+ * Netscape Corporation.
16
+ * Portions created by the Initial Developer are Copyright (C) 2001
17
+ * the Initial Developer. All Rights Reserved.
18
+ *
19
+ * Contributor(s): Bob Clary <bclary@netscape.com>
20
+ *
21
+ * ***** END LICENSE BLOCK ***** */
22
+
23
+ /*
24
+ ChangeLog:
25
+
26
+ 2002-02-25: bclary - modified xbDebugTraceOject to make sure
27
+ that original versions of wrapped functions were not
28
+ rewrapped. This had caused an infinite loop in IE.
29
+
30
+ 2002-02-07: bclary - modified xbDebug.prototype.close to not null
31
+ the debug window reference. This can cause problems with
32
+ Internet Explorer if the page is refreshed. These issues will
33
+ be addressed at a later date.
34
+ */
35
+
36
+ function xbDebug()
37
+ {
38
+ this.on = false;
39
+ this.stack = new Array();
40
+ this.debugwindow = null;
41
+ this.execprofile = new Object();
42
+ }
43
+
44
+ xbDebug.prototype.push = function ()
45
+ {
46
+ this.stack[this.stack.length] = this.on;
47
+ this.on = true;
48
+ }
49
+
50
+ xbDebug.prototype.pop = function ()
51
+ {
52
+ this.on = this.stack[this.stack.length - 1];
53
+ --this.stack.length;
54
+ }
55
+
56
+ xbDebug.prototype.open = function ()
57
+ {
58
+ if (this.debugwindow && !this.debugwindow.closed)
59
+ this.close();
60
+
61
+ this.debugwindow = window.open('about:blank', 'DEBUGWINDOW', 'height=400,width=600,resizable=yes,scrollbars=yes');
62
+
63
+ this.debugwindow.title = 'xbDebug Window';
64
+ this.debugwindow.document.write('<html><head><title>xbDebug Window</title></head><body><h3>Javascript Debug Window</h3></body></html>');
65
+ this.debugwindow.focus();
66
+ }
67
+
68
+ xbDebug.prototype.close = function ()
69
+ {
70
+ if (!this.debugwindow)
71
+ return;
72
+
73
+ if (!this.debugwindow.closed)
74
+ this.debugwindow.close();
75
+
76
+ // bc 2002-02-07, other windows may still hold a reference to this: this.debugwindow = null;
77
+ }
78
+
79
+ xbDebug.prototype.dump = function (msg)
80
+ {
81
+ if (!this.on)
82
+ return;
83
+
84
+ if (!this.debugwindow || this.debugwindow.closed)
85
+ this.open();
86
+
87
+ this.debugwindow.document.write(msg + '<br>');
88
+
89
+ return;
90
+ }
91
+
92
+ var xbDEBUG = new xbDebug();
93
+
94
+ window.onunload = function () {
95
+ xbDEBUG.close();
96
+ }
97
+
98
+ function xbDebugGetFunctionName(funcref)
99
+ {
100
+
101
+ if (!funcref)
102
+ {
103
+ return '';
104
+ }
105
+
106
+ if (funcref.name)
107
+ return funcref.name;
108
+
109
+ var name = funcref + '';
110
+ name = name.substring(name.indexOf(' ') + 1, name.indexOf('('));
111
+ funcref.name = name;
112
+
113
+ if (!name) alert('name not defined');
114
+ return name;
115
+ }
116
+
117
+ // emulate functionref.apply for IE mac and IE win < 5.5
118
+ function xbDebugApplyFunction(funcname, funcref, thisref, argumentsref)
119
+ {
120
+ var rv;
121
+
122
+ if (!funcref)
123
+ {
124
+ alert('xbDebugApplyFunction: funcref is null');
125
+ }
126
+
127
+ if (typeof(funcref.apply) != 'undefined')
128
+ return funcref.apply(thisref, argumentsref);
129
+
130
+ var applyexpr = 'thisref.xbDebug_orig_' + funcname + '(';
131
+ var i;
132
+
133
+ for (i = 0; i < argumentsref.length; i++)
134
+ {
135
+ applyexpr += 'argumentsref[' + i + '],';
136
+ }
137
+
138
+ if (argumentsref.length > 0)
139
+ {
140
+ applyexpr = applyexpr.substring(0, applyexpr.length - 1);
141
+ }
142
+
143
+ applyexpr += ')';
144
+
145
+ return eval(applyexpr);
146
+ }
147
+
148
+ function xbDebugCreateFunctionWrapper(scopename, funcname, precall, postcall)
149
+ {
150
+ var wrappedfunc;
151
+ var scopeobject = eval(scopename);
152
+ var funcref = scopeobject[funcname];
153
+
154
+ scopeobject['xbDebug_orig_' + funcname] = funcref;
155
+
156
+ wrappedfunc = function ()
157
+ {
158
+ var rv;
159
+
160
+ precall(scopename, funcname, arguments);
161
+ rv = xbDebugApplyFunction(funcname, funcref, scopeobject, arguments);
162
+ postcall(scopename, funcname, arguments, rv);
163
+ return rv;
164
+ };
165
+
166
+ if (typeof(funcref.constructor) != 'undefined')
167
+ wrappedfunc.constructor = funcref.constuctor;
168
+
169
+ if (typeof(funcref.prototype) != 'undefined')
170
+ wrappedfunc.prototype = funcref.prototype;
171
+
172
+ scopeobject[funcname] = wrappedfunc;
173
+ }
174
+
175
+ function xbDebugCreateMethodWrapper(contextname, classname, methodname, precall, postcall)
176
+ {
177
+ var context = eval(contextname);
178
+ var methodref = context[classname].prototype[methodname];
179
+
180
+ context[classname].prototype['xbDebug_orig_' + methodname] = methodref;
181
+
182
+ var wrappedmethod = function ()
183
+ {
184
+ var rv;
185
+ // eval 'this' at method run time to pick up reference to the object's instance
186
+ var thisref = eval('this');
187
+ // eval 'arguments' at method run time to pick up method's arguments
188
+ var argsref = arguments;
189
+
190
+ precall(contextname + '.' + classname, methodname, argsref);
191
+ rv = xbDebugApplyFunction(methodname, methodref, thisref, argsref);
192
+ postcall(contextname + '.' + classname, methodname, argsref, rv);
193
+ return rv;
194
+ };
195
+
196
+ return wrappedmethod;
197
+ }
198
+
199
+ function xbDebugPersistToString(obj)
200
+ {
201
+ var s = '';
202
+ var p;
203
+
204
+ if (obj == null)
205
+ return 'null';
206
+
207
+ switch (typeof(obj))
208
+ {
209
+ case 'number':
210
+ return obj;
211
+ case 'string':
212
+ return '"' + obj + '"';
213
+ case 'undefined':
214
+ return 'undefined';
215
+ case 'boolean':
216
+ return obj + '';
217
+ }
218
+
219
+ if (obj.constructor)
220
+ return '[' + xbDebugGetFunctionName(obj.constructor) + ']';
221
+
222
+ return null;
223
+ }
224
+
225
+ function xbDebugTraceBefore(scopename, funcname, funcarguments)
226
+ {
227
+ var i;
228
+ var s = '';
229
+ var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname];
230
+ if (!execprofile)
231
+ execprofile = xbDEBUG.execprofile[scopename + '.' + funcname] = { started: 0, time: 0, count: 0 };
232
+
233
+ for (i = 0; i < funcarguments.length; i++)
234
+ {
235
+ s += xbDebugPersistToString(funcarguments[i]);
236
+ if (i < funcarguments.length - 1)
237
+ s += ', ';
238
+ }
239
+
240
+ xbDEBUG.dump('enter ' + scopename + '.' + funcname + '(' + s + ')');
241
+ execprofile.started = (new Date()).getTime();
242
+ }
243
+
244
+ function xbDebugTraceAfter(scopename, funcname, funcarguments, rv)
245
+ {
246
+ var i;
247
+ var s = '';
248
+ var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname];
249
+ if (!execprofile)
250
+ xbDEBUG.dump('xbDebugTraceAfter: execprofile not created for ' + scopename + '.' + funcname);
251
+ else if (execprofile.started == 0)
252
+ xbDEBUG.dump('xbDebugTraceAfter: execprofile.started == 0 for ' + scopename + '.' + funcname);
253
+ else
254
+ {
255
+ execprofile.time += (new Date()).getTime() - execprofile.started;
256
+ execprofile.count++;
257
+ execprofile.started = 0;
258
+ }
259
+
260
+ for (i = 0; i < funcarguments.length; i++)
261
+ {
262
+ s += xbDebugPersistToString(funcarguments[i]);
263
+ if (i < funcarguments.length - 1)
264
+ s += ', ';
265
+ }
266
+
267
+ xbDEBUG.dump('exit ' + scopename + '.' + funcname + '(' + s + ')==' + xbDebugPersistToString(rv));
268
+ }
269
+
270
+ function xbDebugTraceFunction(scopename, funcname)
271
+ {
272
+ xbDebugCreateFunctionWrapper(scopename, funcname, xbDebugTraceBefore, xbDebugTraceAfter);
273
+ }
274
+
275
+ function xbDebugTraceObject(contextname, classname)
276
+ {
277
+ var classref = eval(contextname + '.' + classname);
278
+ var p;
279
+ var sp;
280
+
281
+ if (!classref || !classref.prototype)
282
+ return;
283
+
284
+ for (p in classref.prototype)
285
+ {
286
+ sp = p + '';
287
+ if (typeof(classref.prototype[sp]) == 'function' && (sp).indexOf('xbDebug_orig') == -1)
288
+ {
289
+ classref.prototype[sp] = xbDebugCreateMethodWrapper(contextname, classname, sp, xbDebugTraceBefore, xbDebugTraceAfter);
290
+ }
291
+ }
292
+ }
293
+
294
+ function xbDebugDumpProfile()
295
+ {
296
+ var p;
297
+ var execprofile;
298
+ var avg;
299
+
300
+ for (p in xbDEBUG.execprofile)
301
+ {
302
+ execprofile = xbDEBUG.execprofile[p];
303
+ avg = Math.round(100 * execprofile.time / execprofile.count) / 100;
304
+ xbDEBUG.dump('Execution profile ' + p + ' called ' + execprofile.count + ' times. Total time=' + execprofile.time + 'ms. Avg Time=' + avg + 'ms.');
305
+ }
306
+ }