[Windmill-dev] Re: [Windmill-commits] [commits] (adam) [481] Fixing
a problem in the recorder where elements who had tagName A
parents with no text content were getting eaten,
also added code to the click functions to replicate a click event
bubble
Mikeal Rogers
mikeal at osafoundation.org
Mon Oct 15 19:12:43 PDT 2007
In light of this rather late and rather large checkin I'd like to
postpone release for at least 24 hours.
-Mikeal
On Oct 15, 2007, at 6:43 PM, svncheckin at osafoundation.org wrote:
> Revision
> 481
> Author
> adam
> Date
> 2007-10-15 18:43:14 -0700 (Mon, 15 Oct 2007)
> Log Message
>
> Fixing a problem in the recorder where elements who had tagName A
> parents with no text content were getting eaten, also added code to
> the click functions to replicate a click event bubble
> Modified Paths
>
> trunk/windmill/js/controller/ieController.js
> trunk/windmill/js/controller/mozController.js
> trunk/windmill/js/controller/safController.js
> trunk/windmill/js/remote.html
> trunk/windmill/js/wm/recorder.js
> trunk/windmill/js/wm/remote.js
> Diff
>
> Modified: trunk/windmill/js/controller/ieController.js (480 => 481)
>
> --- trunk/windmill/js/controller/ieController.js 2007-10-14
> 18:48:10 UTC (rev 480)
> +++ trunk/windmill/js/controller/ieController.js 2007-10-16
> 01:43:14 UTC (rev 481)
> @@ -39,15 +39,15 @@
> if (element.href && (element.href.indexOf('javascript:', 0) ==
> -1)){
> windmill.controller.open({"url":element.href});
> }
> - /*else {
> - if (element.hasChildNodes()){
> - var children = element.childNodes;
> - for (var i = 0; i < children.length; i++){
> - windmill.controller.open({"url":children[i].href});
> - return true;
> - }
> - }
> - }*/
> + else{
> + while (element = element.parentNode) {
> + if (element.href) {
> + windmill.controller.open({"url":element.href});
> + break;
> + }
> + }
> + }
> +
> return true;
> };
>
> Modified: trunk/windmill/js/controller/mozController.js (480 => 481)
>
> --- trunk/windmill/js/controller/mozController.js 2007-10-14
> 18:48:10 UTC (rev 480)
> +++ trunk/windmill/js/controller/mozController.js 2007-10-16
> 01:43:14 UTC (rev 481)
> @@ -34,6 +34,8 @@
> windmill.events.triggerMouseEvent(element, 'mouseup', true);
> windmill.events.triggerMouseEvent(element, 'click', true);
>
> +
> +
> //Apparently there is some annoying issue with chrome..and
> this fixes it. Concept from selenium browerbot.
> if (!browser.isChrome && !preventDefault) {
> if (element.href) {
> @@ -45,6 +47,17 @@
> return true;
> }
> }
> + //It is common place for an event to bubble, which is
> why many sites
> + //will place a click listener on an elements parent and
> expect that to catch
> + //the event and fire it, we need to replicate that.
> + else{
> + while (element = element.parentNode) {
> + if (element.href) {
> + windmill.controller.open({"url":element.href});
> + break;
> + }
> + }
> + }
> }
> return true;
> };
> Modified: trunk/windmill/js/controller/safController.js (480 => 481)
>
> --- trunk/windmill/js/controller/safController.js 2007-10-14
> 18:48:10 UTC (rev 480)
> +++ trunk/windmill/js/controller/safController.js 2007-10-16
> 01:43:14 UTC (rev 481)
> @@ -69,16 +69,14 @@
> if (element.href && (element.href.indexOf('javascript:', 0)
> == -1)){
> windmill.controller.open({"url":element.href});
> }
> - /*else {
> - if (element.hasChildNodes()){
> - var children = element.childNodes;
> - for (var i = 0; i < children.length; i++){
> - windmill.controller.open({"url":children[i].href});
> - return true;
> - }
> - }
> + else{
> + while (element = element.parentNode) {
> + if (element.href) {
> + windmill.controller.open({"url":element.href});
> + break;
> + }
> }
> - */
> + }
> return true;
> };
>
> Modified: trunk/windmill/js/remote.html (480 => 481)
>
> --- trunk/windmill/js/remote.html 2007-10-14 18:48:10 UTC (rev 480)
> +++ trunk/windmill/js/remote.html 2007-10-16 01:43:14 UTC (rev 481)
> @@ -81,14 +81,14 @@
> <div id="navigation" style="font-weight:bold;" align=center>
>
> <span style="font-weight: bold;">
> - <a id="loopLink" href = "#" onclick="javascript:toggleLoop
> ();">Pause Loop</a>  |
> - <a href="#" onclick="javascript:openDialog('shell')">Shell</
> a>  |
> - <a href="#" onclick="javascript:openDialog('output')">Output</
> a>  |
> + <a id="loopLink" href = "#" onclick="javascript:toggleLoop
> ();">Pause Loop</a>  |  
> + <a href="#" onclick="javascript:openDialog('shell')">Shell</
> a> 
> + <a href="#" onclick="javascript:openDialog('output')">Output</
> a> 
> <a href="#" onclick="javascript:openDialog
> ('settings')">Settings</a> 
> </span>
> - <span>|
> - <a href="#" onclick="windmill.ui.incRecSuite
> ();windmill.ui.remote.getSuite();">New Suite</a> 
> - <a href="#" onclick="windmill.ui.remote.addAction();">New
> Action</a>  |  
> + <span>|  
> + <a href="#" onclick="windmill.ui.incRecSuite
> ();windmill.ui.remote.getSuite();"> Add Suite</a>  |  
> + <a href="#" onclick="windmill.ui.remote.addAction();">Add
> Action</a>  |  
> <a href="#" onclick="windmill.ui.remote.clearIDE()">Clear IDE</
> a> 
> </span>
> </div>
> Modified: trunk/windmill/js/wm/recorder.js (480 => 481)
>
> --- trunk/windmill/js/wm/recorder.js 2007-10-14 18:48:10 UTC (rev 480)
> +++ trunk/windmill/js/wm/recorder.js 2007-10-16 01:43:14 UTC (rev 481)
> @@ -26,7 +26,6 @@
> }
> //write json to the remote from the click events
> this.writeJsonClicks = function(e){
> - //console.log(e);
> if( this.recordState == false){ return; }
> var locator = '';
> var locValue = '';
> @@ -39,48 +38,40 @@
> locator = 'name';
> locValue = e.target.name;
> }
> - else if ((e.target.tagName == "A") ||
> (e.target.parentNode.tagName == "A")){
> + else if (e.target.tagName.toUpperCase() == "A"){
> locator = 'link';
> - if (!e.target.href || e.target.onclick ||
> e.target.onmouseover){
> - locValue = e.target.parentNode.innerHTML.replace(/(<([^>]+)
> >)/ig,"");
> - locValue = locValue.replace(/^\s*(.*?)\s*$/,"$1");
> - }
> - else{
> - locValue = e.target.innerHTML.replace(/(<([^>]+)>)/ig,"");
> - locValue = locValue.replace(/^\s*(.*?)\s*$/,"$1");
> - }
> + locValue = e.target.innerHTML.replace(/(<([^>]+)>)/ig,"");
> + locValue = locValue.replace(/^\s*(.*?)\s*$/,"$1");
> }
> else{
> var xpArray = getXPath(e.target);
> var stringXpath = xpArray.join('/');
>
> locator = 'xpath';
> - locValue = stringXpath;
> + locValue = '/'+stringXpath;
> }
> if (locValue != ""){
> var params = {};
> params[locator] = locValue;
> -
> +
> if(e.type == 'dblclick'){
> - windmill.ui.remote.addAction(windmill.ui.remote.buildAction
> ('doubleClick', params));
> + windmill.ui.remote.addAction(windmill.ui.remote.buildAction
> ('doubleClick', params));
> }
> else{
> - //console.log(e.target.parentNode);
> - if (windmill.remote.$("clickOn").checked == true){
> - windmill.ui.remote.addAction(windmill.ui.remote.buildAction
> ('click', params));
> - }
> - else if ((e.target.onclick != null) || (locator == 'link') ||
> (e.target.type == 'image')){
> - windmill.ui.remote.addAction(windmill.ui.remote.buildAction
> ('click', params));
> - }
> - }
> + if (windmill.remote.$("clickOn").checked == true){
> + windmill.ui.remote.addAction
> (windmill.ui.remote.buildAction('click', params));
> + }
> + else if ((e.target.onclick != null) || (locator == 'link')
> || (e.target.tagName.toUpperCase() == 'IMG')){
> + windmill.ui.remote.addAction
> (windmill.ui.remote.buildAction('click', params));
> + }
> }
> - windmill.ui.remote.scrollRecorderTextArea();
> -
> }
> + windmill.ui.remote.scrollRecorderTextArea();
> + }
>
> //Writing json to the remote for the change events
> this.writeJsonChange = function(e){
> -
> +
> if( this.recordState == false){ return; }
> var locator = '';
> var locValue = '';
> Modified: trunk/windmill/js/wm/remote.js (480 => 481)
>
> --- trunk/windmill/js/wm/remote.js 2007-10-14 18:48:10 UTC (rev 480)
> +++ trunk/windmill/js/wm/remote.js 2007-10-16 01:43:14 UTC (rev 481)
> @@ -100,11 +100,11 @@
> suite = windmill.remote.document.createElement('div');
> suite.id = 'recordingSuite' + windmill.ui.recordSuiteNum;
> if (document.all) {
> - var vWidth = windmill.remote.fleegix.dom.getViewportWidth();
> - suite.style.width = (vWidth - 20) + 'px';
> + var vWidth = windmill.remote.fleegix.dom.getViewportWidth();
> + suite.style.width = (vWidth - 20) + 'px';
> }
> else {
> - suite.style.width = "100%";
> + suite.style.width = "100%";
> }
> suite.style.background = "lightblue";
> suite.style.overflow = 'hidden';
> @@ -365,16 +365,16 @@
> var o1 = windmill.remote.document.createElement('option');
> o1.selected = 'selected';
> if (locator){
> - o1.value = locator;
> - o1.innerHTML += locator;
> + o1.value = locator;
> + o1.innerHTML += locator;
> }
> s1.appendChild(o1);
>
> for(var i=0;i<windmill.registry.locator.length;i++){
> - var o1 = windmill.remote.document.createElement('option');
> - o1.value = windmill.registry.locator[i];
> - o1.innerHTML += windmill.registry.locator[i];
> - s1.appendChild(o1);
> + var o1 = windmill.remote.document.createElement('option');
> + o1.value = windmill.registry.locator[i];
> + o1.innerHTML += windmill.registry.locator[i];
> + s1.appendChild(o1);
> }
>
> var c = windmill.remote.document.createElement("td");
> @@ -388,10 +388,13 @@
> i0.size = '45';
> //Dont know why I have to do this.. but it wont work if its
> not setattrib
> if (params[locator]){
> - i0.setAttribute('value',params[locator]);
> + i0.setAttribute('value',params[locator]);
> }
> i0.id = action.id + 'locator';
> i0.setAttribute('onFocus', 'windmill.ui.remote.setRemoteElem
> (\''+i0.id+'\')');
> + //in firefox there was a bug moving the focus to the element
> we clicked, not sure why
> + //but this seems to fix it.
> + i0.setAttribute('onClick', 'windmill.remote.$(\''+i0.id
> +'\').focus();');
>
> var c = windmill.remote.document.createElement("td");
> c.appendChild(i0);
> @@ -415,17 +418,17 @@
>
> var o2 = windmill.remote.document.createElement('option');
> if (typeof(windmill.registry.methods[method].option) !=
> 'undefined'){
> - o2.value = windmill.registry.methods[method].option;
> + o2.value = windmill.registry.methods[method].option;
> }
> o2.selected = 'selected';
> o2.innerHTML += windmill.registry.methods[method].option;
> s2.appendChild(o2);
>
> for(var i=0;i<windmill.registry.option.length;i++){
> - var o2 = windmill.remote.document.createElement('option');
> - o2.value = windmill.registry.option[i];
> - o2.innerHTML += windmill.registry.option[i];
> - s2.appendChild(o2);
> + var o2 = windmill.remote.document.createElement('option');
> + o2.value = windmill.registry.option[i];
> + o2.innerHTML += windmill.registry.option[i];
> + s2.appendChild(o2);
> }
> var c = windmill.remote.document.createElement("td");
> c.appendChild(s2);
> @@ -437,10 +440,11 @@
> i1.className = 'texta';
> i1.size = '40';
> if (typeof(params[windmill.registry.methods
> [method].option]) != 'undefined'){
> - i1.setAttribute("value", params[windmill.registry.methods
> [method].option]);
> + i1.setAttribute("value", params[windmill.registry.methods
> [method].option]);
> }
> i1.id = action.id + 'option';
> i1.setAttribute('onFocus', 'windmill.ui.remote.setRemoteElem
> (\''+i1.id+'\')');
> + i1.setAttribute('onClick', 'windmill.remote.$(\''+i1.id
> +'\').focus();');
>
> var c = windmill.remote.document.createElement("td");
> c.appendChild(i1);
>
> _______________________________________________
> Windmill-commits mailing list
> Windmill-commits at osafoundation.org
> http://lists.osafoundation.org/mailman/listinfo/windmill-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osafoundation.org/pipermail/windmill-dev/attachments/20071015/5b1dd637/attachment-0001.html
More information about the Windmill-dev
mailing list