Permalink
Browse files

extract from iTest2

  • Loading branch information...
Zhimin Zhan Zhimin Zhan
Zhimin Zhan authored and Zhimin Zhan committed Feb 24, 2009
0 parents commit 61f5f88e54f163500584dc63fa3952486451d458
Showing with 3,132 additions and 0 deletions.
  1. +16 −0 ChangeLog.txt
  2. +23 −0 License.txt
  3. BIN ant-jars/js-1.6R7.jar
  4. +6 −0 build.base.properties
  5. +185 −0 build.xml
  6. +3 −0 src/chrome.manifest
  7. +64 −0 src/content/UnitTestUtils.js
  8. +62 −0 src/content/WTREditorCtxMenu.js
  9. +57 −0 src/content/WTRStep.js
  10. +34 −0 src/content/WTR_base.js
  11. +27 −0 src/content/contents.rdf
  12. +48 −0 src/content/editors/DomUtils.js
  13. +114 −0 src/content/editors/editor.js
  14. +43 −0 src/content/editors/itest2.html
  15. +181 −0 src/content/editors/itest2_editor.js
  16. +44 −0 src/content/editors/watir.html
  17. +156 −0 src/content/editors/watir_editor.js
  18. BIN src/content/itest2.png
  19. +49 −0 src/content/itest2recorder.css
  20. +72 −0 src/content/itest2recorder.js
  21. +73 −0 src/content/itest2recorder.xul
  22. +54 −0 src/content/itest2recorderTest.js
  23. +49 −0 src/content/itestrecorder.css
  24. +102 −0 src/content/log.js
  25. +20 −0 src/content/myThis.js
  26. +26 −0 src/content/myThisTest.js
  27. +454 −0 src/content/overlay.js
  28. +46 −0 src/content/overlay.xul
  29. +39 −0 src/content/overlayTest.js
  30. +37 −0 src/content/preferences.js
  31. BIN src/content/record.png
  32. BIN src/content/recording.png
  33. +83 −0 src/content/sidebar.js
  34. +34 −0 src/content/stylesheet_utils.js
  35. BIN src/content/test/forms/groovy.png
  36. +100 −0 src/content/test/forms/index.html
  37. +23 −0 src/content/test/frames/index.html
  38. +26 −0 src/content/test/frames/leftFrame.html
  39. +29 −0 src/content/test/index.html
  40. +28 −0 src/content/test/links/index.html
  41. +41 −0 src/content/tools.js
  42. +420 −0 src/content/webtest-steps.js
  43. +60 −0 src/content/webtest.css
  44. +14 −0 src/defaults/preferences/wtr.js
  45. +32 −0 src/install.rdf
  46. +3 −0 src/locale/en-US/itest2recorder/overlay.dtd
  47. +25 −0 src/update.rdf
  48. +24 −0 src/update.rdf.tpl.xml
  49. +106 −0 test.html
@@ -0,0 +1,16 @@
+1.0.3
+ Record file upload
+ Display correct comment "#" instead of "//"
+
+1.0.2
+ [Fixes - TODO] not recording checkbox by id
+ [Feature] Add the help text at the bottom of the editor
+ [Fixes] iTest2 select by id does not record text
+ [Enhancements] Test page
+
+1.0.1 Recorder (2008-12-01)
+==============
+ [Feature] Add Watir recording
+ [Feature] Support click link with id when there is not name field
+ [Feature] Support textarea
+ [Fixes] Checkbox now working correctly
@@ -0,0 +1,23 @@
+Copyright (c) 2008 AgileWay.
+
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Zhimin Zhan
+
+The plugin is based on WebTestRecorder, http://webtestrecorder.canoo.com
+its license as below.
+---------------------
+
+Copyright (c) 2006 Marc Guillemot.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Marc Guillemot - initial version
+
Binary file not shown.
@@ -0,0 +1,6 @@
+updateLink=http://itest2.com/webtestrecorder.xpi
+updateUrl=http://itest2.com/webtestrecorder-dist/update.rdf?reqVersion=%REQ_VERSION%&itemId=%ITEM_ID%&itemVersion=%ITEM_VERSION%&itemMayAppVersion=%ITEM_MAXAPPVERSION%&appId=%APP_ID%&appVersion=%APP_VERSION%&appOS%APP_OS%&appAbi%APP_ABI%
+
+extension.id={b632a045-55b8-4a21-8e6e-6e99f60f9c23}
+# would only work for Firefox 1.5
+#extension.id=WebtestRecorder@internetzky.de
185 build.xml
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+/*******************************************************************************
+ * Copyright (c) 2006 Marc Guillemot.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc Guillemot - initial version
+ *******************************************************************************/
+-->
+
+<project name="itest2recorder" default="create-xpi">
+
+ <!-- load properties from custom and base property files (if they exist) -->
+ <property file="build.properties"/>
+ <property file="build.base.properties"/>
+
+ <property name="remote.repository" value="http://www.ibiblio.org/maven"/>
+
+
+ <property name="jars.dir" value="ant-jars"/>
+ <property name="targetDir" value="target"/>
+ <property name="distDir" value="dist/dist"/>
+ <property name="rhinoJar" value="${jars.dir}/js-1.6R7.jar"/>
+
+ <property name="update.path" value="http://itest2.com/releases"/>
+ <property name="RELEASE" value=""/>
+ <property name="VERSION" value="1.0"/>
+
+ <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+ <target name="prepare" description="creates the directories">
+ <tstamp>
+ <format property="today" pattern="yyyyMMdd"/>
+ </tstamp>
+ <!-- <buildnumber/> -->
+ <property name="versionNumber" value="0.9.${today}"/>
+ <echo message="Extension version: ${versionNumber}"/>
+ <mkdir dir="${targetDir}"/>
+ <mkdir dir="${targetDir}/chrome"/>
+ <mkdir dir="${targetDir}/src"/>
+ <mkdir dir="${targetDir}/dist"/>
+ </target>
+
+ <target name="clean">
+ <delete dir="${targetDir}"/>
+ </target>
+
+ <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+ <target name="create-jar" depends="compile, test">
+ <zip destfile="${targetDir}/chrome/${ant.project.name}.jar">
+ <fileset dir="${targetDir}/src">
+ <include name="content/**"/>
+ <include name="locale/**/*"/>
+ <include name="defaults/**/*"/>
+ </fileset>
+ </zip>
+ </target>
+
+ <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+ <target name="test" depends="compile" description="runs the unit tests">
+ <java dir="target/classes/content" classname="org.mozilla.javascript.tools.shell.Main" failonerror="true"
+ logError="true"
+ classpath="${rhinoJar}" fork="true">
+ <arg line="-f itest2recorderTest.js overlayTest.js myThisTest.js"/>
+ </java>
+ </target>
+
+ <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+ <target name="compile" depends="prepare, get-dependencies" description="pseudo compilation">
+ <mkdir dir="${targetDir}/classes"/>
+ <!-- remove "const " as rhino seem to dislike it -->
+ <copy todir="${targetDir}/classes" overwrite="true">
+ <fileset dir="src" includes="**/*.js"/>
+ <filterset begintoken="c" endtoken=" ">
+ <filter token="onst" value=""/>
+ </filterset>
+ </copy>
+ <echo message="running js compiler on script files"/>
+ <apply executable="java" failonerror="true" logError="true">
+ <arg value="-cp"/>
+ <arg value="${rhinoJar}"/>
+ <arg value="org.mozilla.javascript.tools.jsc.Main"/>
+
+ <fileset dir="${targetDir}/classes" includes="**/*.js"/>
+ </apply>
+
+ <mkdir dir="${targetDir}/src"/>
+ <copy todir="${targetDir}/src" overwrite="true">
+ <fileset dir="src">
+ <include name="install.rdf"/>
+ <include name="chrome.manifest"/>
+ <include name="update.rdf"/>
+ </fileset>
+ <filterset>
+ <filter token="versionNumber" value="${versionNumber}"/>
+ <filter token="updateLink" value="${updateLink}"/>
+ <filter token="updateUrl" value="${updateUrl}"/>
+ <filter token="extension.id" value="${extension.id}"/>
+ </filterset>
+ </copy>
+
+ <copy todir="${targetDir}/dist" overwrite="true">
+ <fileset dir="${targetDir}/src">
+ <include name="update.rdf"/>
+ </fileset>
+ </copy>
+
+ <property name="binaries" value="**/*.png"/>
+ <copy todir="${targetDir}/src" overwrite="true">
+ <fileset dir="src" excludes="${binaries}">
+ <include name="content/**/*"/>
+ <include name="locale/**/*"/>
+ <include name="defaults/**/*"/>
+ </fileset>
+ <filterset>
+ <filter token="Copyright Marc Guillemot" value="Copyright 2005 - 2006 © Marc Guillemot"/>
+ <filter token="versionNumber" value="${versionNumber}"/>
+ </filterset>
+ </copy>
+ <copy todir="${targetDir}/src" overwrite="true">
+ <fileset dir="src" includes="${binaries}"/>
+ </copy>
+ </target>
+
+ <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+ <target name="create-xpi" depends="create-jar, expand-update-template">
+ <echo message="Creating XPI file"/>
+ <zip destfile="${targetDir}/dist/${ant.project.name}.xpi">
+ <fileset dir="${targetDir}">
+ <include name="chrome/*"/>
+ </fileset>
+ <fileset dir="${targetDir}/src">
+ <include name="install.rdf"/>
+ <include name="chrome.manifest"/>
+ <include name="defaults/**"/>
+ <include name="locale/**"/>
+ </fileset>
+ </zip>
+ </target>
+
+ <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+ <target name="dist" depends="create-xpi" description="copies the generated files where they can be downloaded">
+ <echo message="Copying to ${distDir}"/>
+ <copy todir="${distDir}" overwrite="true">
+ <fileset dir="${targetDir}/dist" includes="*"/>
+ </copy>
+ </target>
+
+ <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+ <target name="get-dependencies" unless="skip.get-dependencies"
+ description="Get all the required dependencies from a remote repository">
+ <mkdir dir="${jars.dir}"/>
+
+ <!--<get usetimestamp="true"-->
+ <!--src="${remote.repository}/rhino/jars/js-1.6R7.jar"-->
+ <!--dest="${jars.dir}/js-1.6R7.jar"/>-->
+ </target>
+
+ <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+ <target name="cruise" depends="dist"
+ description="to be started by the CruiseControl build server">
+ </target>
+
+
+ <target name="expand-update-template" unless="update.expansion.notRequired">
+ <copy file="src/update.rdf.tpl.xml"
+ tofile="${targetDir}/dist/update.rdf"
+ overwrite="true">
+ <filterchain>
+ <replacetokens>
+ <token key="VERSION" value="${VERSION}"/>
+ <token key="RELEASE" value="${RELEASE}"/>
+ <token key="LEAF" value="itest2recorder-${VERSION}${RELEASE}.xpi"/>
+ <token key="UPDATEPATH" value="${update.path}/firebug/${VERSION}"/>
+ </replacetokens>
+ </filterchain>
+ </copy>
+ <echo message="expanded src/update.rdf.tpl.xml"/>
+ </target>
+
+</project>
@@ -0,0 +1,3 @@
+content itest2recorder jar:chrome/itest2recorder.jar!/content/
+locale itest2recorder en-US jar:chrome/itest2recorder.jar!/locale/en-US/itest2recorder/
+overlay chrome://browser/content/browser.xul chrome://itest2recorder/content/overlay.xul
@@ -0,0 +1,64 @@
+
+var window = { addEventListener: function() {} };
+
+/**
+Unit tests utilities
+*/
+
+function assertEquals(_oExpected, _oReal)
+{
+ if (_oExpected != _oReal)
+ {
+ var strExpected = String(_oExpected);
+ var strReal = String(_oReal);
+ var iFirstDiff = 0;
+ for (iFirstDiff=0; iFirstDiff<strExpected.length; ++iFirstDiff)
+ {
+ if (strExpected.charAt(iFirstDiff) != strReal.charAt(iFirstDiff))
+ break;
+ }
+ throw "assertEquals failed: expected: \n>" + _oExpected + "<\n, but got: \n>" + _oReal
+ + "<\nFirst diff at position " + iFirstDiff
+ + ": " + strExpected.charAt(iFirstDiff) + " <> " + strReal.charAt(iFirstDiff);
+ }
+ print("Assertion passed");
+}
+
+function assertUndefined(_oReal)
+{
+ if (undefined != _oReal)
+ {
+ throw "assertUndefined failed: found: " + _oReal;
+ }
+ print("Assertion passed");
+}
+
+function runTest(_testFunction)
+{
+ try
+ {
+ _testFunction();
+ }
+ catch (e)
+ {
+ print(e.message + " [" + e.lineNumber + "]");
+ print(e.caller);
+ for (var i in e)
+ {
+ print(i + ": " + e[i]);
+ }
+ throw e;
+ }
+}
+
+function runTests()
+{
+ for (var i in this)
+ {
+ if (typeof this[i] == "function" && i.indexOf("test") == 0)
+ {
+ print(i);
+ runTest(this[i])
+ }
+ }
+}
@@ -0,0 +1,62 @@
+var WTREditorCtxMenu = {}
+
+/**
+Delete all the recorded node in the displayed editor
+*/
+WTREditorCtxMenu.deleteAll = function(_oMenuItem)
+{
+ var element = document.popupNode;
+ var body = element.ownerDocument.body
+ while (body.lastChild)
+ {
+ body.removeChild(body.lastChild)
+ }
+}
+
+/**
+Copies all steps to the clipboard
+*/
+WTREditorCtxMenu.copyToClipboard = function()
+{
+ const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
+ .getService(Components.interfaces.nsIClipboardHelper);
+ var element = document.popupNode;
+ var editorWindow = element.ownerDocument.defaultView
+ gClipboardHelper.copyString(editorWindow.getAsText());
+}
+
+
+
+WTREditorCtxMenu.onPopupShowing = function(_oMenu)
+{
+ var element = document.popupNode;
+ var fnGetAlternatives = element.ownerDocument.defaultView.getAlternative
+ var nbAlternativeFound = 0;
+ var bHideNoAlternativeFound = true;
+ if (fnGetAlternatives)
+ {
+ var alternatives = fnGetAlternatives(element)
+ nbAlternativeFound = alternatives.length
+ for (var i=0; i<nbAlternativeFound; ++i)
+ {
+ var oMenuItem = document.getElementById('alternative' + i)
+ oMenuItem.label = "Replace with: " + alternatives[i].label
+ oMenuItem.wtrStepNode = alternatives[i].node
+ oMenuItem.hidden = false
+ }
+ bHideNoAlternativeFound = (nbAlternativeFound != 0);
+ }
+
+ for (var i=nbAlternativeFound; i<5; ++i)
+ {
+ var oMenuItem = document.getElementById('alternative' + i)
+ oMenuItem.hidden = true
+ }
+ document.getElementById('editorCtxMenu_noAlternative').hidden = bHideNoAlternativeFound
+}
+
+WTREditorCtxMenu.showAlternative = function(_oMenuItem)
+{
+ var oStepNode = _oMenuItem.wtrStepNode
+ oStepNode.ownerDocument.defaultView.activeAlternative(oStepNode)
+}
Oops, something went wrong.

0 comments on commit 61f5f88

Please sign in to comment.