How to use markFunction method in Cypress

Best JavaScript code snippet using cypress

core.js

Source:core.js Github

copy

Full Screen

...110 * Event on 因为这里需要处理 e.target的tame问题,所以需要额外做一些事情111 * Event remove 参考 Event on的写法, by 石霸112 * @author 承玉113 */114 var Event_On = frameGroup.markFunction(function (s, event, handle, scope) {115 var wrapper = genWrapper();116 wrapper.handle = handle;117 handle.__event_tag = handle.__event_tag || [];118 var els = query(s);119 S.each(els, function (el) {120 handle.__event_tag.push({121 fn: wrapper,122 el: el,123 scope: scope || el124 });125 });126 S.Event.on(els, event, wrapper, scope);127 });128 var Event_Delegate = frameGroup.markFunction(function (s, event, filter, handle, scope) {129 var wrapper = genWrapper();130 wrapper.handle = handle;131 handle.__event_tag = handle.__event_tag || [];132 var els = query(s);133 S.each(els, function (el) {134 handle.__event_tag.push({135 fn: wrapper,136 el: el,137 filter: filter,138 scope: scope || el139 });140 });141 S.Event.delegate(els, event, filter, wrapper, scope);142 });143 var Event_Remove = frameGroup.markFunction(function (s, event, handle, scope) {144 var els = query(s);145 if (handle) {146 var wrappers = handle.__event_tag || [];147 for (var i = wrappers.length - 1; i >= 0; i--) {148 var w = wrappers[i];149 var tScope = scope || w.el;150 if (w.scope === tScope &&151 S.inArray(w.el, els)) {152 S.Event.remove(w.el, event, w.fn, scope);153 wrappers.splice(i, 1);154 }155 }156 } else {157 S.Event.remove(els, event);158 }159 });160 //on和detach 手动转发给Event.on 和 Event.detach161 SafeNodeList.prototype.on = function (event, handle, scope) {162 var self = this;163 var s = self.inner.getDOMNodes();164 Event_On(s, event, handle, scope);165 return this;166 };167 //on和detach 手动转发给Event.on 和 Event.detach168 SafeNodeList.prototype.delegate = function (event, filter, handle, scope) {169 var self = this;170 var s = self.inner.getDOMNodes();171 Event_Delegate(s, event,filter, handle, scope);172 return this;173 };174 SafeNodeList.prototype.detach = function (event, handle, scope) {175 var self = this;176 var s = self.inner.getDOMNodes();177 Event_Remove(s, event, handle, scope);178 return this;179 };180 /**181 * getDOMNodes tame一下182 */183 SafeNodeList.prototype.getDOMNodes = function () {184 var l = [];185 S.each(this.inner.getDOMNodes(), function (a) {186 l.push(tame(a));187 });188 return l;189 };190 SafeNodeList.prototype.getDOMNode = function () {191 return tame(this.inner.getDOMNode());192 };193 SafeNodeList.prototype.each = function (fnc) {194 this.inner.each(function(item,index){195 fnc.call(SafeNodeList, new SafeNodeList(item),index);196 });197 return this;198 };199 SafeNodeList.prototype.slice = function (p1, p2) {200 return new SafeNodeList(this.inner.slice(p1, p2));201 };202 SafeNodeList.prototype.stop = function () {203 this.inner.stop.apply(this.inner,arguments);204 return this;205 };206 SafeNodeList.prototype.remove = function () {207 this.inner.remove();208 return this;209 };210 SafeNodeList.prototype.scrollIntoView = function () {211 var p = S.makeArray(arguments);212 if(p[2]){213 p[2] = query(p[2]);214 }215 this.inner.scrollIntoView.apply(this.inner,p);216 return this;217 };218 SafeNodeList.prototype.val = function () {219 if(arguments[0] !== undefined){220 this.inner.val (arguments[0]);221 return this;222 }else{223 return this.inner.val();224 }225 };226 SafeNodeList.prototype.text = function () {227 if(arguments[0]){228 this.inner.text (arguments[0]);229 return this;230 }else{231 return this.inner.text();232 }233 };234 SafeNodeList.prototype.offset = function () {235 return this.inner.offset();236 };237 SafeNodeList.prototype.replaceWith = function (replace) {238 if (replace.inner) {239 this.inner.replaceWith(replace.inner);240 } else {241 this.inner.replaceWith(query(replace));242 }243 return this;244 };245 SafeNodeList.prototype.empty = function () {246 this.inner.empty();247 return this;248 };249 /**250 * node接口中,有使用到选择器的部分,都用query限定下范围251 */252 S.each(('appendTo prependTo insertBefore insertAfter').split(' '), function (fn) {253 SafeNodeList.prototype[fn] = function (sel) {254 if(sel.inner){255 sel = sel.inner;256 }257 this.inner[fn](query(sel));258 return this;259 };260 });261 /**262 * node接口中,attr ,data都只允许获得自定义属性263 */264 SafeNodeList.prototype.data = function (name, value) {265 if (value === undefined) {266 return this.inner.data(name);267 } else {268 this.inner.data(name, cajaAFTB.untame(value));269 return this;270 }271 };272 SafeNodeList.prototype.removeData = function (name) {273 this.inner.removeData(name)274 return this;275 };276 SafeNodeList.prototype.hasData = function ( name, value) {277 return this.inner.hasData(name, cajaAFTB.untame(value));278 };279 SafeNodeList.prototype.add = function (sel) {280 if(sel.inner){281 return new SafeNodeList(this.inner.add(sel.inner))282 }else{283 return new SafeNodeList(this.inner.add(query(sel)))284 }285 };286 SafeNodeList.prototype.parent = function (filter) {287 filter = filter || 1;288 if (S.isNumber(filter) || S.isString(filter)) {289 var p = this.inner.parent(filter);290 if (S.one(param.mod).contains(p)) {291 return new SafeNodeList(p);292 } else {293 return new SafeNodeList(param.mod);294 }295 } else {296 S.log("only string or number is supported");297 return this;298 }299 };300 SafeNodeList.prototype.attr = function (name, value) {301 if (S.startsWith(name, 'data-')) {302 if (undefined === value) {303 return this.inner.attr(name);304 } else {305 this.inner.attr(name, value);306 return this;307 }308 } else {309 S.log('data-开头的伪属性才被支持!')310 }311 };312 SafeNodeList.prototype.removeAttr = function (name) {313 if (S.startsWith(name, 'data-')) {314 this.inner.removeAttr(name);315 return this;316 } else {317 S.log('data-开头的伪属性才被支持!')318 }319 };320 SafeNodeList.prototype.hasAttr = function (sel, name, value) {321 if (S.isString(name) && S.startsWith(name, 'data-')) {322 return this.inner.hasAttr(query(sel), name, cajaAFTB.untame(value));323 }324 };325 /**326 * NodeList 支持的filter,第二个参数都支持函数, 这里面为了简单,先去掉函数的支持,只支持选择器过滤规则327 */328 S.each(('filter next prev first last siblings children').split(' '), function (fn) {329 SafeNodeList.prototype[ fn] = function (filter) {330 if (!S.isFunction(filter)) {331 return new SafeNodeList(this.inner[fn](filter));332 } else {333 S.log('filter参数必须是字符串');334 return this;335 }336 }337 });338 SafeNodeList.prototype.len = function () {339 return this.inner.length;340 };341 SafeNodeList.prototype.scrollTop = function (a) {342 return this.inner.scrollTop(a)343 };344 SafeNodeList.prototype.innerWidth = function () {345 return this.inner.innerWidth ()346 };347 SafeNodeList.prototype.innerHeight = function () {348 return this.inner.innerHeight ()349 };350 SafeNodeList.prototype.outerWidth = function () {351 return this.inner.outerWidth ()352 };353 SafeNodeList.prototype.outerHeight = function () {354 return this.inner.outerHeight ()355 };356 SafeNodeList.prototype.pause = function (p) {357 this.inner.pause(p);358 return this;359 };360 SafeNodeList.prototype.isPaused = function (p) {361 return this.inner.isPaused();362 };363 SafeNodeList.prototype.isRunning = function (p) {364 return this.inner.isRunning();365 };366 SafeNodeList.prototype.resume = function (p) {367 this.inner.resume (p);368 return this;369 };370 SafeNodeList.prototype.isPaused = function (p) {371 return this.inner.isPaused();372 };373 SafeNodeList.prototype.contains = function (sel) {374 if(sel.inner){375 return this.inner.contains (sel.inner)376 }else{377 return this.inner.contains (query(sel))378 }379 };380 SafeNodeList.prototype.scrollLeft = function (a) {381 return this.inner.scrollLeft(a)382 };383 SafeNodeList.prototype.height = function (a) {384 return this.inner.height(a)385 };386 SafeNodeList.prototype.width = function (a) {387 return this.inner.width(a)388 };389 SafeNodeList.prototype.fire = function () {390 this.inner.fire.apply(this.inner,arguments);391 return this;392 };393 S.each(('show hide toggle fadeIn fadeOut fadeToggle slideDown slideUp slideToggle').split(' '), function (fn) {394 SafeNodeList.prototype[fn] = function () {395 this.inner[fn].apply(this.inner, arguments);396 return this;397 }398 });399 SafeNodeList.prototype.animate = function () {400 var args = S.makeArray(arguments);401 if (S.isObject(args[0])) {402 args[0] = cajaAFTB.untame(args[0]);403 }404 this.inner.animate(args[0], args[1], args[2], args[3]);405 return this;406 };407 SafeNodeList.prototype.addClass = function (sel) {408 this.inner.addClass(sel);409 return this410 };411 SafeNodeList.prototype.hasClass = function (param) {412 return this.inner.hasClass(param);413 };414 SafeNodeList.prototype.removeClass = function (param) {415 this.inner.removeClass(param);416 return this;417 };418 SafeNodeList.prototype.toggleClass = function (param) {419 this.inner.toggleClass(param);420 return this;421 };422 SafeNodeList.prototype.replaceClass = function (p1, p2) {423 this.inner.replaceClass(p1, p2);424 return this;425 };426 SafeNodeList.prototype.equals = function (param) {427 return this.inner.equals(param.inner);428 };429 SafeNodeList.prototype.all = function (param) {430 //kissy中只有one,all,end会出现__parent431 var result = new SafeNodeList(this.inner.all(param));432 if(this.inner.all(param).__parent){433 result.inner.__parent = this.inner.all(param).__parent;434 }435 return result;436 };437 SafeNodeList.prototype.end = function () {438 return new SafeNodeList(this.inner.end());439 };440 SafeNodeList.prototype.item = function (index) {441 return new SafeNodeList(this.inner.item(index));442 };443 SafeNodeList.prototype.index = function () {444 return this.inner.index(arguments[0]);445 };446 SafeNodeList.prototype.clone = function () {447 return new SafeNodeList(this.inner.clone.apply(this.inner, arguments));448 };449 SafeNodeList.prototype.test = function (filter) {450 if (S.isFunction(filter)) {451 this.inner.test(function (a, b) {452 return filter(tame(a), b);453 });454 } else {455 return this.inner.test(filter, param.mod);456 }457 };458 S.each(nodeFuncs, function (func) {459 frameGroup.grantMethod(SafeNodeList, func);460 });461 return {462 /**463 * 一些kissy提供的方法464 */465 unparam: frameGroup.markFunction(function (str) {466 return S.unparam(str);467 }),468 param: frameGroup.markFunction(function (o, seq, eq, arr) {469 return S.param(cajaAFTB.untame(o), seq, eq, arr);470 }),471 unEscapeHTML: frameGroup.markFunction(function (str) {472 return S.unEscapeHTML(str);473 }),474 escapeHTML: frameGroup.markFunction(function (str) {475 return S.escapeHTML(str);476 }),477 substitute: frameGroup.markFunction(function (str, o) {478 return S.substitute(str, cajaAFTB.untame(o));479 }),480 DOM: {481 //get, 即query[0]482 get: frameGroup.markFunction(function (s, context) {483 var ret = query(s, context);484 return tame(ret[0], true);485 }),486 // 提供选择器功能487 query: frameGroup.markFunction(function (s, context) {488 var ret = query(s, context);489 // imports.document.compareDocumentPosition 不存在 bug!490 // 索性用 html ,反正店铺模块不能写 head491 // body 不行,body.contains 与 body.compareDocumentPosition 都没!492 // 不能用 imports , firefox/ie 不行493 S.each(ret, function (v, i) {494 // 手动 tame,框架保证返回数据无害!495 ret[i] = tame(v, true);496 });497 return ret;498 }),499 // 兼容性处理,读取or设置元素 text500 text: frameGroup.markFunction(function (s, value) {501 return S.DOM.text(query(s), value);502 }),503 // 兼容性处理,读取or设置元素坐标504 offset: frameGroup.markFunction(function (s, value) {505 return S.DOM.offset(query(s), value);506 }),507 hasClass: frameGroup.markFunction(function (s, value) {508 return S.DOM.hasClass(query(s), value);509 }),510 addClass: frameGroup.markFunction(function (s, value) {511 return S.DOM.addClass(query(s), value);512 }),513 removeClass: frameGroup.markFunction(function (s, value) {514 return S.DOM.removeClass(query(s), value);515 }),516 toggleClass: frameGroup.markFunction(function (s, value) {517 return S.DOM.toggleClass(query(s), value);518 }),519 replaceClass: frameGroup.markFunction(function (s, oc, nc) {520 return S.DOM.replaceClass(query(s), oc, nc);521 }),522 data: frameGroup.markFunction(function (selector, name, value) {523 return S.DOM.data(query(selector), name, cajaAFTB.untame(value));524 }),525 hasData: frameGroup.markFunction(function (selector, name) {526 return S.DOM.hasData(query(selector), name);527 }),528 removeData: frameGroup.markFunction(function (selector, name) {529 return S.DOM.removeData(query(selector), name)530 }),531 attr: frameGroup.markFunction(function (selector, name, value) {532 if (S.isString(name) && S.startsWith(name, 'data-')) {533 return S.DOM.attr(query(selector), name, value);534 }535 }),536 hasAttr: frameGroup.markFunction(function (selector, name) {537 return S.DOM.hasAttr(query(selector), name);538 }),539 removeAttr: frameGroup.markFunction(function (selector, name) {540 if (S.isString(name) && S.startsWith(name, 'data-')) {541 return S.DOM.removeAttr(query(selector), name);542 }543 }),544 css: frameGroup.markFunction(function (s, name, value) {545 var el = query(s);546 S.each(el,function(v,k){547 var result = cajaAFTB.checkCss(v, name, value);548 if (true === result) {549 DOM.css(v, name, value);550 }else{551 S.log(result);552 }553 })554 })555 },556 io: frameGroup.markFunction(function (cfg) {557 var untamedcfg = cajaAFTB.untame(cfg);558 untamedcfg.data = cajaAFTB.untame(untamedcfg.data);559 var url = untamedcfg.url;560 if(url.charAt(0)!=="/" && url.indexOf('./') !== 0){561 url = cajaAFTB.rewriteURL(url, null, null, {XML_ATTR: "href"});562 }563 //这里处理下,目前只支持json或者jsonp的形式564 if (!('json' === untamedcfg.dataType || 'jsonp' === untamedcfg.dataType)) {565 untamedcfg.dataType = "jsonp";566 }567 if (url) {568 return S.io(untamedcfg);569 } else {570 return function () {571 S.log('url 不在白名单中.')572 };573 }574 }),575 UA: S.clone(S.UA),576 log: frameGroup.markFunction(function () {577 S.log.apply(S, arguments);578 }),579 // 提供批量注册事件功能580 Event: {581 add: Event_On,582 on: Event_On,583 remove: Event_Remove,584 detach: Event_Remove,585 delegate: Event_Delegate,586 fire: frameGroup.markFunction(function (s, event) {587 S.Event.fire(query(s), event);588 })589 },590 // 提供动画方便功能591 Anim: frameGroup.markFunction(function () {592 var args = S.makeArray(arguments);593 args[0] = query(args[0])[0];594 if (S.isObject(args[1])) {595 args[1] = cajaAFTB.untame(args[1]);596 }597 return S.Anim.apply(window, args);598 }),599 JSON: {600 parse: frameGroup.markFunction(function (text) {601 return S.JSON.parse(text);602 }),603 stringify: frameGroup.markFunction(function (value) {604 return S.JSON.stringify(cajaAFTB.untame(value));605 })606 },607 all: frameGroup.markFunction(function () {608 return new SafeNodeList(query(arguments[0]));609 }),610 alert: frameGroup.markFunction(function (x) {611 alert(x);612 }),613 kissy:true614 };615 }616 }617 return init;618}, {619 requires: ['core']...

Full Screen

Full Screen

kissy-adapter.js

Source:kissy-adapter.js Github

copy

Full Screen

...143 * Event on ÒòΪÕâÀïÐèÒª´¦Àí e.targetµÄtameÎÊÌ⣬ËùÒÔÐèÒª¶îÍâ×öһЩÊÂÇé144 * Event remove ²Î¿¼ Event onµÄд·¨£¬ by ʯ°Ô145 * @author ³ÐÓñ146 */147 var Event_On = frameGroup.markFunction(function (s, event, handle, scope) {148 var wrapper = genWrapper();149 wrapper.handle = handle;150 handle.__event_tag = handle.__event_tag || [];151 var els = query(s);152 S.each(els, function (el) {153 handle.__event_tag.push({154 fn: wrapper,155 el: el,156 scope: scope || el157 });158 });159 S.Event.on(els, event, wrapper, scope);160 });161 var Event_Remove = frameGroup.markFunction(function (s, event, handle, scope) {162 var els = query(s);163 if (handle) {164 var wrappers = handle.__event_tag || [];165 for (var i = wrappers.length - 1; i >= 0; i--) {166 var w = wrappers[i];167 var tScope = scope || w.el;168 if (w.scope === tScope &&169 S.inArray(w.el, els)) {170 S.Event.remove(w.el, event, w.fn, scope);171 wrappers.splice(i, 1);172 }173 }174 } else {175 S.Event.remove(els, event);176 }177 });178 //onºÍdetach ÊÖ¶¯×ª·¢¸øEvent.on ºÍ Event.detach179 S.NodeList.prototype.c_on = function (event, handle, scope) {180 var self = this;181 var s = self.getDOMNodes();182 Event_On(s, event, handle, scope);183 return this;184 };185 S.NodeList.prototype.c_detach = function (event, handle, scope) {186 var self = this;187 var s = self.getDOMNodes();188 Event_Remove(s, event, handle, scope);189 return this;190 };191 /**192 * getDOMNodes tameÒ»ÏÂ193 */194 S.NodeList.prototype.c_getDOMNodes = function () {195 var l = [];196 S.each(this.getDOMNodes(), function (a) {197 l.push(tame(a));198 });199 return l;200 };201 /**202 * node½Ó¿ÚÖУ¬ÓÐʹÓõ½Ñ¡ÔñÆ÷µÄ²¿·Ö£¬¶¼ÓÃqueryÏÞ¶¨Ï·¶Î§203 */204 S.each(('add appendTo prependTo insertBefore insertAfter').split(' '), function (fn) {205 S.NodeList.prototype['c_' + fn] = function (sel) {206 return this[fn](query(sel))207 };208 });209 /**210 * NodeList Ö§³ÖµÄfilter£¬µÚ¶þ¸ö²ÎÊý¶¼Ö§³Öº¯Êý, ÕâÀïÃæΪÁ˼òµ¥£¬ÏÈÈ¥µôº¯ÊýµÄÖ§³Ö£¬Ö»Ö§³ÖÑ¡ÔñÆ÷¹ýÂ˹æÔò211 */212 S.each(('filter next prev first last siblings children').split(' '), function (fn) {213 S.NodeList.prototype['c_' + fn] = function (filter) {214 if (!S.isFunction(filter)) {215 return this[fn](filter);216 } else {217 S.error('filter²ÎÊý±ØÐëÊÇ×Ö·û´®');218 return this;219 }220 }221 });222 S.NodeList.prototype.len = function () {223 return this.length;224 };225 S.NodeList.prototype.c_animate = function () {226 var args = S.makeArray(arguments);227 if (S.isObject(args[0])) {228 args[0] = untame(args[0]);229 }230 return this.animate(args[0], args[1], args[2], args[3]);231 };232 S.NodeList.prototype.c_addClass = function (sel) {233 return this.addClass(sel);234 }235 S.each(nodeFuncs, function (func) {236 frameGroup.grantMethod(S.NodeList, func);237 });238 var expose_kissy = {239 /**240 * һЩkissyÌṩµÄ·½·¨241 */242 unparam: frameGroup.markFunction(function (str) {243 return S.unparam(str);244 }),245 param: frameGroup.markFunction(function (o, seq, eq, arr) {246 return S.param(untame(o), seq, eq, arr);247 }),248 unEscapeHTML: frameGroup.markFunction(function (str) {249 return S.unEscapeHTML(str);250 }),251 escapeHTML: frameGroup.markFunction(function (str) {252 return S.escapeHTML(str);253 }),254 substitute: frameGroup.markFunction(function (str, o) {255 return S.substitute(str, untame(o));256 }),257 DOM: {258 //get, ¼´query[0]259 get: frameGroup.markFunction(function (s, context) {260 var ret = query(s, context);261 return tame(ret[0], true);262 }),263 // ÌṩѡÔñÆ÷¹¦ÄÜ264 query: frameGroup.markFunction(function (s, context) {265 var ret = query(s, context);266 // imports.document.compareDocumentPosition ²»´æÔÚ bug£¡267 // Ë÷ÐÔÓà html £¬·´ÕýµêÆÌÄ£¿é²»ÄÜд head268 // body ²»ÐУ¬body.contains Óë body.compareDocumentPosition ¶¼Ã»£¡269 // ²»ÄÜÓà imports , firefox/ie ²»ÐÐ270 S.each(ret, function (v, i) {271 // ÊÖ¶¯ tame£¬¿ò¼Ü±£Ö¤·µ»ØÊý¾ÝÎÞº¦£¡272 ret[i] = tame(v, true);273 });274 return ret;275 }),276 // ¼æÈÝÐÔ´¦Àí£¬¶ÁÈ¡orÉèÖÃÔªËØ text277 text: frameGroup.markFunction(function (s, value) {278 return S.DOM.text(query(s), value);279 }),280 // ¼æÈÝÐÔ´¦Àí£¬¶ÁÈ¡orÉèÖÃÔªËØ×ø±ê281 offset: frameGroup.markFunction(function (s, value) {282 return S.DOM.offset(query(s), value);283 }),284 //Ä¿Ç°Õâ¸ö½Ó¿ÚÏÈÈ¥µô£¬ÒòΪûÓÐ×öУÑé285 //2013Äê1ÔÂ25ÈÕ Ìṩ¶Á½Ó¿Ú286 css: frameGroup.markFunction(function (s, prop) {287 return S.DOM.css(query(s), prop);288 }),289 hasClass: frameGroup.markFunction(function (s, value) {290 return S.DOM.hasClass(query(s), value);291 }),292 addClass: frameGroup.markFunction(function (s, value) {293 return S.DOM.addClass(query(s), value);294 }),295 removeClass: frameGroup.markFunction(function (s, value) {296 return S.DOM.removeClass(query(s), value);297 }),298 toggleClass: frameGroup.markFunction(function (s, value) {299 return S.DOM.toggleClass(query(s), value);300 }),301 replaceClass: frameGroup.markFunction(function (s, oc, nc) {302 return S.DOM.replaceClass(query(s), oc, nc);303 })304 },305 io: frameGroup.markFunction(function (cfg) {306 var untamedcfg = untame(cfg);307 untamedcfg.data = untame(untamedcfg.data);308 var url = untamedcfg.url, flag = false;309 url = parseURL(url).url;310 S.each(urlIO, function (reg) {311 if (reg.test(url)) {312 flag = true;313 }314 });315 //ÕâÀï´¦ÀíÏ£¬Ä¿Ç°Ö»Ö§³Öjson»òÕßjsonpµÄÐÎʽ316 if (!('json' === untamedcfg.dataType || 'jsonp' === untamedcfg.dataType)) {317 untamedcfg.dataType = "jsonp";318 }319 if (flag) {320 return S.io(S.mix(untamedcfg));321 } else {322 return function () {323 //ÕâÀïÒԺ󶼼ÓÒ»¸öÒì³£º¯Êý£¬Í³Ò»´¦Àí324 };325 }326 }),327 UA: S.clone(S.UA),328 log: frameGroup.markFunction(function () {329 S.log.apply(S, arguments);330 }),331 // ÌṩÅúÁ¿×¢²áʼþ¹¦ÄÜ332 Event: {333 add: Event_On,334 on: Event_On,335 remove: Event_Remove,336 detach: Event_Remove,337 fire: frameGroup.markFunction(function (s, event) {338 S.Event.fire(query(s), event);339 })340 },341 // Ìṩ¶¯»­·½±ã¹¦ÄÜ342 Anim: frameGroup.markFunction(function () {343 var args = S.makeArray(arguments);344 args[0] = query(args[0])[0];345 if (S.isObject(args[1])) {346 args[1] = untame(args[1]);347 }348 return S.Anim.apply(window, args);349 }),350 JSON: {351 parse: frameGroup.markFunction(function (text) {352 return S.JSON.parse(text);353 }),354 stringify: frameGroup.markFunction(function(value){355 return S.JSON.stringify(untame(value));356 })357 },358 all: frameGroup.markFunction(function () {359 return S.all(query(arguments[0]));360 }),361 alert: frameGroup.markFunction(function (x) {362 alert(x);363 })364 };365 if(cajaConfig.kissy && false === cajaConfig.kissy.io){366 S.mix(expose_kissy, {io:function(){}});367 }368 return frameGroup.tame(expose_kissy);369 };370 };371 window.cajaAFTB = cajaAFTB;...

Full Screen

Full Screen

test-taming-tamed.js

Source:test-taming-tamed.js Github

copy

Full Screen

...45 };46 api.setReadOnlyRecordField = function(k, v) {47 api.readOnlyRecord[k] = v;48 };49 frame.markFunction(api.setReadOnlyRecordField,50 'setReadOnlyRecordField');51 frame.markReadOnlyRecord(api.readOnlyRecord);52 ////////////////////////////////////////////////////////////////////////53 // ARRAYS54 api.array = [55 4256 ];57 api.setArrayField = function(i, v) {58 api.array[i] = v;59 };60 // Put a reference to some otherwise well-known nonprimitive in an61 // array, to be sure that this gets tamed properly by the array taming.62 api.array[1] = api.readOnlyRecord;63 frame.markFunction(api.setArrayField, 'setArrayField');64 ////////////////////////////////////////////////////////////////////////65 // READ WRITE RECORDS66 api.readWriteRecord = {67 x: 42,68 17: 'seventeen',69 toxicFunctionProperty: function() {},70 __proto__: 4271 };72 api.setReadWriteRecordField = function(k, v) {73 api.readWriteRecord[k] = v;74 };75 frame.markFunction(api.setReadWriteRecordField,76 'setReadWriteRecordField');77 ////////////////////////////////////////////////////////////////////////78 // FUNCTIONS RETURNING PRIMITIVES79 api.functionReturningPrimitive = function (x) {80 return x + 42;81 };82 frame.markFunction(api.functionReturningPrimitive,83 'functionReturningPrimitive');84 ////////////////////////////////////////////////////////////////////////85 // CONSTRUCTORS86 // Create a "class and subclass" pair of constructors87 api.Ctor = function Ctor(x) {88 if (!(this instanceof Ctor)) { return "Called as function"; }89 this.x = x;90 this.invisibleProperty = 17;91 this.readOnlyProperty = 19;92 this.readWriteProperty = 23;93 };94 api.Ctor.staticFunction = function(x) {95 return x + 17;96 };97 api.Ctor.prototype.getX = function () {98 return this.x;99 };100 api.Ctor.prototype.setX = function (x) {101 this.x = x;102 };103 api.Ctor.prototype.toxicFunctionProperty = function(x) {104 return "poison";105 };106 api.Ctor.prototype.xo4aTestMethod = function(v) {107 this.xo4aTestValue = v;108 };109 api.Ctor.prototype.readWriteMethod = function(x) {110 this.x = '' + x + 'readWriteMethod';111 };112 api.Ctor.prototype.readOverrideMethod = function(x) {113 this.x = '' + x + 'readOverrideMethod';114 };115 api.Ctor.prototype.readOnlyProperty = 3;116 api.Ctor.prototype.readWriteProperty = 7;117 api.Ctor.prototype.readOverrideProperty = 11;118 api.SubCtor = function SubCtor(x, y) {119 api.Ctor.call(this, x);120 this.y = y;121 }122 api.SubCtor.prototype = new api.Ctor(0);123 api.SubCtor.prototype.constructor = api.SubCtor;124 api.SubCtor.prototype.getY = function () {125 return this.y;126 };127 api.SubCtor.prototype.setY = function (y) {128 this.y = y;129 };130 api.SubCtor.prototype.getMagSquared = function () {131 return this.x * this.x + this.y * this.y;132 };133 api.SubCtor.prototype.toxicSubMethod = function() {134 return "poison";135 };136 api.functionReturningConstructed = function (x) {137 return new api.Ctor(x);138 };139 // Whitelist the 'Ctor' and 'SubCtor' as constructors, and whitelist the140 // methods except the 'toxic' ones.141 frame.grantRead(api.Ctor, 'prototype');142 frame.grantRead(api.Ctor, 'staticFunction');143 frame.markFunction(api.Ctor.staticFunction);144 frame.grantMethod(api.Ctor.prototype, 'getX');145 frame.grantMethod(api.Ctor.prototype, 'setX');146 frame.grantMethod(api.Ctor.prototype, 'xo4aTestMethod');147 frame.grantMethod(api.Ctor.prototype, 'readWriteMethod');148 frame.grantMethod(api.Ctor.prototype, 'readOverrideMethod');149 frame.grantRead(api.Ctor.prototype, 'readOnlyProperty');150 frame.grantReadWrite(api.Ctor.prototype, 'readWriteProperty');151 frame.grantReadWrite(api.Ctor.prototype, 'readWriteMethod');152 frame.grantReadOverride(api.Ctor.prototype, 'readOverrideProperty');153 frame.grantReadOverride(api.Ctor.prototype, 'readOverrideMethod');154 frame.markCtor(api.Ctor, Object, 'Ctor');155 frame.grantMethod(api.SubCtor.prototype, 'getY');156 frame.grantMethod(api.SubCtor.prototype, 'setY');157 frame.grantMethod(api.SubCtor.prototype, 'getMagSquared');158 frame.markCtor(api.SubCtor, api.Ctor, 'SubCtor');159 frame.markFunction(api.functionReturningConstructed,160 'functionReturningConstructed');161 // Create a "wrong" constructor that we do not whitelist162 WrongCtor = function WrongCtor(x) { };163 api.functionReturningWrongConstructed = function (x) {164 return new WrongCtor(x);165 };166 // Whitelist the function returning the "wrong" constructed object167 frame.markFunction(api.functionReturningWrongConstructed,168 'functionReturningWrongConstructed');169 ////////////////////////////////////////////////////////////////////////170 // TOXIC CONSTRUCTORS171 // Create a "class and subclass" pair of constructors that we will ensure172 // the guest code cannot use, even though it can read them.173 api.ToxicCtor = function(x) {174 this.x = x;175 }176 api.ToxicCtor.prototype.getX = function() {177 return this.x;178 };179 api.ToxicSubCtor = function(x, y) {180 api.ToxicCtor.call(this, x);181 this.y = y;182 }183 api.ToxicSubCtor.prototype = new api.ToxicCtor(0);184 api.ToxicSubCtor.prototype.getY = function() {185 return this.y;186 };187 ////////////////////////////////////////////////////////////////////////188 // VARIOUS KINDS OF FUNCTIONS189 api.functionReturningRecord = function (x) {190 return {191 x: x192 };193 };194 api.functionReturningFunction = function (x) {195 return frame.markFunction(function (y) { return x + y; });196 };197 api.functionCallingMyFunction = function (f, x) {198 return f(x);199 };200 api.functionReturningMyFunction = function (f) {201 return f;202 };203 api.pureFunctionReturningThis = function () {204 return this;205 };206 frame.markFunction(api.functionReturningRecord,207 'functionReturningRecord');208 frame.markFunction(api.functionReturningFunction,209 'functionReturningFunction');210 frame.markFunction(api.functionCallingMyFunction,211 'functionCallingMyFunction');212 frame.markFunction(api.functionReturningMyFunction,213 'functionReturningMyFunction');214 frame.markFunction(api.pureFunctionReturningThis,215 'pureFunctionReturningThis');216 ////////////////////////////////////////////////////////////////////////217 // IDENTITY FUNCTION218 api.identity = function(x) {219 return x;220 };221 frame.markFunction(api.identity, 'identity');222 ////////////////////////////////////////////////////////////////////////223 // TOXIC FUNCTIONS224 api.toxicFunction = function() {225 return "poison";226 };227 ////////////////////////////////////////////////////////////////////////228 // EXOPHORIC FUNCTIONS229 api.xo4aUsingThis = function(y) {230 return this.x + y;231 };232 api.xo4aReturningThis = function() {233 return this;234 };235 frame.markXo4a(api.xo4aUsingThis, 'xo4aUsingThis');236 frame.markXo4a(api.xo4aReturningThis, 'xo4aReturningThis');237 ////////////////////////////////////////////////////////////////////////238 // PROPERTIES ON FUNCTIONS239 api.functionWithProperties = function functionWithProperties(x) {240 return x;241 };242 api.functionWithProperties.invisibleProperty = 17;243 api.functionWithProperties.readOnlyProperty = 33;244 api.functionWithProperties.readWriteProperty = 49;245 api.functionWithProperties[17] = 'seventeen';246 api.functionWithProperties.toxicFunctionProperty = function() {};247 api.setReadOnlyPropertyOnFunction = function (x) {248 api.functionWithProperties.readOnlyProperty = x;249 };250 frame.grantRead(api.functionWithProperties, 'readOnlyProperty');251 frame.grantReadWrite(api.functionWithProperties, 'readWriteProperty');252 frame.markFunction(api.functionWithProperties,253 'functionWithProperties');254 frame.markFunction(api.setReadOnlyPropertyOnFunction,255 'setReadOnlyPropertyOnFunction');256 ////////////////////////////////////////////////////////////////////////257 // TAMED eval() RESULT258 api.evalInHostTamed = function(str, a, b) {259 return eval(str);260 }261 frame.markFunction(api.evalInHostTamed, 'evalInHostTamed');262 ////////////////////////////////////////////////////////////////////////263 // EXCEPTIONS264 // For testing errors with nonstandard .name265 // <https://code.google.com/p/google-caja/issues/detail?id=1671>266 function TestCustomNamedError(message) {267 var e = new Error(message);268 e.name = 'TestCustomNamedError';269 return e;270 }271 // Make sure e.message is not a hole in the membrane272 function TestEvilMessageError() {273 var e = new Error('');274 e.message = {toString: function() { return 'mwahaha'; }};275 return e;...

Full Screen

Full Screen

shared.js

Source:shared.js Github

copy

Full Screen

...65 return wrapper.handle.call(this,e);66 }67 return wrapper;68 }69 var Event_On=frameGroup.markFunction(function(s, event, handle, scope) {70 var wrapper=genWrapper();71 wrapper.handle=handle;72 handle.__event_tag = handle.__event_tag || [];73 var els = query(s);74 S.each(els, function(el) {75 handle.__event_tag.push({76 fn:wrapper,77 el:el,78 scope:scope || el79 });80 });81 S.Event.on(els, event, wrapper, scope);82 });83 return frameGroup.tame({84 DOM:{85 // 提供选择器功能86 query:frameGroup.markFunction(function(s,context) {87 var ret = query(s,context);88 // imports.document.compareDocumentPosition 不存在 bug!89 // 索性用 html ,反正店铺模块不能写 head90 // body 不行,body.contains 与 body.compareDocumentPosition 都没!91 // 不能用 imports , firefox/ie 不行 92 S.each(ret, function(v, i) {93 // 手动 tame,框架保证返回数据无害!94 ret[i] = tame(v);95 });96 return ret;97 }),98 css:frameGroup.markFunction(function(s, value) {99 return S.DOM.css(query(s), value);100 }),101 hasClass:frameGroup.markFunction(function(s, value) {102 return S.DOM.hasClass(query(s), value);103 }),104 addClass:frameGroup.markFunction(function(s, value) {105 return S.DOM.addClass(query(s), value);106 }),107 removeClass:frameGroup.markFunction(function(s, value) {108 return S.DOM.removeClass(query(s), value);109 }),110 // 兼容性处理,读取or设置元素 text111 text:frameGroup.markFunction(function(s, value) {112 return S.DOM.text(query(s), value);113 }),114 // 兼容性处理,读取or设置元素坐标115 offset:frameGroup.markFunction(function(s, value) {116 return S.DOM.offset(query(s), value);117 })118 },119 io:{120 },121 UA:S.clone(S.UA),122 log: frameGroup.markFunction(function() {123 S.log.apply(S, arguments);124 }),125 // 提供批量注册事件功能126 Event:{127 add:Event_On,128 on:Event_On,129 remove:frameGroup.markFunction(function(s, event, handle, scope) {130 var els = query(s);131 if (handle) {132 var wrappers = handle.__event_tag || [];133 for (var i = wrappers.length - 1; i >= 0; i--) {134 var w = wrappers[i];135 var tScope = scope || w.el;136 if (w.scope === tScope &&137 S.inArray(w.el, els)) {138 S.Event.remove(w.el, event, w.fn, scope);139 wrappers.splice(i, 1);140 }141 }142 } else {143 S.Event.remove(els, event);144 }145 })146 },147 // 提供动画方便功能148 Anim:frameGroup.markFunction(function() {149 var args = S.makeArray(arguments);150 args[0] = query(args[0]);151 return S.Anim.apply(window, args);152 })153 });154 };...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...19 function wrapper(data) {20 data = cajaAFTB.untame(data);21 if(typeof(data)=="function")22 {23 frameGroup.markFunction(data); 24 }25 return wrapper.handle.call(this, data);26 }27 return wrapper;28 }29 /**30 * @param context 上下文31 * @param context.mod 沙箱的模块范围,所有操作必须限定到模块范围之内去执行32 * @param context.frame 单个模块的沙箱33 * @return {Object} 实际的组件对象34 */35 return function (context) {36 //最终需要返回给37 return {38 TOP:frameGroup.tame({39 //TOP 的 api函数,第一个为string或者object,第二个为coback function,第三个为boolean40 api:frameGroup.markFunction(function(a){41 var param = S.makeArray(arguments);42 if(param.length>3){43 param[2] = cajaAFTB.untame(param[2]);44 var fnc = param[3] ;45 param[3] = frameGroup.markFunction(function(e){46 fnc.call(window.TOP,e);47 });48 }else{49 param[0] = cajaAFTB.untame(param[0]);50 }51 if(window.TOP){52 window.TOP.api.apply(this,param);53 }else{54 S.log('TOP is not included(jssdk script not loaded)');55 }56 }),57 auth:{58 getLoginStatus:frameGroup.markFunction(function(){59 TOP.auth.getLoginStatus.apply(this, arguments);60 }),61 getSession:frameGroup.markFunction(function(){62 return TOP.auth.getSession();63 }),64 getUser:frameGroup.markFunction(function(){65 return TOP.auth.getUser();66 }),67 isAuth:frameGroup.markFunction(function(){68 return TOP.auth.isAuth.apply(this, arguments);69 }),70 isLogin:frameGroup.markFunction(function(){71 return TOP.auth.isLogin.apply(this, arguments);72 })73 },74 ui:frameGroup.markFunction(function(){75 var param = S.makeArray(arguments);76 if(param[0] == "authbtn"){77 param[1] = cajaAFTB.untame(param[1]);78 //封装callback79 var wrapper = genWrapper();80 wrapper.handle = param[1].callback;81 param[1].callback = wrapper;82 //封装onload83 var wrapper1 = genWrapper();84 wrapper1.handle = param[1].onload;85 param[1].onload = wrapper1;86 }87 return TOP.ui(param[0],param[1]);88 })...

Full Screen

Full Screen

desktop.zinos-desktop.controller.js

Source:desktop.zinos-desktop.controller.js Github

copy

Full Screen

...40 }41 };4243 caja.whenReady(function () {44 caja.markFunction(tamedZinOS.Storage.GetRootDirectories);45 caja.markFunction(tamedZinOS.Storage.GetPathContent);46 caja.markFunction(tamedZinOS.Storage.UploadFile);47 caja.markFunction(tamedZinOS.Storage.CreateDir);48 caja.markFunction(tamedZinOS.UI.Prompt);49 caja.markFunction(tamedZinOS.UI.OpenFile);50 caja.markFunction(tamedZinOS.UI.ShowMessageBox);51 caja.markFunction(tamedZinOS.UI.SaveFileDialog);52 caja.markFunction(tamedZinOS.UI.UploadFileDialog);53 caja.markFunction(tamedZinOS.Storage.DeleteFile);54 caja.markFunction(tamedZinOS.Storage.ReadFile);55 caja.markFunction(tamedZinOS.Storage.CreateFile);56 caja.markFunction(tamedZinOS.Storage.WriteToFile);57 });5859 zinOSAppAPI = tamedZinOS;60 };6162 this.Prompt = function (caption, oninput) {63 zinOSDesktopView.PromptWindow(caption, function (inputText) {64 zinOSDesktopView.ClosePromptWindow();65 oninput(inputText);66 });67 };6869 //UploadFile70 this.UploadFile = function (targetPath, onfileselect) { ...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...35};3637var tame = function(frameGroup, api) {38 frameGroup.markReadOnlyRecord(api);39 frameGroup.markFunction(api.getSelection);40 frameGroup.markFunction(api.setSelection);41 frameGroup.markFunction(api.addSelectionListener);42 frameGroup.markReadOnlyRecord(api.data);43 frameGroup.markFunction(api.data.getNumRows);44 frameGroup.markFunction(api.data.getNumCols);45 frameGroup.markFunction(api.data.getColHeader);46 frameGroup.markFunction(api.data.get);47 return frameGroup.tame(api);48};4950var loadGadget = function(frameGroup, tameApi, name, url) {51 var extraOuters = {52 api: tameApi,53 log: frameGroup.tame(frameGroup.markFunction(function(s) {54 log(name + ' (' + url + ') : ' + String(s));55 }))56 };5758 frameGroup.makeES5Frame(addGadgetDiv(name), defaultUriPolicy, function (frame) {59 frame.url(url).run(extraOuters, function (result) { 60 log('Gadget ' + name + ' (' + url + ') loaded');61 });62 });63};6465caja.configure({66 cajaServer: 'http://localhost:8080/',67 debug: true ...

Full Screen

Full Screen

policy.js

Source:policy.js Github

copy

Full Screen

...10 if (!!console && !!console.log) {11 console.log("Time taken: " + number);12 }13 };14 frameGroup.markFunction(recordResult);15 imports.parent = frameGroup.tame({ recordResult: recordResult });16 // TODO(ihab.awad): Consolidate code that tames common browser utilities17 // such as this one.18 imports.console = frameGroup.tame(frameGroup.markReadOnlyRecord({19 log: frameGroup.markFunction(function () {20 console.log.apply(console, arguments);21 }),22 warn: frameGroup.markFunction(function () {23 console.warn.apply(console, arguments);24 }),25 error: frameGroup.markFunction(function () {26 console.error.apply(console, arguments);27 }),28 info: frameGroup.markFunction(function () {29 console.info.apply(console, arguments);30 }),31 profile: frameGroup.markFunction(function () {32 console.profile.apply(console, arguments);33 }),34 profileEnd: frameGroup.markFunction(function () {35 console.profileEnd.apply(console, arguments);36 })37 }));38 });39 return tamings___;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.markFunction('test');2cy.markFunction('test1');3cy.markFunction('test2');4cy.markFunction('test3');5cy.markFunction('test4');6cy.markFunction('test5');7cy.markFunction('test6');8cy.markFunction('test7');9cy.markFunction('test8');10cy.markFunction('test9');11cy.markFunction('test10');12cy.markFunction('test11');13cy.markFunction('test12');14cy.markFunction('test13');15cy.markFunction('test14');16cy.markFunction('test15');17cy.markFunction('test16');18cy.markFunction('test17');19cy.markFunction('test18');20cy.markFunction('test19');21cy.markFunction('test20');22cy.markFunction('test21');23cy.markFunction('test22');24cy.markFunction('test23');25cy.markFunction('test24');26cy.markFunction('test25');27cy.markFunction('test26');28cy.markFunction('test27');29cy.markFunction('test28');30cy.markFunction('test29');31cy.markFunction('test30');32cy.markFunction('test31');33cy.markFunction('test32');34cy.markFunction('test33');35cy.markFunction('test34');36cy.markFunction('test35');37cy.markFunction('test36');38cy.markFunction('test37');39cy.markFunction('test38');40cy.markFunction('test39');41cy.markFunction('test40');42cy.markFunction('test41');43cy.markFunction('test42');44cy.markFunction('test43');45cy.markFunction('test44');46cy.markFunction('test45');47cy.markFunction('test46');48cy.markFunction('test47');49cy.markFunction('test48');50cy.markFunction('

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.mark('markName');2cy.mark('markName');3cy.mark('markName');4cy.mark('markName');5cy.mark('markName');6cy.mark('markName');7cy.mark('markName');8cy.mark('markName');9cy.mark('markName');10cy.mark('markName');11cy.mark('markName');12cy.mark('markName');13cy.mark('markName');14cy.mark('markName');15cy.mark('markName');16cy.mark('markName');17cy.mark('markName');18cy.mark('markName');19cy.mark('markName');20cy.mark('markName');21cy.mark('markName');22cy.mark('markName');23cy.mark('markName');24cy.mark('markName');25cy.mark('markName');26cy.mark('markName');27cy.mark('markName');28cy.mark('markName');

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('markFunction', (name) => {2 cy.window().then(win => {3 win.mark(name);4 });5});6Cypress.Commands.add('measureFunction', () => {7 cy.window().then(win => {8 win.measure();9 });10});11Cypress.Commands.add('clearMarksFunction', () => {12 cy.window().then(win => {13 win.clearMarks();14 });15});16Cypress.Commands.add('clearMeasuresFunction', () => {17 cy.window().then(win => {18 win.clearMeasures();19 });20});21Cypress.Commands.add('getEntriesByNameFunction', (name) => {22 cy.window().then(win => {23 win.getEntriesByName(name);24 });25});26Cypress.Commands.add('getEntriesByTypeFunction', (type) => {27 cy.window().then(win => {28 win.getEntriesByType(type);29 });30});31Cypress.Commands.add('getEntriesFunction', () => {32 cy.window().then(win => {33 win.getEntries();34 });35});36Cypress.Commands.add('getEntriesByTypeFunction', (type) => {37 cy.window().then(win => {38 win.getEntriesByType(type);39 });40});41Cypress.Commands.add('getEntriesByNameFunction', (name) => {42 cy.window().then(win => {43 win.getEntriesByName(name);44 });45});46Cypress.Commands.add('getEntriesByTypeFunction', (type) => {47 cy.window().then(win => {48 win.getEntriesByType(type);49 });50});51Cypress.Commands.add('getEntriesByName

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.markFunction('myFunction');2cy.markFunction('myFunction', { name: 'myFunction' });3cy.markFunction('myFunction', { name: 'myFunction', args: ['arg1', 'arg2'] });4cy.markFunction('myFunction', { name: 'myFunction', args: ['arg1', 'arg2'], options: { color: 'red', lineWidth: 5 } });5cy.markFunction('myFunction', { name: 'myFunction', args: ['arg1', 'arg2'], options: { color: 'red', lineWidth: 5 } }, { name: 'myFunction', args: ['arg1', 'arg2'], options: { color: 'red', lineWidth: 5 } });6cy.markFunction('myFunction', { name: 'myFunction', args: ['arg1', 'arg2'], options: { color: 'red', lineWidth: 5 } }, { name: 'myFunction', args: ['arg1', 'arg2'], options: { color: 'red', lineWidth: 5 } }, { name: 'myFunction', args: ['arg1', 'arg2'], options: { color: 'red', lineWidth: 5 } });7cy.markFunction('myFunction', { name: 'myFunction', args: ['arg1', 'arg2'], options: { color: 'red', lineWidth: 5 } }, { name: 'myFunction', args: ['arg1', 'arg2'], options: { color: 'red', lineWidth: 5 } }, { name: 'myFunction', args: ['arg1', 'arg2'], options: { color: 'red', lineWidth: 5 } }, { name: 'myFunction', args: ['arg1', 'arg2'], options: { color: 'red', lineWidth: 5 } });

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.markFunction('markFunction', { name: 'markFunction' });2cy.markFunctionStart('markFunctionStart', { name: 'markFunctionStart' });3cy.markFunctionEnd('markFunctionEnd', { name: 'markFunctionEnd' });4cy.markFunctionStartEnd('markFunctionStartEnd', { name: 'markFunctionStartEnd' });5cy.markFunction('markFunction', { name: 'markFunction' });6cy.markFunctionStart('markFunctionStart', { name: 'markFunctionStart' });7cy.markFunctionEnd('markFunctionEnd', { name: 'markFunctionEnd' });8cy.markFunctionStartEnd('markFunctionStartEnd', { name: 'markFunctionStartEnd' });9module.exports = (on, config) => {10 on('task', {11 markFunction: require('cypress-performance/tasks/markFunction'),12 });13};

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.markFunction('Function to be tested');2cy.markFunction('Function to be tested');3cy.markFunction('Function to be tested');4cy.markFunction('Function to be tested');5cy.markFunction('Function to be tested');6cy.markFunction('Function to be tested');7cy.markFunction('Function to be tested');8cy.markFunction('Function to be tested');9cy.markFunction('Function to be tested');10cy.markFunction('Function to be tested');11cy.markFunction('Function to be tested');12cy.markFunction('Function to be tested');13cy.markFunction('Function to be tested');14cy.markFunction('Function to be tested');15cy.markFunction('Function to be tested');16cy.markFunction('Function to be tested');17cy.markFunction('Function to be tested');18cy.markFunction('Function to be tested');19cy.markFunction('Function to be tested');20cy.markFunction('Function to be tested');21cy.markFunction('Function to be tested');22cy.markFunction('Function to be tested');23cy.markFunction('Function to be tested');

Full Screen

Using AI Code Generation

copy

Full Screen

1const add = (a, b) => a + b;2cy.wrap(add).as('add');3const add = (a, b) => a + b;4cy.wrap(add).as('add');5cy.get('@add').should('be.a', 'function');6const add = (a, b) => a + b;7cy.wrap(add).as('add');8cy.get('@add').should('be.a', 'function');9cy.get('@add').should('have.length', 2);10const add = (a, b) => a + b;11cy.wrap(add).as('add');12cy.get('@add').should('be.a', 'function');13cy.get('@add').should('have.length', 2);14cy.get('@add').should('have.property', 'name', 'add');15const add = (a, b) => a + b;16cy.wrap(add).as('add');17cy.get('@add').should('be.a', 'function');18cy.get('@add').should('have.length', 2);19cy.get('@add').should('have.property', 'name', 'add');20cy.get('@add').should('have.property', 'arguments');21const add = (a, b) => a + b;22cy.wrap(add).as('add');23cy.get('@add').should('be.a', 'function');24cy.get('@add').should('have.length', 2);25cy.get('@add').should('have.property', 'name

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.markFunction('test.js', 'functionName', 'lineNumber', 'columnNumber');2describe('My First Test', function() {3 it('Does not do much!', function() {4 expect(true).to.equal(true);5 });6});7import './commands';8cy.markFunction('test.js', 'it', '5', '3');9Feel free to check [issues page](

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful