Bug 750553 - Rename getAttributeValue to getElementAttribute, r=jgriffin, a=testonly, npotb
authorMalini Das <mdas@mozilla.com>
Tue, 01 May 2012 12:37:34 -0700
changeset 95001 e2678ef38a0d40f3124b1fd13a131df283f5b7c1
parent 95000 a53189537295eabffb760bb38a411d119a48c543
child 95002 3266a0e9f1b2d383de4b4092c0f9a658b2a13c04
push idunknown
push userunknown
push dateunknown
reviewersjgriffin, testonly, npotb
bugs750553
milestone15.0a1
Bug 750553 - Rename getAttributeValue to getElementAttribute, r=jgriffin, a=testonly, npotb
testing/marionette/atoms/atoms.js
testing/marionette/client/marionette/marionette.py
testing/marionette/marionette-actors.js
testing/marionette/marionette-listener.js
--- a/testing/marionette/atoms/atoms.js
+++ b/testing/marionette/atoms/atoms.js
@@ -145,18 +145,18 @@ function id(a){a&&(this.o=hd(a),this.f=t
 p.D=function(){if(!this.V){for(var a=[],b=0,c=this.F();b<c;b++)a.push(this.C(b).D());this.V=gb.apply(k,a)}return this.V};function ld(a){a.J||(a.J=Mc(a),a.J.sort(function(a,c){var d=a.b(),e=a.j(),f=c.b(),j=c.j();return d==f&&e==j?0:Vc(d,e,f,j)?1:-1}));return a.J}p.b=function(){return ld(this)[0].b()};p.j=function(){return ld(this)[0].j()};p.g=function(){return z(ld(this)).g()};p.k=function(){return z(ld(this)).k()};p.isCollapsed=function(){return 0==this.w.length||1==this.w.length&&this.C(0).isCollapsed()};
 p.t=function(){return new md(this)};p.select=function(){var a=Lc(this.ta());a.removeAllRanges();for(var b=0,c=this.F();b<c;b++)a.addRange(this.C(b).X())};p.ka=function(){return new nd(this)};p.collapse=function(a){if(!this.isCollapsed()){var b=a?this.C(0):this.C(this.F()-1);this.u();b.collapse(a);this.Q=[b];this.J=[b];this.w=[b.X()]}};function nd(a){Ma(Mc(a),function(a){return a.ka()})}x(nd,Jc);function md(a){a&&(this.I=Ma(ld(a),function(a){return sb(a)}));V.call(this,a?this.b():k,l)}x(md,V);p=md.prototype;
 p.I=k;p.W=0;p.b=function(){return this.I[0].b()};p.g=function(){return z(this.I).g()};p.N=function(){return this.I[this.W].N()};p.next=function(){try{var a=this.I[this.W],b=a.next();N(this,a.r,a.s,a.depth);return b}catch(c){return(c!==K||this.I.length-1==this.W)&&g(c),this.W++,this.next()}};function Tc(a){var b,c=l;if(a.createRange)try{b=a.createRange()}catch(d){return k}else if(a.rangeCount){if(1<a.rangeCount){b=new kd;for(var c=0,e=a.rangeCount;c<e;c++)b.w.push(a.getRangeAt(c));return b}b=a.getRangeAt(0);c=Vc(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset)}else return k;b&&b.addElement?(a=new gd,a.a=b):a=Nc(new Wc(b),c);return a}
 function Vc(a,b,c,d){if(a==c)return d<b;var e;if(1==a.nodeType&&b)if(e=a.childNodes[b])a=e,b=0;else if(H(a,c))return i;if(1==c.nodeType&&d)if(e=c.childNodes[d])c=e,d=0;else if(H(c,a))return l;return 0<(db(a,c)||b-d)};function od(){Q.call(this);this.ha=this.z=k;this.A=new C(0,0);this.va=this.Z=l}x(od,Q);var Y={};Y[ic]=[0,1,2,k];Y[jc]=[k,k,2,k];Y[nc]=[0,1,2,k];Y[Tb]=[0,0,0,0];Y[mc]=[0,0,0,0];Y[kc]=Y[ic];Y[lc]=Y[nc];Y[Sb]=Y[Tb];od.prototype.move=function(a,b){var c=yb(a);this.A.x=b.x+c.x;this.A.y=b.y+c.y;a!=this.m()&&(c=this.m()===Ca.document.documentElement||this.m()===Ca.document.body,c=!this.va&&c?k:this.m(),Z(this,Tb,a),Qb(this,a),Z(this,Sb,c));Z(this,mc);this.Z=l};
 function Z(a,b,c){a.va=i;return Rb(a,b,a.A,pd(a,b),c,h)}function pd(a,b){if(!(b in Y))return 0;var c=Y[b][a.z===k?3:a.z];c===k&&g(new y(13,"Event does not permit the specified mouse button."));return c};function qd(){Q.call(this);this.A=new C(0,0);this.fa=new C(0,0)}x(qd,Q);qd.prototype.za=0;qd.prototype.ya=0;qd.prototype.move=function(a,b,c){this.Y()||Qb(this,a);a=yb(a);this.A.x=b.x+a.x;this.A.y=b.y+a.y;r(c)&&(this.fa.x=c.x+a.x,this.fa.y=c.y+a.y);if(this.Y()){b=Xb;this.Y()||g(new y(13,"Should never fire event when touchscreen is not pressed."));var d,e;this.ya&&(d=this.ya,e=this.fa);Vb(this,b,this.za,this.A,d,e)}};qd.prototype.Y=function(){return!!this.za};function rd(a,b){this.x=a;this.y=b}x(rd,C);rd.prototype.scale=function(a){this.x*=a;this.y*=a;return this};rd.prototype.add=function(a){this.x+=a.x;this.y+=a.y;return this};function sd(){Q.call(this)}x(sd,Q);(function(a){a.Ma=function(){return a.Ea||(a.Ea=new a)}})(sd);function td(a,b,c){Ob(a,i)||g(new y(11,"Element is not currently visible and may not be manipulated"));var d=E(a).documentElement,e=xb(a),f=xb(d),j,m,s,F;F=O(d,"borderLeftWidth");s=O(d,"borderRightWidth");j=O(d,"borderTopWidth");m=O(d,"borderBottomWidth");j=new ub(parseFloat(j),parseFloat(s),parseFloat(m),parseFloat(F));m=e.x-f.x-j.left;e=e.y-f.y-j.top;f=d.clientHeight-a.offsetHeight;d.scrollLeft+=Math.min(m,Math.max(m-(d.clientWidth-a.offsetWidth),0));d.scrollTop+=Math.min(e,Math.max(e-f,0));b||
 (b=zb(a),b=new C(b.width/2,b.height/2));c=c||new od;c.move(a,b);c.z!==k&&g(new y(13,"Cannot press more then one button or an already pressed button."));c.z=0;c.ha=c.m();!qb()&&(P(c.m(),"OPTION")||P(c.m(),"SELECT"))?a=i:(a=E(c.m()).activeElement,a=(b=Z(c,lc))&&a!=E(c.m()).activeElement?l:b);if(a&&(a=c.ba||c.l,b=E(a).activeElement,a!=b)){if(b&&u(b.blur))try{b.blur()}catch(B){g(B)}u(a.focus)&&a.focus()}c.z===k&&g(new y(13,"Cannot release a button when no button is pressed."));Z(c,nc);if(0==c.z&&c.m()==
 c.ha){b=c.A;d=pd(c,ic);if(Ob(c.l,i)&&Hb(c.l)){a=k;if(Yb)for(e=c.l;e;e=e.parentNode)if(P(e,"A")){a=e;break}else{a:{if(P(e,"INPUT")&&(f=e.type.toLowerCase(),"submit"==f||"image"==f)){f=i;break a}if(P(e,"BUTTON")&&(f=e.type.toLowerCase(),"submit"==f)){f=i;break a}f=l}if(f)break}if(e=Bb(c.l)){e=c.l;Bb(e)||g(new y(15,"Element is not selectable"));f="selected";m=e.type&&e.type.toLowerCase();if("checkbox"==m||"radio"==m)f="checked";e=!!Eb(e,f)}if(c.ba&&(f=c.ba,!e||f.multiple))c.l.selected=!e,Ub(f,hc);Rb(c,
 ic,b,d)&&a&&ac(a)&&(b=a.href,d=G(E(a)),a.target?d.open(b,a.target):d.location.href=b)}c.Z&&Z(c,kc);c.Z=!c.Z}else 2==c.z&&Z(c,jc);c.z=k;c.ha=k}var ud=["_"],$=q;!(ud[0]in $)&&$.execScript&&$.execScript("var "+ud[0]);for(var wd;ud.length&&(wd=ud.shift());)!ud.length&&r(td)?$[wd]=td:$=$[wd]?$[wd]:$[wd]={};; return this._.apply(null,arguments);}.apply({navigator:typeof window!='undefined'?window.navigator:null}, arguments);}
-//getAttributeValue
-var getAttributeValue = function(){return function(){var f=null,g=!1,h=this;
+//getElementAttribute
+var getElementAttribute = function(){return function(){var f=null,g=!1,h=this;
 function i(a){var c=typeof a;if("object"==c)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return c;var b=Object.prototype.toString.call(a);if("[object Window]"==b)return"object";if("[object Array]"==b||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==b||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"==
 c&&"undefined"==typeof a.call)return"object";return c}function j(a,c){function b(){}b.prototype=c.prototype;a.f=c.prototype;a.prototype=new b};function k(a,c){for(var b=1;b<arguments.length;b++)var d=(""+arguments[b]).replace(/\$/g,"$$$$"),a=a.replace(/\%s/,d);return a}function l(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")};var m,n="",o=/rv\:([^\);]+)(\)|;)/.exec(h.navigator?h.navigator.userAgent:f);m=n=o?o[1]:"";var p={};function q(a,c){this.code=a;this.message=c||"";this.name=r[a]||r[13];var b=Error(this.message);b.name=this.name;this.stack=b.stack||""}j(q,Error);
 var r={7:"NoSuchElementError",8:"NoSuchFrameError",9:"UnknownCommandError",10:"StaleElementReferenceError",11:"ElementNotVisibleError",12:"InvalidElementStateError",13:"UnknownError",15:"ElementNotSelectableError",19:"XPathLookupError",23:"NoSuchWindowError",24:"InvalidCookieDomainError",25:"UnableToSetCookieError",26:"ModalDialogOpenedError",27:"NoModalDialogOpenError",28:"ScriptTimeoutError",32:"InvalidSelectorError",33:"SqlDatabaseError",34:"MoveTargetOutOfBoundsError"};
 q.prototype.toString=function(){return"["+this.name+"] "+this.message};function s(a){this.stack=Error().stack||"";a&&(this.message=""+a)}j(s,Error);s.prototype.name="CustomError";function t(a,c){c.unshift(a);s.call(this,k.apply(f,c));c.shift()}j(t,s);t.prototype.name="AssertionError";function u(a,c){if("string"==typeof a)return"string"!=typeof c||1!=c.length?-1:a.indexOf(c,0);for(var b=0;b<a.length;b++)if(b in a&&a[b]===c)return b;return-1};if(!p["1.9.1"]){for(var v=0,w=l(""+m).split("."),x=l("1.9.1").split("."),y=Math.max(w.length,x.length),z=0;0==v&&z<y;z++){var A=w[z]||"",B=x[z]||"",C=RegExp("(\\d*)(\\D*)","g"),D=RegExp("(\\d*)(\\D*)","g");do{var E=C.exec(A)||["","",""],F=D.exec(B)||["","",""];if(0==E[0].length&&0==F[0].length)break;v=((0==E[1].length?0:parseInt(E[1],10))<(0==F[1].length?0:parseInt(F[1],10))?-1:(0==E[1].length?0:parseInt(E[1],10))>(0==F[1].length?0:parseInt(F[1],10))?1:0)||((0==E[2].length)<(0==F[2].length)?-1:(0==
 E[2].length)>(0==F[2].length)?1:0)||(E[2]<F[2]?-1:E[2]>F[2]?1:0)}while(0==v)}p["1.9.1"]=0<=v};var G={SCRIPT:1,STYLE:1,HEAD:1,IFRAME:1,OBJECT:1},H={IMG:" ",BR:"\n"};function I(a,c,b){if(!(a.nodeName in G))if(3==a.nodeType)b?c.push((""+a.nodeValue).replace(/(\r\n|\r|\n)/g,"")):c.push(a.nodeValue);else if(a.nodeName in H)c.push(H[a.nodeName]);else for(a=a.firstChild;a;)I(a,c,b),a=a.nextSibling};(function(){var a=h.Components;if(!a)return g;try{if(!a.classes)return g}catch(c){return g}var b=a.classes,a=a.interfaces;b["@mozilla.org/xpcom/version-comparator;1"].getService(a.nsIVersionComparator);b["@mozilla.org/xre/app-info;1"].getService(a.nsIXULAppInfo);return!0})();var J="StopIteration"in h?h.StopIteration:Error("StopIteration");function K(){}K.prototype.next=function(){throw J;};function L(a,c,b,d,e){this.a=!!c;a&&M(this,a,d);this.depth=void 0!=e?e:this.c||0;this.a&&(this.depth*=-1);this.e=!b}j(L,K);L.prototype.b=f;L.prototype.c=0;L.prototype.d=g;function M(a,c,b){if(a.b=c)a.c="number"==typeof b?b:1!=a.b.nodeType?0:a.a?-1:1}
 L.prototype.next=function(){var a;if(this.d){if(!this.b||this.e&&0==this.depth)throw J;a=this.b;var c=this.a?-1:1;if(this.c==c){var b=this.a?a.lastChild:a.firstChild;b?M(this,b):M(this,a,-1*c)}else(b=this.a?a.previousSibling:a.nextSibling)?M(this,b):M(this,a.parentNode,-1*c);this.depth+=this.c*(this.a?-1:1)}else this.d=!0;a=this.b;if(!this.b)throw J;return a};
 L.prototype.splice=function(a){var c=this.b,b=this.a?1:-1;this.c==b&&(this.c=-1*b,this.depth+=this.c*(this.a?-1:1));this.a=!this.a;L.prototype.next.call(this);this.a=!this.a;for(var b=arguments[0],d=i(b),b="array"==d||"object"==d&&"number"==typeof b.length?arguments[0]:arguments,d=b.length-1;0<=d;d--)c.parentNode&&c.parentNode.insertBefore(b[d],c.nextSibling);c&&c.parentNode&&c.parentNode.removeChild(c)};function N(a,c,b,d){L.call(this,a,c,b,f,d)}j(N,L);N.prototype.next=function(){do N.f.next.call(this);while(-1==this.c);return this.b};function O(a,c){return!!a&&1==a.nodeType&&(!c||a.tagName.toUpperCase()==c)}function P(a){return O(a,"OPTION")?!0:O(a,"INPUT")?(a=a.type.toLowerCase(),"checkbox"==a||"radio"==a):g}var Q={"class":"className",readonly:"readOnly"},R=["checked","disabled","draggable","hidden"];
 function S(a,c){var b=Q[c]||c,d=a[b];if(void 0===d&&0<=u(R,b))return g;if(b="value"==c)if(b=O(a,"OPTION")){var e;b=c.toLowerCase();if(a.hasAttribute)e=a.hasAttribute(b);else try{e=a.attributes[b].specified}catch(Y){e=g}b=!e}b&&(d=[],I(a,d,g),d=d.join(""));return d}var T="async,autofocus,autoplay,checked,compact,complete,controls,declare,defaultchecked,defaultselected,defer,disabled,draggable,ended,formnovalidate,hidden,indeterminate,iscontenteditable,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,paused,pubdate,readonly,required,reversed,scoped,seamless,seeking,selected,spellcheck,truespeed,willvalidate".split(",");
--- a/testing/marionette/client/marionette/marionette.py
+++ b/testing/marionette/client/marionette/marionette.py
@@ -65,17 +65,17 @@ class HTMLElement(object):
 
     def find_element(self, method, target):
         return self.marionette.find_element(method, target, self.id)
 
     def find_elements(self, method, target):
         return self.marionette.find_elements(method, target, self.id)
 
     def get_attribute(self, attribute):
-        return self.marionette._send_message('getAttributeValue', 'value', element=self.id, name=attribute)
+        return self.marionette._send_message('getElementAttribute', 'value', element=self.id, name=attribute)
 
     def click(self):
         return self.marionette._send_message('clickElement', 'ok', element=self.id)
 
     def text(self):
         return self.marionette._send_message('getElementText', 'value', element=self.id)
 
     def send_keys(self, string):
--- a/testing/marionette/marionette-actors.js
+++ b/testing/marionette/marionette-actors.js
@@ -840,28 +840,28 @@ MarionetteDriverActor.prototype = {
   /**
    * Get a given attribute of an element
    *
    * @param object aRequest
    *        'element' member holds the reference id to
    *        the element that will be inspected
    *        'name' member holds the name of the attribute to retrieve
    */
-  getAttributeValue: function MDA_getAttributeValue(aRequest) {
+  getElementAttribute: function MDA_getElementAttribute(aRequest) {
     if (this.context == "chrome") {
       try {
         let el = this.curBrowser.elementManager.getKnownElement(aRequest.element, this.getCurrentWindow());
-        this.sendResponse(utils.getAttributeValue(el, aRequest.name));
+        this.sendResponse(utils.getElementAttribute(el, aRequest.name));
       }
       catch (e) {
         this.sendError(e.message, e.num, e.stack);
       }
     }
     else {
-      this.sendAsync("getAttributeValue", {element: aRequest.element, name: aRequest.name});
+      this.sendAsync("getElementAttribute", {element: aRequest.element, name: aRequest.name});
     }
   },
 
   /**
    * Get the text of an element, if any. Includes the text of all child elements.
    *
    * @param object aRequest
    *        'element' member holds the reference id to
@@ -1132,17 +1132,17 @@ MarionetteDriverActor.prototype.requestT
   "executeScript": MarionetteDriverActor.prototype.execute,
   "setScriptTimeout": MarionetteDriverActor.prototype.setScriptTimeout,
   "executeAsyncScript": MarionetteDriverActor.prototype.executeWithCallback,
   "executeJSScript": MarionetteDriverActor.prototype.executeJSScript,
   "setSearchTimeout": MarionetteDriverActor.prototype.setSearchTimeout,
   "findElement": MarionetteDriverActor.prototype.findElement,
   "findElements": MarionetteDriverActor.prototype.findElements,
   "clickElement": MarionetteDriverActor.prototype.clickElement,
-  "getAttributeValue": MarionetteDriverActor.prototype.getAttributeValue,
+  "getElementAttribute": MarionetteDriverActor.prototype.getElementAttribute,
   "getElementText": MarionetteDriverActor.prototype.getElementText,
   "isElementDisplayed": MarionetteDriverActor.prototype.isElementDisplayed,
   "isElementEnabled": MarionetteDriverActor.prototype.isElementEnabled,
   "isElementSelected": MarionetteDriverActor.prototype.isElementSelected,
   "sendKeysToElement": MarionetteDriverActor.prototype.sendKeysToElement,
   "clearElement": MarionetteDriverActor.prototype.clearElement,
   "goUrl": MarionetteDriverActor.prototype.goUrl,
   "getUrl": MarionetteDriverActor.prototype.getUrl,
--- a/testing/marionette/marionette-listener.js
+++ b/testing/marionette/marionette-listener.js
@@ -56,17 +56,17 @@ function startListeners() {
   addMessageListener("Marionette:goUrl" + listenerId, goUrl);
   addMessageListener("Marionette:getUrl" + listenerId, getUrl);
   addMessageListener("Marionette:goBack" + listenerId, goBack);
   addMessageListener("Marionette:goForward" + listenerId, goForward);
   addMessageListener("Marionette:refresh" + listenerId, refresh);
   addMessageListener("Marionette:findElementContent" + listenerId, findElementContent);
   addMessageListener("Marionette:findElementsContent" + listenerId, findElementsContent);
   addMessageListener("Marionette:clickElement" + listenerId, clickElement);
-  addMessageListener("Marionette:getAttributeValue" + listenerId, getAttributeValue);
+  addMessageListener("Marionette:getElementAttribute" + listenerId, getElementAttribute);
   addMessageListener("Marionette:getElementText" + listenerId, getElementText);
   addMessageListener("Marionette:isElementDisplayed" + listenerId, isElementDisplayed);
   addMessageListener("Marionette:isElementEnabled" + listenerId, isElementEnabled);
   addMessageListener("Marionette:isElementSelected" + listenerId, isElementSelected);
   addMessageListener("Marionette:sendKeysToElement" + listenerId, sendKeysToElement);
   addMessageListener("Marionette:clearElement" + listenerId, clearElement);
   addMessageListener("Marionette:switchToFrame" + listenerId, switchToFrame);
   addMessageListener("Marionette:deleteSession" + listenerId, deleteSession);
@@ -113,17 +113,17 @@ function deleteSession(msg) {
   removeMessageListener("Marionette:goUrl" + listenerId, goUrl);
   removeMessageListener("Marionette:getUrl" + listenerId, getUrl);
   removeMessageListener("Marionette:goBack" + listenerId, goBack);
   removeMessageListener("Marionette:goForward" + listenerId, goForward);
   removeMessageListener("Marionette:refresh" + listenerId, refresh);
   removeMessageListener("Marionette:findElementContent" + listenerId, findElementContent);
   removeMessageListener("Marionette:findElementsContent" + listenerId, findElementsContent);
   removeMessageListener("Marionette:clickElement" + listenerId, clickElement);
-  removeMessageListener("Marionette:getAttributeValue" + listenerId, getAttributeValue);
+  removeMessageListener("Marionette:getElementAttribute" + listenerId, getElementAttribute);
   removeMessageListener("Marionette:getElementText" + listenerId, getElementText);
   removeMessageListener("Marionette:isElementDisplayed" + listenerId, isElementDisplayed);
   removeMessageListener("Marionette:isElementEnabled" + listenerId, isElementEnabled);
   removeMessageListener("Marionette:isElementSelected" + listenerId, isElementSelected);
   removeMessageListener("Marionette:sendKeysToElement" + listenerId, sendKeysToElement);
   removeMessageListener("Marionette:clearElement" + listenerId, clearElement);
   removeMessageListener("Marionette:switchToFrame" + listenerId, switchToFrame);
   removeMessageListener("Marionette:deleteSession" + listenerId, deleteSession);
@@ -482,20 +482,20 @@ function clickElement(msg) {
   catch (e) {
     sendError(e.message, e.num, e.stack);
   }
 }
 
 /**
  * Get a given attribute of an element
  */
-function getAttributeValue(msg) {
+function getElementAttribute(msg) {
   try {
     let el = elementManager.getKnownElement(msg.json.element, win);
-    sendResponse({value: utils.getAttributeValue(el, msg.json.name)});
+    sendResponse({value: utils.getElementAttribute(el, msg.json.name)});
   }
   catch (e) {
     sendError(e.message, e.num, e.stack);
   }
 }
 
 /**
  * Get the text of this element. This includes text from child elements.