How to use j.command method in Appium Base Driver

Best JavaScript code snippet using appium-base-driver

editing.js

Source:editing.js Github

copy

Full Screen

1//-------------------------------------------------------------------------------------------------------2// Java script library to run editing layout tests3var commandCount = 1;4var commandDelay = window.location.search.substring(1);5if (commandDelay == '')6 commandDelay = 0;7var selection = window.getSelection();8//-------------------------------------------------------------------------------------------------------9function execSetSelectionCommand(sn, so, en, eo) {10 window.getSelection().setBaseAndExtent(sn, so, en, eo);11}12// Args are startNode, startOffset, endNode, endOffset13function setSelectionCommand(sn, so, en, eo) {14 if (commandDelay > 0) {15 window.setTimeout(execSetSelectionCommand, commandCount * commandDelay, sn, so, en, eo);16 commandCount++;17 } else18 execSetSelectionCommand(sn, so, en, eo);19}20//-------------------------------------------------------------------------------------------------------21function execTransposeCharactersCommand() {22 document.execCommand("Transpose");23}24function transposeCharactersCommand() {25 if (commandDelay > 0) {26 window.setTimeout(execTransposeCharactersCommand, commandCount * commandDelay);27 commandCount++;28 }29 else {30 execTransposeCharactersCommand();31 }32}33//-------------------------------------------------------------------------------------------------------34function execMoveSelectionForwardByCharacterCommand() {35 selection.modify("move", "forward", "character");36}37function moveSelectionForwardByCharacterCommand() {38 if (commandDelay > 0) {39 window.setTimeout(execMoveSelectionForwardByCharacterCommand, commandCount * commandDelay);40 commandCount++;41 }42 else {43 execMoveSelectionForwardByCharacterCommand();44 }45}46//-------------------------------------------------------------------------------------------------------47function execExtendSelectionForwardByCharacterCommand() {48 selection.modify("extend", "forward", "character");49}50function extendSelectionForwardByCharacterCommand() {51 if (commandDelay > 0) {52 window.setTimeout(execExtendSelectionForwardByCharacterCommand, commandCount * commandDelay);53 commandCount++;54 }55 else {56 execExtendSelectionForwardByCharacterCommand();57 }58}59//-------------------------------------------------------------------------------------------------------60function execMoveSelectionForwardByWordCommand() {61 selection.modify("move", "forward", "word");62}63function moveSelectionForwardByWordCommand() {64 if (commandDelay > 0) {65 window.setTimeout(execMoveSelectionForwardByWordCommand, commandCount * commandDelay);66 commandCount++;67 }68 else {69 execMoveSelectionForwardByWordCommand();70 }71}72//-------------------------------------------------------------------------------------------------------73function execExtendSelectionForwardByWordCommand() {74 selection.modify("extend", "forward", "word");75}76function extendSelectionForwardByWordCommand() {77 if (commandDelay > 0) {78 window.setTimeout(execExtendSelectionForwardByWordCommand, commandCount * commandDelay);79 commandCount++;80 }81 else {82 execExtendSelectionForwardByWordCommand();83 }84}85//-------------------------------------------------------------------------------------------------------86function execMoveSelectionForwardBySentenceCommand() {87 selection.modify("move", "forward", "sentence");88}89function moveSelectionForwardBySentenceCommand() {90 if (commandDelay > 0) {91 window.setTimeout(execMoveSelectionForwardBySentenceCommand, commandCount * commandDelay);92 commandCount++;93 }94 else {95 execMoveSelectionForwardBySentenceCommand();96 }97}98//-------------------------------------------------------------------------------------------------------99function execExtendSelectionForwardBySentenceCommand() {100 selection.modify("extend", "forward", "sentence");101}102function extendSelectionForwardBySentenceCommand() {103 if (commandDelay > 0) {104 window.setTimeout(execExtendSelectionForwardBySentenceCommand, commandCount * commandDelay);105 commandCount++;106 }107 else {108 execExtendSelectionForwardBySentenceCommand();109 }110}111//-------------------------------------------------------------------------------------------------------112function execMoveSelectionForwardByLineCommand() {113 selection.modify("move", "forward", "line");114}115function moveSelectionForwardByLineCommand() {116 if (commandDelay > 0) {117 window.setTimeout(execMoveSelectionForwardByLineCommand, commandCount * commandDelay);118 commandCount++;119 }120 else {121 execMoveSelectionForwardByLineCommand();122 }123}124//-------------------------------------------------------------------------------------------------------125function execExtendSelectionForwardByLineCommand() {126 selection.modify("extend", "forward", "line");127}128function extendSelectionForwardByLineCommand() {129 if (commandDelay > 0) {130 window.setTimeout(execExtendSelectionForwardByLineCommand, commandCount * commandDelay);131 commandCount++;132 }133 else {134 execExtendSelectionForwardByLineCommand();135 }136}137//-------------------------------------------------------------------------------------------------------138function execMoveSelectionForwardByLineBoundaryCommand() {139 selection.modify("move", "forward", "lineBoundary");140}141function moveSelectionForwardByLineBoundaryCommand() {142 if (commandDelay > 0) {143 window.setTimeout(execMoveSelectionForwardByLineBoundaryCommand, commandCount * commandDelay);144 commandCount++;145 }146 else {147 execMoveSelectionForwardByLineBoundaryCommand();148 }149}150//-------------------------------------------------------------------------------------------------------151function execExtendSelectionForwardByLineBoundaryCommand() {152 selection.modify("extend", "forward", "lineBoundary");153}154function extendSelectionForwardByLineBoundaryCommand() {155 if (commandDelay > 0) {156 window.setTimeout(execExtendSelectionForwardByLineBoundaryCommand, commandCount * commandDelay);157 commandCount++;158 }159 else {160 execExtendSelectionForwardByLineBoundaryCommand();161 }162}163//-------------------------------------------------------------------------------------------------------164function execMoveSelectionBackwardByCharacterCommand() {165 selection.modify("move", "backward", "character");166}167function moveSelectionBackwardByCharacterCommand() {168 if (commandDelay > 0) {169 window.setTimeout(execMoveSelectionBackwardByCharacterCommand, commandCount * commandDelay);170 commandCount++;171 }172 else {173 execMoveSelectionBackwardByCharacterCommand();174 }175}176//-------------------------------------------------------------------------------------------------------177function execExtendSelectionBackwardByCharacterCommand() {178 selection.modify("extend", "backward", "character");179}180function extendSelectionBackwardByCharacterCommand() {181 if (commandDelay > 0) {182 window.setTimeout(execExtendSelectionBackwardByCharacterCommand, commandCount * commandDelay);183 commandCount++;184 }185 else {186 execExtendSelectionBackwardByCharacterCommand();187 }188}189//-------------------------------------------------------------------------------------------------------190function execMoveSelectionBackwardByWordCommand() {191 selection.modify("move", "backward", "word");192}193function moveSelectionBackwardByWordCommand() {194 if (commandDelay > 0) {195 window.setTimeout(execMoveSelectionBackwardByWordCommand, commandCount * commandDelay);196 commandCount++;197 }198 else {199 execMoveSelectionBackwardByWordCommand();200 }201}202//-------------------------------------------------------------------------------------------------------203function execExtendSelectionBackwardByWordCommand() {204 selection.modify("extend", "backward", "word");205}206function extendSelectionBackwardByWordCommand() {207 if (commandDelay > 0) {208 window.setTimeout(execExtendSelectionBackwardByWordCommand, commandCount * commandDelay);209 commandCount++;210 }211 else {212 execExtendSelectionBackwardByWordCommand();213 }214}215//-------------------------------------------------------------------------------------------------------216function execMoveSelectionBackwardBySentenceCommand() {217 selection.modify("move", "backward", "sentence");218}219function moveSelectionBackwardBySentenceCommand() {220 if (commandDelay > 0) {221 window.setTimeout(execMoveSelectionBackwardBySentenceCommand, commandCount * commandDelay);222 commandCount++;223 }224 else {225 execMoveSelectionBackwardBySentenceCommand();226 }227}228//-------------------------------------------------------------------------------------------------------229function execExtendSelectionBackwardBySentenceCommand() {230 selection.modify("extend", "backward", "sentence");231}232function extendSelectionBackwardBySentenceCommand() {233 if (commandDelay > 0) {234 window.setTimeout(execExtendSelectionBackwardBySentenceCommand, commandCount * commandDelay);235 commandCount++;236 }237 else {238 execExtendSelectionBackwardBySentenceCommand();239 }240}241//-------------------------------------------------------------------------------------------------------242function execMoveSelectionBackwardByLineCommand() {243 selection.modify("move", "backward", "line");244}245function moveSelectionBackwardByLineCommand() {246 if (commandDelay > 0) {247 window.setTimeout(execMoveSelectionBackwardByLineCommand, commandCount * commandDelay);248 commandCount++;249 }250 else {251 execMoveSelectionBackwardByLineCommand();252 }253}254//-------------------------------------------------------------------------------------------------------255function execExtendSelectionBackwardByLineCommand() {256 selection.modify("extend", "backward", "line");257}258function extendSelectionBackwardByLineCommand() {259 if (commandDelay > 0) {260 window.setTimeout(execExtendSelectionBackwardByLineCommand, commandCount * commandDelay);261 commandCount++;262 }263 else {264 execExtendSelectionBackwardByLineCommand();265 }266}267//-------------------------------------------------------------------------------------------------------268function execExtendSelectionBackwardByLineBoundaryCommand() {269 selection.modify("extend", "backward", "lineBoundary");270}271function extendSelectionBackwardByLineBoundaryCommand() {272 if (commandDelay > 0) {273 window.setTimeout(execExtendSelectionBackwardByLineBoundaryCommand, commandCount * commandDelay);274 commandCount++;275 }276 else {277 execExtendSelectionBackwardByLineBoundaryCommand();278 }279}280//-------------------------------------------------------------------------------------------------------281function execMoveSelectionBackwardByLineBoundaryCommand() {282 selection.modify("move", "backward", "lineBoundary");283}284function moveSelectionBackwardByLineBoundaryCommand() {285 if (commandDelay > 0) {286 window.setTimeout(execMoveSelectionBackwardByLineBoundaryCommand, commandCount * commandDelay);287 commandCount++;288 }289 else {290 execMoveSelectionBackwardByLineBoundaryCommand();291 }292}293//-------------------------------------------------------------------------------------------------------294function doubleClick(x, y) {295 eventSender.mouseMoveTo(x, y);296 eventSender.mouseDown();297 eventSender.mouseUp();298 eventSender.mouseDown();299 eventSender.mouseUp();300}301function doubleClickAtSelectionStart() {302 var rects = window.getSelection().getRangeAt(0).getClientRects();303 var x = rects[0].left;304 var y = rects[0].top;305 doubleClick(x, y);306}307//-------------------------------------------------------------------------------------------------------308function execBoldCommand() {309 document.execCommand("Bold");310 debugForDumpAsText("execBoldCommand");311}312function boldCommand() {313 if (commandDelay > 0) {314 window.setTimeout(execBoldCommand, commandCount * commandDelay);315 commandCount++;316 }317 else {318 execBoldCommand();319 }320}321//-------------------------------------------------------------------------------------------------------322function execUnderlineCommand() {323 document.execCommand("Underline");324 debugForDumpAsText("execUnderlineCommand");325}326function underlineCommand() {327 if (commandDelay > 0) {328 window.setTimeout(execUnderlineCommand, commandCount * commandDelay);329 commandCount++;330 }331 else {332 execUnderlineCommand();333 }334}335//-------------------------------------------------------------------------------------------------------336function execFontNameCommand() {337 document.execCommand("FontName", false, "Courier");338 debugForDumpAsText("execFontNameCommand");339}340function fontNameCommand() {341 if (commandDelay > 0) {342 window.setTimeout(execFontNameCommand, commandCount * commandDelay);343 commandCount++;344 }345 else {346 execFontNameCommand();347 }348}349//-------------------------------------------------------------------------------------------------------350function execFontSizeCommand(s) {351 if (arguments.length == 0 || s == undefined || s.length == 0)352 s = '12px';353 document.execCommand("FontSize", false, s);354 debugForDumpAsText("execFontSizeCommand");355}356function fontSizeCommand(s) {357 if (commandDelay > 0) {358 window.setTimeout(execFontSizeCommand, commandCount * commandDelay, s);359 commandCount++;360 }361 else {362 execFontSizeCommand(s);363 }364}365//-------------------------------------------------------------------------------------------------------366function execFontSizeDeltaCommand(s) {367 if (arguments.length == 0 || s == undefined || s.length == 0)368 s = '1px';369 document.execCommand("FontSizeDelta", false, s);370 debugForDumpAsText("execFontSizeDeltaCommand");371}372function fontSizeDeltaCommand(s) {373 if (commandDelay > 0) {374 window.setTimeout(execFontSizeDeltaCommand, commandCount * commandDelay, s);375 commandCount++;376 }377 else {378 execFontSizeDeltaCommand(s);379 }380}381//-------------------------------------------------------------------------------------------------------382function execItalicCommand() {383 document.execCommand("Italic");384 debugForDumpAsText("execItalicCommand");385}386function italicCommand() {387 if (commandDelay > 0) {388 window.setTimeout(execItalicCommand, commandCount * commandDelay);389 commandCount++;390 }391 else {392 execItalicCommand();393 }394}395//-------------------------------------------------------------------------------------------------------396function execJustifyCenterCommand() {397 document.execCommand("JustifyCenter");398 debugForDumpAsText("execJustifyCenterCommand");399}400function justifyCenterCommand() {401 if (commandDelay > 0) {402 window.setTimeout(execJustifyCenterCommand, commandCount * commandDelay);403 commandCount++;404 }405 else {406 execJustifyCenterCommand();407 }408}409//-------------------------------------------------------------------------------------------------------410function execJustifyLeftCommand() {411 document.execCommand("JustifyLeft");412 debugForDumpAsText("execJustifyLeftCommand");413}414function justifyLeftCommand() {415 if (commandDelay > 0) {416 window.setTimeout(execJustifyLeftCommand, commandCount * commandDelay);417 commandCount++;418 }419 else {420 execJustifyLeftCommand();421 }422}423//-------------------------------------------------------------------------------------------------------424function execJustifyRightCommand() {425 document.execCommand("JustifyRight");426 debugForDumpAsText("execJustifyRightCommand");427}428function justifyRightCommand() {429 if (commandDelay > 0) {430 window.setTimeout(execJustifyRightCommand, commandCount * commandDelay);431 commandCount++;432 }433 else {434 execJustifyRightCommand();435 }436}437//-------------------------------------------------------------------------------------------------------438function execInsertHTMLCommand(html) {439 document.execCommand("InsertHTML", false, html);440 debugForDumpAsText("execInsertHTMLCommand");441}442function insertHTMLCommand(html) {443 if (commandDelay > 0) {444 window.setTimeout(execInsertHTMLCommand, commandCount * commandDelay, html);445 commandCount++;446 }447 else {448 execInsertHTMLCommand(html);449 }450}451//-------------------------------------------------------------------------------------------------------452function execInsertImageCommand(imgSrc) {453 document.execCommand("InsertImage", false, imgSrc);454 debugForDumpAsText("execInsertImageCommand");455}456function insertImageCommand(imgSrc) {457 if (commandDelay > 0) {458 window.setTimeout(execInsertImageCommand, commandCount * commandDelay, imgSrc);459 commandCount++;460 }461 else {462 execInsertImageCommand(imgSrc);463 }464}465//-------------------------------------------------------------------------------------------------------466function execInsertLineBreakCommand() {467 document.execCommand("InsertLineBreak");468 debugForDumpAsText("execInsertLineBreakCommand");469}470function insertLineBreakCommand() {471 if (commandDelay > 0) {472 window.setTimeout(execInsertLineBreakCommand, commandCount * commandDelay);473 commandCount++;474 }475 else {476 execInsertLineBreakCommand();477 }478}479//-------------------------------------------------------------------------------------------------------480 481function execInsertParagraphCommand() {482 document.execCommand("InsertParagraph");483 debugForDumpAsText("execInsertParagraphCommand");484}485function insertParagraphCommand() {486 if (commandDelay > 0) {487 window.setTimeout(execInsertParagraphCommand, commandCount * commandDelay);488 commandCount++;489 }490 else {491 execInsertParagraphCommand();492 }493}494//-------------------------------------------------------------------------------------------------------495function execInsertNewlineInQuotedContentCommand() {496 document.execCommand("InsertNewlineInQuotedContent");497 debugForDumpAsText("execInsertNewlineInQuotedContentCommand");498}499function insertNewlineInQuotedContentCommand() {500 if (commandDelay > 0) {501 window.setTimeout(execInsertNewlineInQuotedContentCommand, commandCount * commandDelay);502 commandCount++;503 }504 else {505 execInsertNewlineInQuotedContentCommand();506 }507}508//-------------------------------------------------------------------------------------------------------509function execTypeCharacterCommand(c) {510 if (arguments.length == 0 || c == undefined || c.length == 0 || c.length > 1)511 c = 'x';512 document.execCommand("InsertText", false, c);513 debugForDumpAsText("execTypeCharacterCommand");514}515function typeCharacterCommand(c) {516 if (commandDelay > 0) {517 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay, c);518 commandCount++;519 }520 else {521 execTypeCharacterCommand(c);522 }523}524//-------------------------------------------------------------------------------------------------------525function execSelectAllCommand() {526 document.execCommand("SelectAll");527}528function selectAllCommand() {529 if (commandDelay > 0) {530 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);531 commandCount++;532 }533 else {534 execSelectAllCommand();535 }536}537//-------------------------------------------------------------------------------------------------------538function execStrikethroughCommand() {539 document.execCommand("Strikethrough");540 debugForDumpAsText("execStrikethroughCommand");541}542function strikethroughCommand() {543 if (commandDelay > 0) {544 window.setTimeout(execStrikethroughCommand, commandCount * commandDelay);545 commandCount++;546 }547 else {548 execStrikethroughCommand();549 }550}551//-------------------------------------------------------------------------------------------------------552function execUndoCommand() {553 document.execCommand("Undo");554 debugForDumpAsText("execUndoCommand");555}556function undoCommand() {557 if (commandDelay > 0) {558 window.setTimeout(execUndoCommand, commandCount * commandDelay);559 commandCount++;560 }561 else {562 execUndoCommand();563 }564}565//-------------------------------------------------------------------------------------------------------566function execRedoCommand() {567 document.execCommand("Redo");568 debugForDumpAsText("execRedoCommand");569}570function redoCommand() {571 if (commandDelay > 0) {572 window.setTimeout(execRedoCommand, commandCount * commandDelay);573 commandCount++;574 }575 else {576 execRedoCommand();577 }578}579//-------------------------------------------------------------------------------------------------------580function execChangeRootSize() {581 document.getElementById("root").style.width = "600px";582}583function changeRootSize() {584 if (commandDelay > 0) {585 window.setTimeout(execChangeRootSize, commandCount * commandDelay);586 commandCount++;587 }588 else {589 execChangeRootSize();590 }591}592//-------------------------------------------------------------------------------------------------------593function execCutCommand() {594 document.execCommand("Cut");595 debugForDumpAsText("execCutCommand");596}597function cutCommand() {598 if (commandDelay > 0) {599 window.setTimeout(execCutCommand, commandCount * commandDelay);600 commandCount++;601 }602 else {603 execCutCommand();604 }605}606//-------------------------------------------------------------------------------------------------------607function execCopyCommand() {608 document.execCommand("Copy");609 debugForDumpAsText("execCopyCommand");610}611function copyCommand() {612 if (commandDelay > 0) {613 window.setTimeout(execCopyCommand, commandCount * commandDelay);614 commandCount++;615 }616 else {617 execCopyCommand();618 }619}620//-------------------------------------------------------------------------------------------------------621function execPasteCommand() {622 document.execCommand("Paste");623 debugForDumpAsText("execPasteCommand");624}625function pasteCommand() {626 if (commandDelay > 0) {627 window.setTimeout(execPasteCommand, commandCount * commandDelay);628 commandCount++;629 }630 else {631 execPasteCommand();632 }633}634//-------------------------------------------------------------------------------------------------------635function execCreateLinkCommand(url) {636 document.execCommand("CreateLink", false, url);637 debugForDumpAsText("execCreateLinkCommand");638}639function createLinkCommand(url) {640 if (commandDelay > 0) {641 window.setTimeout(execCreateLinkCommand, commandCount * commandDelay, url);642 commandCount++;643 } else644 execCreateLinkCommand(url);645}646//-------------------------------------------------------------------------------------------------------647function execUnlinkCommand() {648 document.execCommand("Unlink");649 debugForDumpAsText("execUnlinkCommand");650}651function unlinkCommand() {652 if (commandDelay > 0) {653 window.setTimeout(execUnlinkCommand, commandCount * commandDelay);654 commandCount++;655 } else656 execUnlinkCommand();657}658//-------------------------------------------------------------------------------------------------------659function execPasteAndMatchStyleCommand() {660 document.execCommand("PasteAndMatchStyle");661 debugForDumpAsText("execPasteAndMatchStyleCommand");662}663function pasteAndMatchStyleCommand() {664 if (commandDelay > 0) {665 window.setTimeout(execPasteAndMatchStyleCommand, commandCount * commandDelay);666 commandCount++;667 }668 else {669 execPasteAndMatchStyleCommand();670 }671}672//-------------------------------------------------------------------------------------------------------673function execDeleteCommand() {674 document.execCommand("Delete");675 debugForDumpAsText("execDeleteCommand");676}677function deleteCommand() {678 if (commandDelay > 0) {679 window.setTimeout(execDeleteCommand, commandCount * commandDelay);680 commandCount++;681 }682 else {683 execDeleteCommand();684 }685}686//-------------------------------------------------------------------------------------------------------687function execForwardDeleteCommand() {688 document.execCommand("ForwardDelete");689 debugForDumpAsText("execForwardDeleteCommand");690}691function forwardDeleteCommand() {692 if (commandDelay > 0) {693 window.setTimeout(execForwardDeleteCommand, commandCount * commandDelay);694 commandCount++;695 }696 else {697 execForwardDeleteCommand();698 }699}700//-------------------------------------------------------------------------------------------------------701function runEditingTest() {702 if (window.layoutTestController)703 layoutTestController.dumpEditingCallbacks();704 var elem = document.getElementById("test");705 var selection = window.getSelection();706 selection.setPosition(elem, 0);707 editingTest();708}709var dumpAsText = false;710var markupResultList = document.createElement('ol');711function runDumpAsTextEditingTest(enableCallbacks) {712 if (window.layoutTestController) {713 layoutTestController.dumpAsText();714 if (enableCallbacks)715 layoutTestController.dumpEditingCallbacks();716 }717 dumpAsText = true;718 var elem = document.getElementById("test");719 var selection = window.getSelection();720 selection.setPosition(elem, 0);721 editingTest();722 document.body.appendChild(markupResultList);723}724function debugForDumpAsText(name) {725 if (dumpAsText && document.getElementById("root")) {726 var newItem = document.createElement('li');727 newItem.appendChild(document.createTextNode(name+": "+document.getElementById("root").innerHTML));728 markupResultList.appendChild(newItem);729 }730}731//-------------------------------------------------------------------------------------------------------732function execBackColorCommand() {733 document.execCommand("BackColor", false, "Chartreuse");734 debugForDumpAsText('execBackColorCommand');735}736function backColorCommand() {737 if (commandDelay > 0) {738 window.setTimeout(execBackColorCommand, commandCount * commandDelay);739 commandCount++;740 }741 else {742 execBackColorCommand();743 }744}745function execForeColorCommand(color) {746 document.execCommand("ForeColor", false, color);747 debugForDumpAsText('execForeColorCommand');748}749function foreColorCommand(color) {750 if (commandDelay > 0) {751 window.setTimeout(execForeColorCommand, commandCount * commandDelay, color);752 commandCount++;753 } else754 execForeColorCommand(color);755}756//-------------------------------------------------------------------------------------------------------757function runCommand(command, arg1, arg2) {758 document.execCommand(command,arg1,arg2);759}760function executeCommand(command,arg1,arg2) {761 if (commandDelay > 0) {762 window.setTimeout(runCommand, commandCount * commandDelay);763 commandCount++;764 }765 else {766 runCommand(command,arg1,arg2);767 }...

Full Screen

Full Screen

list.js

Source:list.js Github

copy

Full Screen

1let WhatsAlexa = require('../events');2let Config = require('../config');3let fs = require('fs');4let {MessageType} = require('@adiwajshing/baileys');5let Language = require('../language');6let Lang = Language.getString('list');7let td = Config.WORKTYPE == 'public' ? false : true8var LOADING = ''9var warning = ''10var anti_link = ''11var auto_bio = ''12var language = ''13var MSG = ''14var FMSG = ''15if (Config.ANTILINK == 'true') anti_link = 'On'16if (Config.ANTILINK == 'false') anti_link = 'Off'17if (Config.AUTOBIO == 'true') auto_bio = 'On'18if (Config.AUTOBIO == 'false') auto_bio = 'Off'19if (Config.LANG == 'EN') warning = 'We are not responsible for any consequences that may arise from use or misuse of Bot, You are responsible for all consequences also the responsibility of sharing Images, Videos, Stickers, Audios etc.. are yours!', language = 'English', FMSG = 'Have a Nice Day 💖\n\n```Git:``` *'+Config.GIT+'*\n\n```Thank You For using WhatsAlexa 💕```\n*© WhatsAlexa, Made By Toxic Devil*\n\n*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*\n *⦁◊═⦁ Whats 👸 Alexa ⦁═◊⦁*\n*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*', MSG = '*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*\n *⦁◊═⦁ Whats 👸 Alexa ⦁═◊⦁*\n*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*\n\nHi user,\n*'+warning+'*\n\n*◆ BOT INFO ◆*\n\n```▣ Developer:``` *TOXIC DEVIL*\n```▣ Owner:``` *'+Config.OWNER+'*\n```▣ Contact Owner:``` *wa.me/'+Config.OWNERNUM+'*\n```▣ Version:``` *'+Config.VERSION+'*\n```▣ Branch:``` *'+Config.BRANCH+'*\n```▣ Language:``` *'+language+'*\n```▣ Auto Bio:``` *'+auto_bio+'*\n```▣ Antilink:``` *'+anti_link+'*\n```▣ Work Type:``` *'+Config.WORKTYPE+'*\n\n∎ ⇓ *Commands* ⇓ ∎\n\n'20if (Config.LANG == 'ML') warning = 'ബോട്ടിന്റെ ഉപയോഗത്തിൽ നിന്നോ ദുരുപയോഗത്തിൽ നിന്നോ ഉണ്ടാകുന്ന അനന്തരഫലങ്ങൾക്ക് ഞങ്ങൾ ഉത്തരവാദികളല്ല, ചിത്രങ്ങൾ, വീഡിയോകൾ, സ്റ്റിക്കറുകൾ, ഓഡിയോകൾ മുതലായവ പങ്കിടുന്നതിന്റെ ഉത്തരവാദിത്തവും നിങ്ങളാണ്.', language = 'മലയാളം', FMSG = 'ഒരു നല്ല ദിനം ആശംസിക്കുന്നു 💖\n\n```ഗിറ്റ്:``` *'+Config.GIT+'*\n\n```WhatsAlexa ഉപയോഗിച്ചതിന് നന്ദി 💕```\n*© WhatsAlexa, ഉണ്ടാക്കിയത് Toxic Devil*\n\n*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*\n *⦁◊═⦁ Whats 👸 Alexa ⦁═◊⦁*\n*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*', MSG = '*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*\n *⦁◊═⦁ Whats 👸 Alexa ⦁═◊⦁*\n*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*\n\nനമസ്കാരം user,\n*'+warning+'*\n\n*◆ ബോട്ട് വിവരം ◆*\n\n```▣ ഡെവലപ്പർ:``` *TOXIC DEVIL*\n```▣ ഉടമ:``` *'+Config.OWNER+'*\n```▣ ഉടമയുമായി ബന്ധപ്പെടുക:``` *wa.me/'+Config.OWNERNUM+'*\n```▣ Version:``` *'+Config.VERSION+'*\n```▣ Branch:``` *'+Config.BRANCH+'*\n```▣ ഭാഷ:``` *'+language+'*\n```▣ ഓട്ടോ ബയോ:``` *'+auto_bio+'*\n```▣ ആന്റി ലിങ്ക്:``` *'+anti_link+'*\n```▣ വര്‍ക്ക്‌ തരം:``` *'+Config.WORKTYPE+'*\n\n∎ ⇓ *കമാൻഡുകൾ* ⇓ ∎\n\n'21if (Config.LANG == 'ID') warning = 'Kami tidak bertanggung jawab atas segala akibat yang mungkin timbul dari penggunaan atau penyalahgunaan Bot, Anda bertanggung jawab atas semua konsekuensi juga tanggung jawab berbagi Gambar, Video, Stiker, Audio dll. adalah milik Anda!', language = 'Indonasian', FMSG = 'Semoga harimu menyenangkan 💖\n\n```Git:``` *'+Config.GIT+'*\n\n```Terima kasih telah menggunakan WhatsAlexa 💕```\n*© WhatsAlexa, Dibuat oleh Toxic Devil*\n\n*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*\n *⦁◊═⦁ Whats 👸 Alexa ⦁═◊⦁*\n*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*', MSG = '*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*\n *⦁◊═⦁ Whats 👸 Alexa ⦁═◊⦁*\n*◄━━━━━━━⦁⦁◯⦁⦁━━━━━━━━►*\n\nHai user,\n*'+warning+'*\n\n*◆ INFORMASI BOT ◆*\n\n```▣ Pengembang:``` *TOXIC DEVIL*\n```▣ Pemilik:``` *'+Config.OWNER+'*\n```▣ Version:``` *'+Config.VERSION+'*\n```▣ Branch:``` *'+Config.BRANCH+'*\n```▣ Hubungi Pemilik:``` *wa.me/'+Config.OWNERNUM+'*\n```▣ Bahasa:``` *'+language+'*\n```▣ Bio otomatis:``` *'+auto_bio+'*\n```▣ Anti Tautan:``` *'+anti_link+'*\n```▣ Jenis Pekerjaan:``` *'+Config.WORKTYPE+'*\n\n∎ ⇓ *Perintah* ⇓ ∎\n\n'22 WhatsAlexa.addCommand({pattern: 'list ?(.*)', fromMe: td, dontAddCommandList: true}, (async (message, match) => {23 24 var CMD_HELP = '';25 if (match[1] === '') {26 WhatsAlexa.commands.map(27 async (command) => {28 if (command.dontAddCommandList || command.pattern === undefined) return;29 try {30 var match = command.pattern.toString().match(/(\W*)([A-Za-zğüşiöç1234567890]*)/);31 } catch {32 var match = [command.pattern];33 }34 35 var HANDLER = '';36 37 if (/\[(\W*)\]/.test(Config.HANDLERS)) {38 HANDLER = Config.HANDLERS.match(/\[(\W*)\]/)[1][0];39 } else {40 HANDLER = '.';41 }42 CMD_HELP += '*🎯 ' + Lang.COMMAND + ':* ```' + (match.length >= 3 ? (HANDLER + match[2]) : command.pattern) + (command.desc === '' ? '```\n\n' : '```\n');43 if (command.desc !== '') CMD_HELP += '*📝 ' + Lang.DESC + ':* ```' + command.desc + (command.warn === '' ? '```\n\n' : '```\n');44 if (command.usage !== '') CMD_HELP += '*⌨️ ' + Lang.EXAMPLE + ':* ```' + command.usage + '```\n\n';45 if (command.warn !== '') CMD_HELP += '*⚠️ ' + Lang.WARN + ':* ```' + command.warn + '```\n\n';46 }47 );48 49 await message.client.sendMessage(50 message.jid, MSG + CMD_HELP + FMSG, MessageType.text, {contextInfo: { forwardingScore: 49, isForwarded: true }, quoted: message.data});51 } else {52 var CMD_HELP = '';53 WhatsAlexa.commands.map(54 async (command) => {55 if (command.dontAddCommandList || command.pattern === undefined) return;56 try {57 var cmatch = command.pattern.toString().match(/(\W*)([A-Za-zğüşiöç1234567890]*)/);58 } catch {59 var cmatch = [command.pattern];60 }61 62 if (cmatch[2] == match[1]) {63 var HANDLER = '';64 65 if (/\[(\W*)\]/.test(Config.HANDLERS)) {66 HANDLER = Config.HANDLERS.match(/\[(\W*)\]/)[1][0];67 } else {68 HANDLER = '.';69 }70 CMD_HELP += '*🎯 ' + Lang.COMMAND + ':* ```' + (cmatch.length >= 3 ? (HANDLER + cmatch[2]) : command.pattern) + (command.desc === '' ? '```\n\n' : '```\n');71 if (command.desc !== '') CMD_HELP += '*📝 ' + Lang.DESC + ':* ```' + command.desc + (command.warn === '' ? '```\n\n' : '```\n');72 if (command.usage !== '') CMD_HELP += '*⌨️ ' + Lang.EXAMPLE + ':* ```' + command.usage + '```\n\n';73 if (command.warn !== '') CMD_HELP += '*⚠️ ' + Lang.WARN + ':* ```' + command.warn + '```\n\n';74 }75 }76 );77 if (CMD_HELP === '') CMD_HELP += Lang.NOT_FOUND; 78 await message.client.sendMessage(79 message.jid, MSG + CMD_HELP + FMSG, MessageType.text, {contextInfo: { forwardingScore: 49, isForwarded: true }, quoted: message.data});80 }81 }));82 WhatsAlexa.addCommand({pattern: 'menu ?(.*)', fromMe: td, dontAddCommandList: true}, (async (message, match) => {83 var CMD_HELP = '';84 if (match[1] === '') {85 WhatsAlexa.commands.map(86 async (command) => {87 if (command.dontAddCommandList || command.pattern === undefined) return;88 try {89 var match = command.pattern.toString().match(/(\W*)([A-Za-zğüşiöç1234567890]*)/);90 } catch {91 var match = [command.pattern];92 }93 94 var HANDLER = '';95 96 if (/\[(\W*)\]/.test(Config.HANDLERS)) {97 HANDLER = Config.HANDLERS.match(/\[(\W*)\]/)[1][0];98 } else {99 HANDLER = '.';100 }101 CMD_HELP += '*🎯 ' + Lang.COMMAND + ':* ```' + (match.length >= 3 ? (HANDLER + match[2]) : command.pattern) + (command.desc === '' ? '```\n\n' : '```\n');102 if (command.desc !== '') CMD_HELP += '*📝 ' + Lang.DESC + ':* ```' + command.desc + (command.warn === '' ? '```\n\n' : '```\n');103 if (command.usage !== '') CMD_HELP += '*⌨️ ' + Lang.EXAMPLE + ':* ```' + command.usage + '```\n\n';104 if (command.warn !== '') CMD_HELP += '*⚠️ ' + Lang.WARN + ':* ```' + command.warn + '```\n\n';105 }106 );107 108 await message.client.sendMessage(109 message.jid, MSG + CMD_HELP + FMSG, MessageType.text, {contextInfo: { forwardingScore: 49, isForwarded: true }, quoted: message.data});110 } else {111 112 var CMD_HELP = '';113 WhatsAlexa.commands.map(114 async (command) => {115 if (command.dontAddCommandList || command.pattern === undefined) return;116 try {117 var cmatch = command.pattern.toString().match(/(\W*)([A-Za-zğüşiöç1234567890]*)/);118 } catch {119 var cmatch = [command.pattern];120 }121 122 if (cmatch[2] == match[1]) {123 var HANDLER = '';124 125 if (/\[(\W*)\]/.test(Config.HANDLERS)) {126 HANDLER = Config.HANDLERS.match(/\[(\W*)\]/)[1][0];127 } else {128 HANDLER = '.';129 }130 CMD_HELP += '*🎯 ' + Lang.COMMAND + ':* ```' + (cmatch.length >= 3 ? (HANDLER + cmatch[2]) : command.pattern) + (command.desc === '' ? '```\n\n' : '```\n');131 if (command.desc !== '') CMD_HELP += '*📝 ' + Lang.DESC + ':* ```' + command.desc + (command.warn === '' ? '```\n\n' : '```\n');132 if (command.usage !== '') CMD_HELP += '*⌨️ ' + Lang.EXAMPLE + ':* ```' + command.usage + '```\n\n';133 if (command.warn !== '') CMD_HELP += '*⚠️ ' + Lang.WARN + ':* ```' + command.warn + '```\n\n';134 }135 }136 );137 if (CMD_HELP === '') CMD_HELP += Lang.NOT_FOUND; 138 await message.client.sendMessage(139 message.jid, MSG + CMD_HELP + FMSG, MessageType.text, {contextInfo: { forwardingScore: 49, isForwarded: true }, quoted: message.data});140 }141 }));142 WhatsAlexa.addCommand({pattern: 'help ?(.*)', fromMe: td, dontAddCommandList: true}, (async (message, match) => {143 var CMD_HELP = '';144 if (match[1] === '') {145 WhatsAlexa.commands.map(146 async (command) => {147 if (command.dontAddCommandList || command.pattern === undefined) return;148 try {149 var match = command.pattern.toString().match(/(\W*)([A-Za-zğüşiöç1234567890]*)/);150 } catch {151 var match = [command.pattern];152 }153 154 var HANDLER = '';155 156 if (/\[(\W*)\]/.test(Config.HANDLERS)) {157 HANDLER = Config.HANDLERS.match(/\[(\W*)\]/)[1][0];158 } else {159 HANDLER = '.';160 }161 CMD_HELP += '*🎯 ' + Lang.COMMAND + ':* ```' + (match.length >= 3 ? (HANDLER + match[2]) : command.pattern) + (command.desc === '' ? '```\n\n' : '```\n');162 if (command.desc !== '') CMD_HELP += '*📝 ' + Lang.DESC + ':* ```' + command.desc + (command.warn === '' ? '```\n\n' : '```\n');163 if (command.usage !== '') CMD_HELP += '*⌨️ ' + Lang.EXAMPLE + ':* ```' + command.usage + '```\n\n';164 if (command.warn !== '') CMD_HELP += '*⚠️ ' + Lang.WARN + ':* ```' + command.warn + '```\n\n';165 }166 );167 168 await message.client.sendMessage(169 message.jid, MSG + CMD_HELP + FMSG, MessageType.text, {contextInfo: { forwardingScore: 49, isForwarded: true }, quoted: message.data});170 } else {171 var CMD_HELP = '';172 WhatsAlexa.commands.map(173 async (command) => {174 if (command.dontAddCommandList || command.pattern === undefined) return;175 try {176 var cmatch = command.pattern.toString().match(/(\W*)([A-Za-zğüşiöç1234567890]*)/);177 } catch {178 var cmatch = [command.pattern];179 }180 181 if (cmatch[2] == match[1]) {182 var HANDLER = '';183 184 if (/\[(\W*)\]/.test(Config.HANDLERS)) {185 HANDLER = Config.HANDLERS.match(/\[(\W*)\]/)[1][0];186 } else {187 HANDLER = '.';188 }189 CMD_HELP += '*🎯 ' + Lang.COMMAND + ':* ```' + (cmatch.length >= 3 ? (HANDLER + cmatch[2]) : command.pattern) + (command.desc === '' ? '```\n\n' : '```\n');190 if (command.desc !== '') CMD_HELP += '*📝 ' + Lang.DESC + ':* ```' + command.desc + (command.warn === '' ? '```\n\n' : '```\n');191 if (command.usage !== '') CMD_HELP += '*⌨️ ' + Lang.EXAMPLE + ':* ```' + command.usage + '```\n\n';192 if (command.warn !== '') CMD_HELP += '*⚠️ ' + Lang.WARN + ':* ```' + command.warn + '```\n\n';193 }194 }195 );196 if (CMD_HELP === '') CMD_HELP += Lang.NOT_FOUND;197 await message.client.sendMessage(198 message.jid, MSG + CMD_HELP + FMSG, MessageType.text, {contextInfo: { forwardingScore: 49, isForwarded: true }, quoted: message.data});199 }200 }));201 WhatsAlexa.addCommand({pattern: 'cmd ?(.*)', fromMe: td, dontAddCommandList: true}, (async (message, match) => {202 var CMD_HELP = '';203 if (match[1] === '') {204 WhatsAlexa.commands.map(205 async (command) => {206 if (command.dontAddCommandList || command.pattern === undefined) return;207 try {208 var match = command.pattern.toString().match(/(\W*)([A-Za-zğüşiöç1234567890]*)/);209 } catch {210 var match = [command.pattern];211 }212 213 var HANDLER = '';214 215 if (/\[(\W*)\]/.test(Config.HANDLERS)) {216 HANDLER = Config.HANDLERS.match(/\[(\W*)\]/)[1][0];217 } else {218 HANDLER = '.';219 }220 CMD_HELP += '*🎯 ' + Lang.COMMAND + ':* ```' + (match.length >= 3 ? (HANDLER + match[2]) : command.pattern) + (command.desc === '' ? '```\n\n' : '```\n');221 if (command.desc !== '') CMD_HELP += '*📝 ' + Lang.DESC + ':* ```' + command.desc + (command.warn === '' ? '```\n\n' : '```\n');222 if (command.usage !== '') CMD_HELP += '*⌨️ ' + Lang.EXAMPLE + ':* ```' + command.usage + '```\n\n';223 if (command.warn !== '') CMD_HELP += '*⚠️ ' + Lang.WARN + ':* ```' + command.warn + '```\n\n';224 }225 );226 227 await message.client.sendMessage(228 message.jid, MSG + CMD_HELP + FMSG, MessageType.text, {contextInfo: { forwardingScore: 49, isForwarded: true }, quoted: message.data});229 } else {230 231 var CMD_HELP = '';232 WhatsAlexa.commands.map(233 async (command) => {234 if (command.dontAddCommandList || command.pattern === undefined) return;235 try {236 var cmatch = command.pattern.toString().match(/(\W*)([A-Za-zğüşiöç1234567890]*)/);237 } catch {238 var cmatch = [command.pattern];239 }240 241 if (cmatch[2] == match[1]) {242 var HANDLER = '';243 244 if (/\[(\W*)\]/.test(Config.HANDLERS)) {245 HANDLER = Config.HANDLERS.match(/\[(\W*)\]/)[1][0];246 } else {247 HANDLER = '.';248 }249 CMD_HELP += '*🎯 ' + Lang.COMMAND + ':* ```' + (cmatch.length >= 3 ? (HANDLER + cmatch[2]) : command.pattern) + (command.desc === '' ? '```\n\n' : '```\n');250 if (command.desc !== '') CMD_HELP += '*📝 ' + Lang.DESC + ':* ```' + command.desc + (command.warn === '' ? '```\n\n' : '```\n');251 if (command.usage !== '') CMD_HELP += '*⌨️ ' + Lang.EXAMPLE + ':* ```' + command.usage + '```\n\n';252 if (command.warn !== '') CMD_HELP += '*⚠️ ' + Lang.WARN + ':* ```' + command.warn + '```\n\n';253 }254 }255 );256 if (CMD_HELP === '') CMD_HELP += Lang.NOT_FOUND;257 await message.client.sendMessage(258 message.jid, MSG + CMD_HELP + FMSG, MessageType.text, {contextInfo: { forwardingScore: 49, isForwarded: true }, quoted: message.data});259 }...

Full Screen

Full Screen

commands.js

Source:commands.js Github

copy

Full Screen

1// Copyright 2012 Selenium committers2// Copyright 2012 Software Freedom Conservancy3//4// Licensed under the Apache License, Version 2.0 (the "License");5// you may not use this file except in compliance with the License.6// You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing, software11// distributed under the License is distributed on an "AS IS" BASIS,12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13// See the License for the specific language governing permissions and14// limitations under the License.15/**16 * @fileoverview Command handlers used by the SafariDriver's injected script.17 */18goog.provide('safaridriver.inject.commands');19goog.require('bot');20goog.require('bot.Error');21goog.require('bot.ErrorCode');22goog.require('bot.action');23goog.require('bot.dom');24goog.require('bot.frame');25goog.require('bot.inject');26goog.require('bot.inject.cache');27goog.require('bot.locators');28goog.require('bot.window');29goog.require('goog.array');30goog.require('goog.debug.Logger');31goog.require('goog.math.Coordinate');32goog.require('goog.math.Size');33goog.require('goog.net.cookies');34goog.require('goog.style');35goog.require('safaridriver.inject.CommandRegistry');36goog.require('safaridriver.inject.message.Activate');37goog.require('webdriver.atoms.element');38/**39 * @private {!goog.debug.Logger}40 * @const41 */42safaridriver.inject.commands.LOG_ = goog.debug.Logger.getLogger(43 'safaridriver.inject.commands');44/** @return {string} The name of the current window. */45safaridriver.inject.commands.getWindowName = function() {46 return window.name;47};48/** @return {string} The current URL. */49safaridriver.inject.commands.getCurrentUrl = function() {50 return window.location.href;51};52/**53 * Loads a new URL in the current page.54 * @param {!safaridriver.Command} command The command object.55 */56safaridriver.inject.commands.loadUrl = function(command) {57 window.location.href = /** @type {string} */ (command.getParameter('url'));58 // No need to send a response. The global page should be listening for the59 // navigate event.60};61/** Reloads the current page. */62safaridriver.inject.commands.reloadPage = function() {63 window.location.reload();64 // No need to send a response. The global page should be listening for the65 // navigate event.66};67/**68 * Stub that reports an error that navigating through the browser history does69 * not work for the SafariDriver.70 */71safaridriver.inject.commands.unsupportedHistoryNavigation = function() {72 throw Error('Yikes! Safari history navigation does not work. We can ' +73 'go forward or back, but once we do, we can no longer ' +74 'communicate with the page...');75};76/** @return {string} The document title. */77safaridriver.inject.commands.getTitle = function() {78 return document.title;79};80/** @return {string} A string representation of the current page source. */81safaridriver.inject.commands.getPageSource = function() {82 return new XMLSerializer().serializeToString(document);83};84/**85 * Defines an element locating command.86 * @param {function(!Object, (Document|Element)=):87 * (Element|!goog.array.ArrayLike.<Element>)} locatorFn The locator function88 * that should be used.89 * @return {function(!safaridriver.Command): !bot.response.ResponseObject} The90 * locator command function.91 * @private92 */93safaridriver.inject.commands.findElementCommand_ = function(locatorFn) {94 return function(command) {95 var locator = {};96 locator[command.getParameter('using')] = command.getParameter('value');97 var args = [locator];98 if (command.getParameter('id')) {99 args.push({'ELEMENT': command.getParameter('id')});100 }101 return bot.inject.executeScript(locatorFn, args);102 };103};104/**105 * Locates an element on the page.106 * @param {!safaridriver.Command} command The command object.107 * @return {!bot.response.ResponseObject} The command response.108 */109safaridriver.inject.commands.findElement =110 safaridriver.inject.commands.findElementCommand_(bot.locators.findElement);111/**112 * Locates multiple elements on the page.113 * @param {!safaridriver.Command} command The command object.114 * @return {bot.response.ResponseObject} The command response.115 */116safaridriver.inject.commands.findElements =117 safaridriver.inject.commands.findElementCommand_(bot.locators.findElements);118/**119 * Retrieves the element that currently has focus.120 * @return {!bot.response.ResponseObject} The response object.121 */122safaridriver.inject.commands.getActiveElement = function() {123 var getActiveElement = goog.partial(bot.dom.getActiveElement, document);124 return /** @type {!bot.response.ResponseObject} */ (bot.inject.executeScript(125 getActiveElement, []));126};127/**128 * Adds a new cookie to the page.129 * @param {!safaridriver.Command} command The command object.130 */131safaridriver.inject.commands.addCookie = function(command) {132 var cookie = command.getParameter('cookie');133 // The WebDriver wire protocol defines cookie expiration times in seconds134 // since midnight, January 1, 1970 UTC, but goog.net.Cookies expects them135 // to be in seconds since "right now".136 var maxAge = cookie['expiry'];137 if (goog.isNumber(maxAge)) {138 maxAge = new Date(maxAge - goog.now());139 }140 // TODO: check whether cookie['domain'] is valid.141 goog.net.cookies.set(cookie['name'], cookie['value'], maxAge,142 cookie['path'], cookie['domain'], cookie['secure']);143};144/**145 * @return {!Array.<{name:string, value:string}>} A list of the cookies visible146 * to the current page.147 */148safaridriver.inject.commands.getCookies = function() {149 var keys = goog.net.cookies.getKeys();150 return goog.array.map(keys, function(key) {151 return {152 'name': key,153 'value': goog.net.cookies.get(key)154 };155 });156};157/** Deletes all cookies visible to the current page. */158safaridriver.inject.commands.deleteCookies = function() {159 goog.net.cookies.clear();160};161/**162 * Deletes a specified cookie.163 * @param {!safaridriver.Command} command The command object.164 */165safaridriver.inject.commands.deleteCookie = function(command) {166 goog.net.cookies.remove(/** @type {string} */ (command.getParameter('name')));167};168/**169 * Creates a command that targets a specific DOM element.170 * @param {!Function} handlerFn The actual handler function. The first parameter171 * should be the Element to target.172 * @param {...string} var_args Any named parameters which should be extracted173 * and passed as arguments to {@code commandFn}.174 * @return {function(!safaridriver.Command)} The new element command function.175 * @private176 */177safaridriver.inject.commands.elementCommand_ = function(handlerFn, var_args) {178 var keys = goog.array.slice(arguments, 1);179 return function(command) {180 command = safaridriver.inject.commands.util.prepareElementCommand(command);181 var element = command.getParameter('id');182 var args = goog.array.concat(element, goog.array.map(keys, function(key) {183 return command.getParameter(key);184 }));185 return bot.inject.executeScript(handlerFn, args);186 };187};188/**189 * @param {!safaridriver.Command} command The command to execute.190 * @see bot.action.clear191 */192safaridriver.inject.commands.clearElement =193 safaridriver.inject.commands.elementCommand_(bot.action.clear);194/**195 * @param {!safaridriver.Command} command The command to execute.196 * @see bot.action.click197 */198safaridriver.inject.commands.clickElement =199 safaridriver.inject.commands.elementCommand_(bot.action.click);200/**201 * @param {!safaridriver.Command} command The command to execute.202 * @see bot.action.submit203 */204safaridriver.inject.commands.submitElement =205 safaridriver.inject.commands.elementCommand_(bot.action.submit);206/**207 * @param {!safaridriver.Command} command The command to execute.208 * @see webdriver.atoms.element.getAttribute209 */210safaridriver.inject.commands.getElementAttribute =211 safaridriver.inject.commands.elementCommand_(212 webdriver.atoms.element.getAttribute, 'name');213/**214 * @param {!safaridriver.Command} command The command to execute.215 * @see goog.style.getPageOffset216 */217safaridriver.inject.commands.getElementLocation =218 safaridriver.inject.commands.elementCommand_(goog.style.getPageOffset);219/**220 * @param {!safaridriver.Command} command The command to execute.221 * @see webdriver.atoms.element.getLocationInView222 */223safaridriver.inject.commands.getLocationInView =224 safaridriver.inject.commands.elementCommand_(225 webdriver.atoms.element.getLocationInView);226/**227 * @param {!safaridriver.Command} command The command to execute.228 * @see goog.style.getSize229 */230safaridriver.inject.commands.getElementSize =231 safaridriver.inject.commands.elementCommand_(goog.style.getSize);232/**233 * @param {!safaridriver.Command} command The command to execute.234 * @see webdriver.atoms.element.getText235 */236safaridriver.inject.commands.getElementText =237 safaridriver.inject.commands.elementCommand_(238 webdriver.atoms.element.getText);239/**240 * @param {!safaridriver.Command} command The command to execute.241 */242safaridriver.inject.commands.getElementTagName =243 safaridriver.inject.commands.elementCommand_(function(el) {244 return el.tagName.toLowerCase();245 });246/**247 * @param {!safaridriver.Command} command The command to execute.248 * @see bot.dom.isShown249 */250safaridriver.inject.commands.isElementDisplayed =251 safaridriver.inject.commands.elementCommand_(bot.dom.isShown);252/**253 * @param {!safaridriver.Command} command The command to execute.254 * @see bot.dom.isEnabled255 */256safaridriver.inject.commands.isElementEnabled =257 safaridriver.inject.commands.elementCommand_(bot.dom.isEnabled);258/**259 * @param {!safaridriver.Command} command The command to execute.260 * @see webdriver.atoms.element.isSelected261 */262safaridriver.inject.commands.isElementSelected =263 safaridriver.inject.commands.elementCommand_(264 webdriver.atoms.element.isSelected);265/**266 * @param {!safaridriver.Command} command The command to execute.267 */268safaridriver.inject.commands.elementEquals =269 safaridriver.inject.commands.elementCommand_(function(a, b) {270 return a === b;271 }, 'other');272/**273 * @param {!safaridriver.Command} command The command to execute.274 * @see bot.dom.getEffectiveStyle275 */276safaridriver.inject.commands.getCssValue =277 safaridriver.inject.commands.elementCommand_(bot.dom.getEffectiveStyle,278 'propertyName');279/**280 * @return {!goog.math.Coordinate} The position of the window.281 * @see bot.window.getPosition282 */283safaridriver.inject.commands.getWindowPosition = function() {284 return bot.window.getPosition();285};286/**287 * @param {!safaridriver.Command} command The command to execute.288 * @see bot.window.setPosition289 */290safaridriver.inject.commands.setWindowPosition = function(command) {291 var position = new goog.math.Coordinate(292 /** @type {number} */ (command.getParameter('x')),293 /** @type {number} */ (command.getParameter('y')));294 bot.window.setPosition(position);295};296/**297 * @return {!goog.math.Size} The size of the window.298 * @see bot.window.getSize299 */300safaridriver.inject.commands.getWindowSize = function() {301 return bot.window.getSize();302};303/**304 * @param {!safaridriver.Command} command The command to execute.305 * @see bot.window.setSize306 */307safaridriver.inject.commands.setWindowSize = function(command) {308 var size = new goog.math.Size(309 /** @type {number} */ (command.getParameter('width')),310 /** @type {number} */ (command.getParameter('height')));311 bot.window.setSize(size);312};313/** Maximizes the window. */314safaridriver.inject.commands.maximizeWindow = function() {315 window.moveTo(0, 0);316 window.resizeTo(window.screen.width, window.screen.height);317};318/**319 * Executes a command in the context of the current page.320 * @param {!safaridriver.Command} command The command to execute.321 * @param {!safaridriver.inject.Tab} tab A reference to the tab issuing this322 * command.323 * @return {!webdriver.promise.Promise} A promise that will be resolved with the324 * {@link bot.response.ResponseObject} from the page.325 * @throws {Error} If there is an error while sending the command to the page.326 */327safaridriver.inject.commands.executeInPage = function(command, tab) {328 command = safaridriver.inject.commands.util.prepareElementCommand(command);329 return tab.executeInPage(command);330};331/**332 * Locates a frame and sends a message to it to activate itself with the333 * extension. The located frame will be334 * @param {!safaridriver.Command} command The command to execute.335 * the target of all subsequent commands.336 * @throws {Error} If there is an error whilst locating the frame.337 */338safaridriver.inject.commands.switchToFrame = function(command) {339 var id = command.getParameter('id');340 var frameWindow;341 if (goog.isNull(id)) {342 safaridriver.inject.commands.LOG_.info('Resetting focus to window.top');343 frameWindow = window.top;344 } else if (goog.isString(id)) {345 safaridriver.inject.commands.LOG_.info(346 'Switching to frame by name or ID: ' + id);347 frameWindow = bot.frame.findFrameByNameOrId(/** @type {string} */ (id));348 } else if (goog.isNumber(id)) {349 safaridriver.inject.commands.LOG_.info(350 'Switching to frame by index: ' + id);351 frameWindow = bot.frame.findFrameByIndex(/** @type {number} */ (id));352 } else {353 var elementKey = /** @type {string} */ (id[bot.inject.ELEMENT_KEY]);354 safaridriver.inject.commands.LOG_.info('Switching to frame by ' +355 'WebElement: ' + elementKey);356 // ID must be a WebElement. Pull it from the cache.357 var frameElement = bot.inject.cache.getElement(elementKey);358 frameWindow = bot.frame.getFrameWindow(359 /** @type {!(HTMLIFrameElement|HTMLFrameElement)} */ (frameElement));360 }361 if (!frameWindow) {362 throw new bot.Error(bot.ErrorCode.NO_SUCH_FRAME,363 'Unable to locate frame with ' + id);364 }365 // De-activate ourselves. We should no longer respond to commands until366 // we are re-activated.367 safaridriver.inject.Tab.getInstance().setActive(false);368 var message = new safaridriver.inject.message.Activate(command);369 message.send(frameWindow);370};371goog.scope(function() {372var CommandName = webdriver.CommandName;373var commands = safaridriver.inject.commands;374// Commands that should be defined for every frame.375safaridriver.inject.CommandRegistry.getInstance()376 .defineModule(safaridriver.inject.commands.module.ID, goog.object.create(377 CommandName.ADD_COOKIE, commands.addCookie,378 CommandName.CLEAR_ELEMENT, commands.clearElement,379 CommandName.CLICK_ELEMENT, commands.clickElement,380 CommandName.DELETE_ALL_COOKIES, commands.deleteCookies,381 CommandName.DELETE_COOKIE, commands.deleteCookie,382 CommandName.ELEMENT_EQUALS, commands.elementEquals,383 CommandName.FIND_CHILD_ELEMENT, commands.findElement,384 CommandName.FIND_CHILD_ELEMENTS, commands.findElements,385 CommandName.FIND_ELEMENT, commands.findElement,386 CommandName.FIND_ELEMENTS, commands.findElements,387 CommandName.GET, commands.loadUrl,388 CommandName.GET_ACTIVE_ELEMENT, commands.getActiveElement,389 CommandName.GET_ALL_COOKIES, commands.getCookies,390 CommandName.GET_CURRENT_URL, commands.getCurrentUrl,391 CommandName.GET_ELEMENT_ATTRIBUTE, commands.getElementAttribute,392 CommandName.GET_ELEMENT_LOCATION, commands.getElementLocation,393 CommandName.GET_ELEMENT_LOCATION_IN_VIEW, commands.getLocationInView,394 CommandName.GET_ELEMENT_SIZE, commands.getElementSize,395 CommandName.GET_ELEMENT_TAG_NAME, commands.getElementTagName,396 CommandName.GET_ELEMENT_TEXT, commands.getElementText,397 CommandName.GET_ELEMENT_VALUE_OF_CSS_PROPERTY, commands.getCssValue,398 CommandName.GET_PAGE_SOURCE, commands.getPageSource,399 CommandName.GET_TITLE, commands.getTitle,400 CommandName.GET_WINDOW_POSITION, commands.getWindowPosition,401 CommandName.GET_WINDOW_SIZE, commands.getWindowSize,402 CommandName.GO_BACK, commands.unsupportedHistoryNavigation,403 CommandName.GO_FORWARD, commands.unsupportedHistoryNavigation,404 CommandName.IS_ELEMENT_DISPLAYED, commands.isElementDisplayed,405 CommandName.IS_ELEMENT_ENABLED, commands.isElementEnabled,406 CommandName.IS_ELEMENT_SELECTED, commands.isElementSelected,407 CommandName.MAXIMIZE_WINDOW, commands.maximizeWindow,408 CommandName.REFRESH, commands.reloadPage,409 CommandName.SET_WINDOW_POSITION, commands.setWindowPosition,410 CommandName.SET_WINDOW_SIZE, commands.setWindowSize,411 CommandName.SUBMIT_ELEMENT, commands.submitElement,412 CommandName.SWITCH_TO_FRAME, commands.switchToFrame,413 // The extension handles window switches. It sends the command to this414 // injected script only as a means of retrieving the window name.415 CommandName.SWITCH_TO_WINDOW, commands.getWindowName));...

Full Screen

Full Screen

server.js

Source:server.js Github

copy

Full Screen

1// Copyright 2012 Selenium committers2// Copyright 2012 Software Freedom Conservancy3//4// Licensed under the Apache License, Version 2.0 (the "License");5// you may not use this file except in compliance with the License.6// You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing, software11// distributed under the License is distributed on an "AS IS" BASIS,12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13// See the License for the specific language governing permissions and14// limitations under the License.15goog.provide('safaridriver.extension.Server');16goog.require('bot.ErrorCode');17goog.require('bot.response');18goog.require('goog.Disposable');19goog.require('goog.debug.Logger');20goog.require('goog.object');21goog.require('goog.string');22goog.require('safaridriver.Command');23goog.require('safaridriver.alert');24goog.require('safaridriver.extension.commands');25goog.require('safaridriver.message.Command');26goog.require('safaridriver.message.Response');27goog.require('webdriver.CommandName');28goog.require('webdriver.promise');29/**30 * Creates a new WebSocket server that may be used to communicate with a31 * SafariDriver client.32 *33 * <p>Note the name of this class is a bit misleading as it uses a WebSocket34 * to communicate with the client (i.e., the actual HTTP server is run by the35 * client).36 *37 * @param {!safaridriver.extension.Session} session The session associated with38 * this server.39 * @constructor40 * @implements {webdriver.CommandExecutor}41 * @extends {goog.Disposable}42 */43safaridriver.extension.Server = function(session) {44 goog.base(this);45 /** @private {!goog.debug.Logger} */46 this.log_ = goog.debug.Logger.getLogger('safaridriver.extension.Server');47 /** @private {!safaridriver.extension.Session} */48 this.session_ = session;49 /** @private {!webdriver.promise.Deferred} */50 this.ready_ = new webdriver.promise.Deferred();51 /** @private {!Array.<function()>} */52 this.disposeCallbacks_ = [];53};54goog.inherits(safaridriver.extension.Server, goog.Disposable);55/**56 * @typedef {(function(!safaridriver.extension.Session, !safaridriver.Command)|57 * function(!safaridriver.extension.Session))}58 */59safaridriver.extension.Server.CommandHandler;60/**61 * Maps command names to their handler functions.62 * @private {!Object.<webdriver.CommandName,63 * safaridriver.extension.Server.CommandHandler>}64 * @const65 */66safaridriver.extension.Server.COMMAND_MAP_ = {};67goog.scope(function() {68var CommandName = webdriver.CommandName;69var commands = safaridriver.extension.commands;70var map = safaridriver.extension.Server.COMMAND_MAP_;71map[CommandName.NEW_SESSION] = commands.newSession;72map[CommandName.DESCRIBE_SESSION] = commands.describeSession;73// We can't shutdown Safari from an extension, but we can quietly handle the74// command so we don't return an unknown command error.75map[CommandName.QUIT] = goog.nullFunction;76map[CommandName.CLOSE] = commands.closeTab;77map[CommandName.GET_CURRENT_WINDOW_HANDLE] = commands.getWindowHandle;78map[CommandName.GET_WINDOW_HANDLES] = commands.getWindowHandles;79map[CommandName.GET_CURRENT_URL] = commands.sendCommand;80map[CommandName.GET_TITLE] = commands.sendCommand;81map[CommandName.GET_PAGE_SOURCE] = commands.sendCommand;82map[CommandName.GET] = commands.loadUrl;83map[CommandName.REFRESH] = commands.refresh;84map[CommandName.GO_BACK] = commands.sendCommand;85map[CommandName.GO_FORWARD] = commands.sendCommand;86map[CommandName.GO_BACK] = commands.sendCommand;87map[CommandName.ADD_COOKIE] = commands.sendCommand;88map[CommandName.GET_ALL_COOKIES] = commands.sendCommand;89map[CommandName.DELETE_ALL_COOKIES] = commands.sendCommand;90map[CommandName.DELETE_COOKIE] = commands.sendCommand;91map[CommandName.IMPLICITLY_WAIT] = commands.implicitlyWait;92map[CommandName.FIND_ELEMENT] = commands.findElement;93map[CommandName.FIND_ELEMENTS] = commands.findElement;94map[CommandName.FIND_CHILD_ELEMENT] = commands.findElement;95map[CommandName.FIND_CHILD_ELEMENTS] = commands.findElement;96map[CommandName.GET_ACTIVE_ELEMENT] = commands.sendCommand;97map[CommandName.CLEAR_ELEMENT] = commands.sendCommand;98map[CommandName.CLICK_ELEMENT] = commands.sendCommand;99map[CommandName.SUBMIT_ELEMENT] = commands.sendCommand;100map[CommandName.GET_ELEMENT_TEXT] = commands.sendCommand;101map[CommandName.GET_ELEMENT_TAG_NAME] = commands.sendCommand;102map[CommandName.IS_ELEMENT_SELECTED] = commands.sendCommand;103map[CommandName.IS_ELEMENT_ENABLED] = commands.sendCommand;104map[CommandName.IS_ELEMENT_DISPLAYED] = commands.sendCommand;105map[CommandName.GET_ELEMENT_LOCATION] = commands.sendCommand;106map[CommandName.GET_ELEMENT_LOCATION_IN_VIEW] = commands.sendCommand;107map[CommandName.GET_ELEMENT_SIZE] = commands.sendCommand;108map[CommandName.GET_ELEMENT_ATTRIBUTE] = commands.sendCommand;109map[CommandName.GET_ELEMENT_VALUE_OF_CSS_PROPERTY] = commands.sendCommand;110map[CommandName.ELEMENT_EQUALS] = commands.sendCommand;111map[CommandName.SEND_KEYS_TO_ELEMENT] = commands.sendCommand;112map[CommandName.CLICK] = commands.sendCommand;113map[CommandName.DOUBLE_CLICK] = commands.sendCommand;114map[CommandName.MOUSE_DOWN] = commands.sendCommand;115map[CommandName.MOUSE_UP] = commands.sendCommand;116map[CommandName.MOVE_TO] = commands.sendCommand;117map[CommandName.SEND_KEYS_TO_ACTIVE_ELEMENT] = commands.sendCommand;118map[CommandName.SWITCH_TO_FRAME] = commands.sendCommand;119map[CommandName.SWITCH_TO_WINDOW] = commands.switchToWindow;120map[CommandName.SET_WINDOW_SIZE] = commands.sendWindowCommand;121map[CommandName.SET_WINDOW_POSITION] = commands.sendWindowCommand;122map[CommandName.GET_WINDOW_SIZE] = commands.sendWindowCommand;123map[CommandName.GET_WINDOW_POSITION] = commands.sendWindowCommand;124map[CommandName.MAXIMIZE_WINDOW] = commands.sendWindowCommand;125map[CommandName.EXECUTE_SCRIPT] = commands.sendCommand;126map[CommandName.EXECUTE_ASYNC_SCRIPT] = commands.executeAsyncScript;127map[CommandName.SET_SCRIPT_TIMEOUT] = commands.setScriptTimeout;128map[CommandName.SCREENSHOT] = commands.takeScreenshot;129map[CommandName.ACCEPT_ALERT] = commands.handleNoAlertsPresent;130map[CommandName.DISMISS_ALERT] = commands.handleNoAlertsPresent;131map[CommandName.GET_ALERT_TEXT] = commands.handleNoAlertsPresent;132map[CommandName.SET_ALERT_TEXT] = commands.handleNoAlertsPresent133map[CommandName.GET_AVAILABLE_LOG_TYPES] = commands.getAvailableLogTypes;134map[CommandName.GET_LOG] = commands.getLogs;135}); // goog.scope136/**137 * The WebSocket used by this instance, lazily initialized in {@link #connect}.138 * @private {WebSocket}139 */140safaridriver.extension.Server.prototype.webSocket_ = null;141/** @override */142safaridriver.extension.Server.prototype.disposeInternal = function() {143 this.logMessage_('Disposing of server', goog.debug.Logger.Level.FINE);144 if (this.webSocket_) {145 if (this.ready_.isPending()) {146 this.ready_.cancel(Error('Server has been disposed'));147 }148 this.disposeWebSocket_();149 }150 while (this.disposeCallbacks_.length) {151 var callback = this.disposeCallbacks_.shift();152 callback();153 }154 delete this.disposeCallbacks_;155 delete this.log_;156 delete this.session_;157 delete this.ready_;158 delete this.webSocket_;159 goog.base(this, 'disposeInternal');160};161/** @private */162safaridriver.extension.Server.prototype.disposeWebSocket_ = function() {163 if (this.webSocket_) {164 var webSocket = this.webSocket_;165 this.webSocket_ = null;166 webSocket.onopen = goog.nullFunction;167 webSocket.onclose = goog.nullFunction;168 webSocket.onmessage = goog.nullFunction;169 webSocket.onerror = goog.nullFunction;170 webSocket.close();171 }172};173/** @return {!safaridriver.extension.Session} The session for this server. */174safaridriver.extension.Server.prototype.getSession = function() {175 return this.session_;176};177/**178 * Registers a callback to be called when this server is disposed. If the server179 * has already been disposed, the callback will be invoked immediately.180 * @param {function()} fn The callback function.181 */182safaridriver.extension.Server.prototype.onDispose = function(fn) {183 if (this.isDisposed()) {184 fn();185 } else {186 this.disposeCallbacks_.push(fn);187 }188};189/**190 * Set of URLs that {@link safaridriver.extension.Server} instances are191 * connected to.192 * @private {!Object}193 */194safaridriver.extension.Server.connectedUrls_ = {};195/**196 * Connects to a server.197 * @param {string} url URL to connect to.198 * @return {!webdriver.promise.Promise} A promise that will be resolved when199 * this server has connected.200 * @throws {Error} If this server has already connected to a server.201 */202safaridriver.extension.Server.prototype.connect = function(url) {203 if (this.isDisposed()) {204 throw Error('This server has been disposed!');205 }206 if (this.webSocket_) {207 throw Error('This server has already connected!');208 }209 this.attemptConnect_(url);210 return this.ready_.promise;211};212/**213 * Attempts to open a WebSocket connection with the given URL.214 * @param {string} url The URL to attempt to connect to.215 * @private216 */217safaridriver.extension.Server.prototype.attemptConnect_ = function(url) {218 if (safaridriver.extension.Server.connectedUrls_[url]) {219 throw Error('Another instance is already connected to ' + url);220 }221 safaridriver.extension.Server.connectedUrls_[url] = true;222 this.logMessage_('Attempting to connect to ' + url);223 // Register the event handlers. Note that it is not possible for these224 // callbacks to be missed because it is registered after the web socket is225 // instantiated. Because of the synchronous nature of JavaScript, this code226 // will execute before the browser creates the resource and makes any calls227 // to these callbacks.228 this.webSocket_ = new WebSocket(url);229 this.webSocket_.onopen = goog.bind(this.onOpen_, this);230 this.webSocket_.onclose = goog.bind(this.onClose_, this, url);231 this.webSocket_.onmessage = goog.bind(this.onMessage_, this);232 this.webSocket_.onerror = goog.bind(this.onError_, this);233};234/**235 * Executes a single command once all those received before it have completed.236 * @param {!webdriver.Command} command The command to execute.237 * @param {function(Error, !bot.response.ResponseObject=)=} opt_callback A238 * callback function for adherence to the {@link webdriver.CommandExecutor}239 * interface.240 * @return {!webdriver.promise.Promise} A promise that will be resolved with a241 * {@link bot.response.ResponseObject} object once the command has242 * completed.243 */244safaridriver.extension.Server.prototype.execute = function(245 command, opt_callback) {246 // Normally command will be an instanceof safaridriver.Command, but it will be247 // a standard webdriver.Command if it came from248 // safaridriver.extension.driver (via the extension builder REPL).249 command = new safaridriver.Command(goog.string.getRandomString(),250 command.getName(), command.getParameters());251 var handler = safaridriver.extension.Server.COMMAND_MAP_[command.getName()];252 if (!handler) {253 this.logMessage_('Unknown command: ' + command.getName(),254 goog.debug.Logger.Level.SEVERE);255 return webdriver.promise.rejected(bot.response.createErrorResponse(256 Error('Unknown command: ' + command.getName())));257 }258 var description = this.session_.getId() + '::' + command.getName();259 var fn = goog.bind(this.executeCommand_, this, command, handler);260 var flow = webdriver.promise.controlFlow();261 var result = flow.execute(fn, description).262 then(bot.response.createResponse, bot.response.createErrorResponse).263 thenFinally(goog.bind(function(response) {264 this.session_.setCurrentCommand(null);265 return response;266 }, this));267 // If we were given a callback, massage the result to fit the268 // webdriver.CommandExecutor contract.269 if (opt_callback) {270 result.then(bot.response.checkResponse).271 then(goog.partial(opt_callback, null), opt_callback);272 }273 return result;274};275/**276 * @param {!safaridriver.Command} command The command to execute.277 * @param {safaridriver.extension.Server.CommandHandler} handler The command278 * handler.279 * @return {*} The command result.280 * @private281 */282safaridriver.extension.Server.prototype.executeCommand_ = function(283 command, handler) {284 this.logMessage_('Executing command: ' + command.getName());285 var alertText = this.session_.getUnhandledAlertText();286 if (!goog.isNull(alertText)) {287 this.session_.setUnhandledAlertText(null);288 return safaridriver.alert.createResponse(alertText);289 }290 this.session_.setCurrentCommand(command);291 return handler(this.session_, command);292};293/**294 * @param {string} message The message to log.295 * @param {goog.debug.Logger.Level=} opt_level The level to log the message at;296 * Defaults to INFO.297 * @private298 */299safaridriver.extension.Server.prototype.logMessage_ = function(300 message, opt_level) {301 this.log_.log(opt_level || goog.debug.Logger.Level.INFO,302 '[' + this.session_.getId() + '] ' + message);303};304/**305 * Called when the WebSocket connection is opened.306 * @private307 */308safaridriver.extension.Server.prototype.onOpen_ = function() {309 this.logMessage_('WebSocket connection established.');310 if (!this.isDisposed() && this.ready_.isPending()) {311 this.ready_.fulfill();312 }313};314/**315 * Called when an attempt to open the WebSocket fails or there is a connection316 * failure after a successful connection has been established. Triggers the317 * disposable of this server.318 * @param {string} url The URL the WebSocket was connected to.319 * @private320 */321safaridriver.extension.Server.prototype.onClose_ = function(url) {322 safaridriver.extension.Server.connectedUrls_[url] = false;323 this.logMessage_('WebSocket connection was closed.',324 goog.debug.Logger.Level.WARNING);325 if (!this.isDisposed()) {326 if (this.ready_.isPending()) {327 var message = 'Failed to connect to ' + url;328 this.logMessage_(message);329 this.disposeWebSocket_();330 setTimeout(goog.bind(this.attemptConnect_, this, url), 500);331 } else {332 this.dispose();333 }334 }335};336/**337 * Called when there is a communication error with the WebSocket.338 * @param {!MessageEvent} event The error event.339 * @private340 */341safaridriver.extension.Server.prototype.onError_ = function(event) {342 this.logMessage_('There was an error in the WebSocket: ' + event.data,343 goog.debug.Logger.Level.SEVERE);344};345/**346 * Called when the WebSocket receives a message.347 * @param {!MessageEvent} event The message event.348 * @private349 */350safaridriver.extension.Server.prototype.onMessage_ = function(event) {351 this.logMessage_('Received a message: ' + event.data,352 goog.debug.Logger.Level.FINER);353 try {354 var message = safaridriver.message.fromEvent(event);355 if (!message.isType(safaridriver.message.Command.TYPE)) {356 throw Error('Not a command message: ' + message);357 }358 } catch (ex) {359 this.send_(null, bot.response.createErrorResponse(ex));360 return;361 }362 var command = message.getCommand();363 this.execute(command).364 thenCatch(bot.response.createErrorResponse).365 then(goog.bind(function(response) {366 this.send_(command, response);367 }, this));368};369/**370 * Sends a response to the client.371 * @param {safaridriver.Command} command The command this is a response to, or372 * {@code null} if the response indicates a parse error with the command.373 * @param {!bot.response.ResponseObject} response The response to send.374 * @private375 */376safaridriver.extension.Server.prototype.send_ = function(command, response) {377 var id = command ? command.id : '';378 var message = new safaridriver.message.Response(id, response);379 var str = message.toString();380 this.logMessage_('Sending response: ' + str);381 if (!command && response['status'] === bot.ErrorCode.SUCCESS) {382 this.logMessage_('Sending success response with a null command: ' + str,383 goog.debug.Logger.Level.WARNING);384 }385 this.webSocket_.send(str);...

Full Screen

Full Screen

context-menu-manager-spec.js

Source:context-menu-manager-spec.js Github

copy

Full Screen

1const ContextMenuManager = require('../src/context-menu-manager');2describe('ContextMenuManager', function() {3 let [contextMenu, parent, child, grandchild] = [];4 beforeEach(function() {5 const { resourcePath } = atom.getLoadSettings();6 contextMenu = new ContextMenuManager({ keymapManager: atom.keymaps });7 contextMenu.initialize({ resourcePath });8 parent = document.createElement('div');9 child = document.createElement('div');10 grandchild = document.createElement('div');11 parent.tabIndex = -1;12 child.tabIndex = -1;13 grandchild.tabIndex = -1;14 parent.classList.add('parent');15 child.classList.add('child');16 grandchild.classList.add('grandchild');17 child.appendChild(grandchild);18 parent.appendChild(child);19 document.body.appendChild(parent);20 });21 afterEach(function() {22 document.body.blur();23 document.body.removeChild(parent);24 });25 describe('::add(itemsBySelector)', function() {26 it('can add top-level menu items that can be removed with the returned disposable', function() {27 const disposable = contextMenu.add({28 '.parent': [{ label: 'A', command: 'a' }],29 '.child': [{ label: 'B', command: 'b' }],30 '.grandchild': [{ label: 'C', command: 'c' }]31 });32 expect(contextMenu.templateForElement(grandchild)).toEqual([33 { label: 'C', command: 'c' },34 { label: 'B', command: 'b' },35 { label: 'A', command: 'a' }36 ]);37 disposable.dispose();38 expect(contextMenu.templateForElement(grandchild)).toEqual([]);39 });40 it('can add submenu items to existing menus that can be removed with the returned disposable', function() {41 const disposable1 = contextMenu.add({42 '.grandchild': [{ label: 'A', submenu: [{ label: 'B', command: 'b' }] }]43 });44 const disposable2 = contextMenu.add({45 '.grandchild': [{ label: 'A', submenu: [{ label: 'C', command: 'c' }] }]46 });47 expect(contextMenu.templateForElement(grandchild)).toEqual([48 {49 label: 'A',50 submenu: [{ label: 'B', command: 'b' }, { label: 'C', command: 'c' }]51 }52 ]);53 disposable2.dispose();54 expect(contextMenu.templateForElement(grandchild)).toEqual([55 {56 label: 'A',57 submenu: [{ label: 'B', command: 'b' }]58 }59 ]);60 disposable1.dispose();61 expect(contextMenu.templateForElement(grandchild)).toEqual([]);62 });63 it('favors the most specific / recently added item in the case of a duplicate label', function() {64 grandchild.classList.add('foo');65 const disposable1 = contextMenu.add({66 '.grandchild': [{ label: 'A', command: 'a' }]67 });68 const disposable2 = contextMenu.add({69 '.grandchild.foo': [{ label: 'A', command: 'b' }]70 });71 const disposable3 = contextMenu.add({72 '.grandchild': [{ label: 'A', command: 'c' }]73 });74 contextMenu.add({75 '.child': [{ label: 'A', command: 'd' }]76 });77 expect(contextMenu.templateForElement(grandchild)).toEqual([78 { label: 'A', command: 'b' }79 ]);80 disposable2.dispose();81 expect(contextMenu.templateForElement(grandchild)).toEqual([82 { label: 'A', command: 'c' }83 ]);84 disposable3.dispose();85 expect(contextMenu.templateForElement(grandchild)).toEqual([86 { label: 'A', command: 'a' }87 ]);88 disposable1.dispose();89 expect(contextMenu.templateForElement(grandchild)).toEqual([90 { label: 'A', command: 'd' }91 ]);92 });93 it('allows multiple separators, but not adjacent to each other', function() {94 contextMenu.add({95 '.grandchild': [96 { label: 'A', command: 'a' },97 { type: 'separator' },98 { type: 'separator' },99 { label: 'B', command: 'b' },100 { type: 'separator' },101 { type: 'separator' },102 { label: 'C', command: 'c' }103 ]104 });105 expect(contextMenu.templateForElement(grandchild)).toEqual([106 { label: 'A', command: 'a' },107 { type: 'separator' },108 { label: 'B', command: 'b' },109 { type: 'separator' },110 { label: 'C', command: 'c' }111 ]);112 });113 it('excludes items marked for display in devMode unless in dev mode', function() {114 contextMenu.add({115 '.grandchild': [116 { label: 'A', command: 'a', devMode: true },117 { label: 'B', command: 'b', devMode: false }118 ]119 });120 expect(contextMenu.templateForElement(grandchild)).toEqual([121 { label: 'B', command: 'b' }122 ]);123 contextMenu.devMode = true;124 expect(contextMenu.templateForElement(grandchild)).toEqual([125 { label: 'A', command: 'a' },126 { label: 'B', command: 'b' }127 ]);128 });129 it('allows items to be associated with `created` hooks which are invoked on template construction with the item and event', function() {130 let createdEvent = null;131 const item = {132 label: 'A',133 command: 'a',134 created(event) {135 this.command = 'b';136 createdEvent = event;137 }138 };139 contextMenu.add({ '.grandchild': [item] });140 const dispatchedEvent = { target: grandchild };141 expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual([142 { label: 'A', command: 'b' }143 ]);144 expect(item.command).toBe('a'); // doesn't modify original item template145 expect(createdEvent).toBe(dispatchedEvent);146 });147 it('allows items to be associated with `shouldDisplay` hooks which are invoked on construction to determine whether the item should be included', function() {148 let shouldDisplayEvent = null;149 let shouldDisplay = true;150 const item = {151 label: 'A',152 command: 'a',153 shouldDisplay(event) {154 this.foo = 'bar';155 shouldDisplayEvent = event;156 return shouldDisplay;157 }158 };159 contextMenu.add({ '.grandchild': [item] });160 const dispatchedEvent = { target: grandchild };161 expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual([162 { label: 'A', command: 'a' }163 ]);164 expect(item.foo).toBeUndefined(); // doesn't modify original item template165 expect(shouldDisplayEvent).toBe(dispatchedEvent);166 shouldDisplay = false;167 expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual([]);168 });169 it('prunes a trailing separator', function() {170 contextMenu.add({171 '.grandchild': [172 { label: 'A', command: 'a' },173 { type: 'separator' },174 { label: 'B', command: 'b' },175 { type: 'separator' }176 ]177 });178 expect(contextMenu.templateForEvent({ target: grandchild }).length).toBe(179 3180 );181 });182 it('prunes a leading separator', function() {183 contextMenu.add({184 '.grandchild': [185 { type: 'separator' },186 { label: 'A', command: 'a' },187 { type: 'separator' },188 { label: 'B', command: 'b' }189 ]190 });191 expect(contextMenu.templateForEvent({ target: grandchild }).length).toBe(192 3193 );194 });195 it('prunes duplicate separators', function() {196 contextMenu.add({197 '.grandchild': [198 { label: 'A', command: 'a' },199 { type: 'separator' },200 { type: 'separator' },201 { label: 'B', command: 'b' }202 ]203 });204 expect(contextMenu.templateForEvent({ target: grandchild }).length).toBe(205 3206 );207 });208 it('prunes all redundant separators', function() {209 contextMenu.add({210 '.grandchild': [211 { type: 'separator' },212 { type: 'separator' },213 { label: 'A', command: 'a' },214 { type: 'separator' },215 { type: 'separator' },216 { label: 'B', command: 'b' },217 { label: 'C', command: 'c' },218 { type: 'separator' },219 { type: 'separator' }220 ]221 });222 expect(contextMenu.templateForEvent({ target: grandchild }).length).toBe(223 4224 );225 });226 it('throws an error when the selector is invalid', function() {227 let addError = null;228 try {229 contextMenu.add({ '<>': [{ label: 'A', command: 'a' }] });230 } catch (error) {231 addError = error;232 }233 expect(addError.message).toContain('<>');234 });235 it('calls `created` hooks for submenu items', function() {236 const item = {237 label: 'A',238 command: 'B',239 submenu: [240 {241 label: 'C',242 created(event) {243 this.label = 'D';244 }245 }246 ]247 };248 contextMenu.add({ '.grandchild': [item] });249 const dispatchedEvent = { target: grandchild };250 expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual([251 {252 label: 'A',253 command: 'B',254 submenu: [255 {256 label: 'D'257 }258 ]259 }260 ]);261 });262 });263 describe('::templateForEvent(target)', function() {264 let [keymaps, item] = [];265 beforeEach(function() {266 keymaps = atom.keymaps.add('source', {267 '.child': {268 'ctrl-a': 'test:my-command',269 'shift-b': 'test:my-other-command'270 }271 });272 item = {273 label: 'My Command',274 command: 'test:my-command',275 submenu: [276 {277 label: 'My Other Command',278 command: 'test:my-other-command'279 }280 ]281 };282 contextMenu.add({ '.parent': [item] });283 });284 afterEach(() => keymaps.dispose());285 it('adds Electron-style accelerators to items that have keybindings', function() {286 child.focus();287 const dispatchedEvent = { target: child };288 expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual([289 {290 label: 'My Command',291 command: 'test:my-command',292 accelerator: 'Ctrl+A',293 submenu: [294 {295 label: 'My Other Command',296 command: 'test:my-other-command',297 accelerator: 'Shift+B'298 }299 ]300 }301 ]);302 });303 it('adds accelerators when a parent node has key bindings for a given command', function() {304 grandchild.focus();305 const dispatchedEvent = { target: grandchild };306 expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual([307 {308 label: 'My Command',309 command: 'test:my-command',310 accelerator: 'Ctrl+A',311 submenu: [312 {313 label: 'My Other Command',314 command: 'test:my-other-command',315 accelerator: 'Shift+B'316 }317 ]318 }319 ]);320 });321 it('does not add accelerators when a child node has key bindings for a given command', function() {322 parent.focus();323 const dispatchedEvent = { target: parent };324 expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual([325 {326 label: 'My Command',327 command: 'test:my-command',328 submenu: [329 {330 label: 'My Other Command',331 command: 'test:my-other-command'332 }333 ]334 }335 ]);336 });337 it('adds accelerators based on focus, not context menu target', function() {338 grandchild.focus();339 const dispatchedEvent = { target: parent };340 expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual([341 {342 label: 'My Command',343 command: 'test:my-command',344 accelerator: 'Ctrl+A',345 submenu: [346 {347 label: 'My Other Command',348 command: 'test:my-other-command',349 accelerator: 'Shift+B'350 }351 ]352 }353 ]);354 });355 it('does not add accelerators for multi-keystroke key bindings', function() {356 atom.keymaps.add('source', {357 '.child': {358 'ctrl-a ctrl-b': 'test:multi-keystroke-command'359 }360 });361 contextMenu.clear();362 contextMenu.add({363 '.parent': [364 {365 label: 'Multi-keystroke command',366 command: 'test:multi-keystroke-command'367 }368 ]369 });370 child.focus();371 const label = process.platform === 'darwin' ? '⌃A ⌃B' : 'Ctrl+A Ctrl+B';372 expect(contextMenu.templateForEvent({ target: child })).toEqual([373 {374 label: `Multi-keystroke command [${label}]`,375 command: 'test:multi-keystroke-command'376 }377 ]);378 });379 });380 describe('::templateForEvent(target) (sorting)', function() {381 it('applies simple sorting rules', function() {382 contextMenu.add({383 '.parent': [384 {385 label: 'My Command',386 command: 'test:my-command',387 after: ['test:my-other-command']388 },389 {390 label: 'My Other Command',391 command: 'test:my-other-command'392 }393 ]394 });395 const dispatchedEvent = { target: parent };396 expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual([397 {398 label: 'My Other Command',399 command: 'test:my-other-command'400 },401 {402 label: 'My Command',403 command: 'test:my-command',404 after: ['test:my-other-command']405 }406 ]);407 });408 it('applies sorting rules recursively to submenus', function() {409 contextMenu.add({410 '.parent': [411 {412 submenu: [413 {414 label: 'My Command',415 command: 'test:my-command',416 after: ['test:my-other-command']417 },418 {419 label: 'My Other Command',420 command: 'test:my-other-command'421 }422 ]423 }424 ]425 });426 const dispatchedEvent = { target: parent };427 expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual([428 {429 submenu: [430 {431 label: 'My Other Command',432 command: 'test:my-other-command'433 },434 {435 label: 'My Command',436 command: 'test:my-command',437 after: ['test:my-other-command']438 }439 ]440 }441 ]);442 });443 });...

Full Screen

Full Screen

navtreeindex0.js

Source:navtreeindex0.js Github

copy

Full Screen

1var NAVTREEINDEX0 =2{3"_mtk___packet_8h_source.html":[2,0,0,0,0],4"dir_29c008a3d6007eb363d0585658336295.html":[2,0,0,0],5"dir_47892d94e1d0bf342f4cec549ae2e06e.html":[2,0,0],6"dir_74389ed8173ad57b461b9d623a1f3867.html":[2,0],7"files.html":[2],8"group__pmtk__appendix.html":[1,0],9"group__pmtk__command.html":[1,1],10"group__pmtk__command.html#ga6012e5fa857099f0e5fd61bb6d1f84be":[1,1,0],11"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea00bfa74b9ab4be1cb538d6720808c007":[1,1,0,89],12"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea037ee569708e29066d04d6b24a589998":[1,1,0,92],13"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea05ed0801721f44c80238d29c18bf9a02":[1,1,0,51],14"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea063d8815c8ee51cd08acda80daa1e81e":[1,1,0,64],15"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea08e334f61a3facbee28df70210d878d3":[1,1,0,66],16"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea1265f33d4aba1384f11ef5872119f573":[1,1,0,22],17"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea1397b023e0d48ec75adabef05a22e061":[1,1,0,87],18"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea144340c8d86359dce90bcdc73a1c3f47":[1,1,0,47],19"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea153232faf17c74620043aa97852fbf93":[1,1,0,33],20"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea1552640a94f244c1a0c27e14bafdd426":[1,1,0,100],21"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea19e1adb3e180af8c09c84c63ae9e789f":[1,1,0,90],22"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea1c16678ddc76189e4215f65893655821":[1,1,0,19],23"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea1ce00a71b2d49bed618e16eaf551cd9a":[1,1,0,52],24"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea1f021ebe90b969144edb422d2e41d62d":[1,1,0,88],25"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea2625b3468647086a44ea53b5e7b58288":[1,1,0,77],26"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea2855fd322f2e27500a2844b7776c1061":[1,1,0,26],27"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea2ac3e95cf254fb53202aa90270d17492":[1,1,0,98],28"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea2edaf5cac4aa4a2fc73b5312d7428b24":[1,1,0,41],29"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea32f454682a68a9c3bccef8e25b15b8ba":[1,1,0,63],30"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea349fe122413c42817cdd46f0888a6c5f":[1,1,0,61],31"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea377b4ea82070d970dbfa11b6cf426594":[1,1,0,43],32"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea37e936f37aef1900a7e5a87fddbf8861":[1,1,0,11],33"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea3ace760b44e085e0142fef46f1837e0d":[1,1,0,4],34"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea3c5bcc16f2cb139831b0c05d7e77d4d3":[1,1,0,3],35"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea3f53bb52d96bb7739b2c6cf17d05c268":[1,1,0,76],36"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea3fb309c02edc5daf43592d9f2959928e":[1,1,0,46],37"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea42011586fa1fca5a3643cac6b05b60c0":[1,1,0,97],38"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea466830c3723b4afc4ffaa5d389f528c3":[1,1,0,9],39"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea467817db20c8c590ea5c065e5faa1f53":[1,1,0,37],40"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea48aff60bb41ea828e9ccaf810f3f47f9":[1,1,0,7],41"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea55bd5f9f60b4113329eef6c1ad3ed296":[1,1,0,50],42"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea56cefa0d6551ed89dc1974929c35a875":[1,1,0,23],43"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea5d520ba1d9f1b61bcce90b521632c32d":[1,1,0,16],44"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea6732848b6864eda4c0bf2d6e665ebeb9":[1,1,0,71],45"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea684eb8a711e4201f6de6aa5067100f21":[1,1,0,0],46"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea69756339c6d97ad458e3ccadc60e3059":[1,1,0,14],47"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea6b852645bdf9e0680bb45017559105e5":[1,1,0,86],48"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea6dc3a9739c6f1928716ee2c97e28204b":[1,1,0,82],49"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea72e57a8d23a2f9d09d2c9685cb93d9c7":[1,1,0,81],50"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea7bc54655b91905cd5de5770adef0b58e":[1,1,0,91],51"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea7bd230a1d411831e909a6bdeaec2f7eb":[1,1,0,5],52"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea7cff33d092ea4b69a868898082a9383d":[1,1,0,8],53"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea8060ce5da125915a4b00f7aff4220889":[1,1,0,30],54"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea807d8bf7605b87d790f4593f06dbb2f6":[1,1,0,69],55"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea815b92d27ea9a9adb14e4dbf2c6eb939":[1,1,0,6],56"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea8371d87a4fab64e97e5a53200fa6cda2":[1,1,0,28],57"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea83e665f81bc20f6d8e425e0749f3f288":[1,1,0,29],58"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea86e6074288800bb3626e16e735dcc6f8":[1,1,0,96],59"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea8782a9c367032850565b8d449225ddda":[1,1,0,31],60"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea8789b7bc5c5abad0ab627ad50aba79d4":[1,1,0,17],61"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea8a11d9cb5cca390770b0f6b6ffc64b5a":[1,1,0,56],62"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea8d1f075aa6a35cbca97ca5fb7ac07fa1":[1,1,0,49],63"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea8ddbdbf2649933cc970f831500dfe66f":[1,1,0,39],64"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea94e91e0b1e6fa7207f32a1f49bdf5c94":[1,1,0,57],65"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea9873165a5537dafa3b4c57dbea50d258":[1,1,0,45],66"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea9b4d921b1fe8ac8f59195773a81a9aa3":[1,1,0,48],67"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea9b58e4f853bd537a8d44fe1021c57bb1":[1,1,0,34],68"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea9c0c1ca48067fdd105f70e04487ff701":[1,1,0,65],69"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea9c90d1ead04106ba8d52a532d9e0cb14":[1,1,0,83],70"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea9e2fbd7c984e5e6e082b3825b060ca00":[1,1,0,25],71"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bea9e91e2fdcbc35d2cb5e9c9fe9f564e98":[1,1,0,18],72"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaa23a5c6e8e35b989498e6b6b101731e7":[1,1,0,24],73"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaa84af36afd8dbaa82b104bbf0b263592":[1,1,0,59],74"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaa8d6e40f333aff7e4435f88809042ac8":[1,1,0,40],75"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaa932726f1937dfdd7955fbee8819489a":[1,1,0,55],76"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaa93754c9b38d52d93c691c0ab53a7b7d":[1,1,0,94],77"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaa957fa7398464443cff5412f35fd0611":[1,1,0,2],78"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaa99559cfe61a412f1e302dc39021b879":[1,1,0,53],79"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaafb3f64364e21510313190785e3fc7d0":[1,1,0,36],80"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beab0a80b268936db695d5a7ccff70e10bf":[1,1,0,78],81"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beab139be3d7b4b2482f2838bac51db2b39":[1,1,0,62],82"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beab2b4ec0b0540e9fc51bc8a839d44c8ff":[1,1,0,68],83"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beab3eae09a18fc5417f8b359d9efdfd235":[1,1,0,60],84"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beab7a9a31d9329df65b587ae512e1e6a14":[1,1,0,13],85"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beab85d515c5cb70af97c6afb7f15e225b2":[1,1,0,70],86"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beabadd7524424255f446ccfd0a37b1df97":[1,1,0,72],87"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beabbbb799ada6d27a16cb6a9e7fabcc0fd":[1,1,0,27],88"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beabf86ac7cc7d3b0ce907b0a86e6a1338b":[1,1,0,1],89"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beac6d9aff834a28ac4feddf34a66102a43":[1,1,0,85],90"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beac94b5ff1087757868d8afeff20c011fa":[1,1,0,20],91"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaca811436d2d5072939d0f5cee493231c":[1,1,0,12],92"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beace569382848d8559a16fa090e8d56100":[1,1,0,42],93"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bead2312b41c26e764ef34621c560f9973c":[1,1,0,58],94"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bead7650c8cb304121491fdf61bc284c036":[1,1,0,80],95"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bead7e27c02b08d6ff4296f7a67a00dfe26":[1,1,0,44],96"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bead90684782d20bd184adebce214da0fb7":[1,1,0,74],97"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84bead90d6c9f7c3e751fd1cab1b92187bfb0":[1,1,0,95],98"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beadd3af74a2c6d9ea8a5411dfdb51e93a4":[1,1,0,99],99"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beae2dbe959ff5bc2dcd3dc71a92d5c053c":[1,1,0,93],100"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beae4a762e079462ab42723d0052ad9c5b4":[1,1,0,73],101"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beae8b254db5898fe8f36f6f650d81cb0d1":[1,1,0,79],102"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beae96a7db722c3fbaececd2c8d9a45b19c":[1,1,0,84],103"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beae99971090e79d0b006294059e32301b0":[1,1,0,67],104"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaeb41c59cd96e6d16e343046893ff7442":[1,1,0,32],105"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaec48bc94e3f15bdf3f9eda6d76fbd7ab":[1,1,0,21],106"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaf1a7e2d71a17c147d1ef007986a29cfb":[1,1,0,54],107"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaf38eaf459a6e12d9579a52ea433d2b3b":[1,1,0,15],108"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaf8a05f41e01df87665ca9237aa9f416e":[1,1,0,75],109"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaf8f88476f893e2e7445714372c99b6f3":[1,1,0,10],110"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beafab5347f328ae50a3b524cad27b2be8d":[1,1,0,35],111"group__pmtk__command.html#gga6012e5fa857099f0e5fd61bb6d1f84beaff110d710ff9d5961dd33c7291e5824d":[1,1,0,38],112"index.html":[0],113"index.html":[],114"index.html#COMMAND_Chapter":[0,1],115"index.html#COMMAND_List_Chapter":[0,2],116"index.html#PMTK_Overview":[0,0],117"index.html#Version_Chapter":[0,3],118"index.html#license":[0,4],119"modules.html":[1],120"pages.html":[] ...

Full Screen

Full Screen

fckcommands.js

Source:fckcommands.js Github

copy

Full Screen

1/*2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net3 * Copyright (C) 2003-2009 Frederico Caldeira Knabben4 *5 * == BEGIN LICENSE ==6 *7 * Licensed under the terms of any of the following licenses at your8 * choice:9 *10 * - GNU General Public License Version 2 or later (the "GPL")11 * http://www.gnu.org/licenses/gpl.html12 *13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")14 * http://www.gnu.org/licenses/lgpl.html15 *16 * - Mozilla Public License Version 1.1 or later (the "MPL")17 * http://www.mozilla.org/MPL/MPL-1.1.html18 *19 * == END LICENSE ==20 *21 * Define all commands available in the editor.22 */2324var FCKCommands = FCK.Commands = new Object() ;25FCKCommands.LoadedCommands = new Object() ;2627FCKCommands.RegisterCommand = function( commandName, command )28{29 this.LoadedCommands[ commandName ] = command ;30}3132FCKCommands.GetCommand = function( commandName )33{34 var oCommand = FCKCommands.LoadedCommands[ commandName ] ;3536 if ( oCommand )37 return oCommand ;3839 switch ( commandName )40 {41 case 'Bold' :42 case 'Italic' :43 case 'Underline' :44 case 'StrikeThrough':45 case 'Subscript' :46 case 'Superscript' : oCommand = new FCKCoreStyleCommand( commandName ) ; break ;4748 case 'RemoveFormat' : oCommand = new FCKRemoveFormatCommand() ; break ;4950 case 'DocProps' : oCommand = new FCKDialogCommand( 'DocProps' , FCKLang.DocProps , 'dialog/fck_docprops.html' , 400, 380, FCKCommands.GetFullPageState ) ; break ;51 case 'Templates' : oCommand = new FCKDialogCommand( 'Templates' , FCKLang.DlgTemplatesTitle , 'dialog/fck_template.html' , 380, 450 ) ; break ;52 case 'Link' : oCommand = new FCKDialogCommand( 'Link' , FCKLang.DlgLnkWindowTitle , 'dialog/fck_link.html' , 400, 300 ) ; break ;53 case 'Unlink' : oCommand = new FCKUnlinkCommand() ; break ;54 case 'VisitLink' : oCommand = new FCKVisitLinkCommand() ; break ;55 case 'Anchor' : oCommand = new FCKDialogCommand( 'Anchor' , FCKLang.DlgAnchorTitle , 'dialog/fck_anchor.html' , 370, 160 ) ; break ;56 case 'AnchorDelete' : oCommand = new FCKAnchorDeleteCommand() ; break ;57 case 'BulletedList' : oCommand = new FCKDialogCommand( 'BulletedList', FCKLang.BulletedListProp , 'dialog/fck_listprop.html?UL' , 370, 160 ) ; break ;58 case 'NumberedList' : oCommand = new FCKDialogCommand( 'NumberedList', FCKLang.NumberedListProp , 'dialog/fck_listprop.html?OL' , 370, 160 ) ; break ;59 case 'About' : oCommand = new FCKDialogCommand( 'About' , FCKLang.About , 'dialog/fck_about.html' , 420, 330, function(){ return FCK_TRISTATE_OFF ; } ) ; break ;60 case 'Find' : oCommand = new FCKDialogCommand( 'Find' , FCKLang.DlgFindAndReplaceTitle, 'dialog/fck_replace.html' , 340, 230, null, null, 'Find' ) ; break ;61 case 'Replace' : oCommand = new FCKDialogCommand( 'Replace' , FCKLang.DlgFindAndReplaceTitle, 'dialog/fck_replace.html' , 340, 230, null, null, 'Replace' ) ; break ;6263 case 'Image' : oCommand = new FCKDialogCommand( 'Image' , FCKLang.DlgImgTitle , 'dialog/fck_image.html' , 450, 390 ) ; break ;64 case 'Flash' : oCommand = new FCKDialogCommand( 'Flash' , FCKLang.DlgFlashTitle , 'dialog/fck_flash.html' , 450, 390 ) ; break ;65 case 'SpecialChar' : oCommand = new FCKDialogCommand( 'SpecialChar', FCKLang.DlgSpecialCharTitle , 'dialog/fck_specialchar.html' , 400, 290 ) ; break ;66 case 'Smiley' : oCommand = new FCKDialogCommand( 'Smiley' , FCKLang.DlgSmileyTitle , 'dialog/fck_smiley.html' , FCKConfig.SmileyWindowWidth, FCKConfig.SmileyWindowHeight ) ; break ;67 case 'Table' : oCommand = new FCKDialogCommand( 'Table' , FCKLang.DlgTableTitle , 'dialog/fck_table.html' , 480, 250 ) ; break ;68 case 'TableProp' : oCommand = new FCKDialogCommand( 'Table' , FCKLang.DlgTableTitle , 'dialog/fck_table.html?Parent', 480, 250 ) ; break ;69 case 'TableCellProp': oCommand = new FCKDialogCommand( 'TableCell' , FCKLang.DlgCellTitle , 'dialog/fck_tablecell.html' , 550, 240 ) ; break ;7071 case 'Style' : oCommand = new FCKStyleCommand() ; break ;7273 case 'FontName' : oCommand = new FCKFontNameCommand() ; break ;74 case 'FontSize' : oCommand = new FCKFontSizeCommand() ; break ;75 case 'FontFormat' : oCommand = new FCKFormatBlockCommand() ; break ;7677 case 'Source' : oCommand = new FCKSourceCommand() ; break ;78 case 'Preview' : oCommand = new FCKPreviewCommand() ; break ;79 case 'Save' : oCommand = new FCKSaveCommand() ; break ;80 case 'NewPage' : oCommand = new FCKNewPageCommand() ; break ;81 case 'PageBreak' : oCommand = new FCKPageBreakCommand() ; break ;82 case 'Rule' : oCommand = new FCKRuleCommand() ; break ;83 case 'Nbsp' : oCommand = new FCKNbsp() ; break ;8485 case 'TextColor' : oCommand = new FCKTextColorCommand('ForeColor') ; break ;86 case 'BGColor' : oCommand = new FCKTextColorCommand('BackColor') ; break ;8788 case 'Paste' : oCommand = new FCKPasteCommand() ; break ;89 case 'PasteText' : oCommand = new FCKPastePlainTextCommand() ; break ;90 case 'PasteWord' : oCommand = new FCKPasteWordCommand() ; break ;9192 case 'JustifyLeft' : oCommand = new FCKJustifyCommand( 'left' ) ; break ;93 case 'JustifyCenter' : oCommand = new FCKJustifyCommand( 'center' ) ; break ;94 case 'JustifyRight' : oCommand = new FCKJustifyCommand( 'right' ) ; break ;95 case 'JustifyFull' : oCommand = new FCKJustifyCommand( 'justify' ) ; break ;96 case 'Indent' : oCommand = new FCKIndentCommand( 'indent', FCKConfig.IndentLength ) ; break ;97 case 'Outdent' : oCommand = new FCKIndentCommand( 'outdent', FCKConfig.IndentLength * -1 ) ; break ;98 case 'Blockquote' : oCommand = new FCKBlockQuoteCommand() ; break ;99 case 'CreateDiv' : oCommand = new FCKDialogCommand( 'CreateDiv', FCKLang.CreateDiv, 'dialog/fck_div.html', 380, 210, null, null, true ) ; break ;100 case 'EditDiv' : oCommand = new FCKDialogCommand( 'EditDiv', FCKLang.EditDiv, 'dialog/fck_div.html', 380, 210, null, null, false ) ; break ;101 case 'DeleteDiv' : oCommand = new FCKDeleteDivCommand() ; break ;102103 case 'TableInsertRowAfter' : oCommand = new FCKTableCommand('TableInsertRowAfter') ; break ;104 case 'TableInsertRowBefore' : oCommand = new FCKTableCommand('TableInsertRowBefore') ; break ;105 case 'TableDeleteRows' : oCommand = new FCKTableCommand('TableDeleteRows') ; break ;106 case 'TableInsertColumnAfter' : oCommand = new FCKTableCommand('TableInsertColumnAfter') ; break ;107 case 'TableInsertColumnBefore' : oCommand = new FCKTableCommand('TableInsertColumnBefore') ; break ;108 case 'TableDeleteColumns' : oCommand = new FCKTableCommand('TableDeleteColumns') ; break ;109 case 'TableInsertCellAfter' : oCommand = new FCKTableCommand('TableInsertCellAfter') ; break ;110 case 'TableInsertCellBefore' : oCommand = new FCKTableCommand('TableInsertCellBefore') ; break ;111 case 'TableDeleteCells' : oCommand = new FCKTableCommand('TableDeleteCells') ; break ;112 case 'TableMergeCells' : oCommand = new FCKTableCommand('TableMergeCells') ; break ;113 case 'TableMergeRight' : oCommand = new FCKTableCommand('TableMergeRight') ; break ;114 case 'TableMergeDown' : oCommand = new FCKTableCommand('TableMergeDown') ; break ;115 case 'TableHorizontalSplitCell' : oCommand = new FCKTableCommand('TableHorizontalSplitCell') ; break ;116 case 'TableVerticalSplitCell' : oCommand = new FCKTableCommand('TableVerticalSplitCell') ; break ;117 case 'TableDelete' : oCommand = new FCKTableCommand('TableDelete') ; break ;118119 case 'Form' : oCommand = new FCKDialogCommand( 'Form' , FCKLang.Form , 'dialog/fck_form.html' , 380, 210 ) ; break ;120 case 'Checkbox' : oCommand = new FCKDialogCommand( 'Checkbox' , FCKLang.Checkbox , 'dialog/fck_checkbox.html' , 380, 200 ) ; break ;121 case 'Radio' : oCommand = new FCKDialogCommand( 'Radio' , FCKLang.RadioButton , 'dialog/fck_radiobutton.html' , 380, 200 ) ; break ;122 case 'TextField' : oCommand = new FCKDialogCommand( 'TextField' , FCKLang.TextField , 'dialog/fck_textfield.html' , 380, 210 ) ; break ;123 case 'Textarea' : oCommand = new FCKDialogCommand( 'Textarea' , FCKLang.Textarea , 'dialog/fck_textarea.html' , 380, 210 ) ; break ;124 case 'HiddenField' : oCommand = new FCKDialogCommand( 'HiddenField', FCKLang.HiddenField , 'dialog/fck_hiddenfield.html' , 380, 190 ) ; break ;125 case 'Button' : oCommand = new FCKDialogCommand( 'Button' , FCKLang.Button , 'dialog/fck_button.html' , 380, 210 ) ; break ;126 case 'Select' : oCommand = new FCKDialogCommand( 'Select' , FCKLang.SelectionField, 'dialog/fck_select.html' , 400, 340 ) ; break ;127 case 'ImageButton' : oCommand = new FCKDialogCommand( 'ImageButton', FCKLang.ImageButton , 'dialog/fck_image.html?ImageButton', 450, 390 ) ; break ;128129 case 'SpellCheck' : oCommand = new FCKSpellCheckCommand() ; break ;130 case 'FitWindow' : oCommand = new FCKFitWindow() ; break ;131132 case 'Undo' : oCommand = new FCKUndoCommand() ; break ;133 case 'Redo' : oCommand = new FCKRedoCommand() ; break ;134 case 'Copy' : oCommand = new FCKCutCopyCommand( false ) ; break ;135 case 'Cut' : oCommand = new FCKCutCopyCommand( true ) ; break ;136137 case 'SelectAll' : oCommand = new FCKSelectAllCommand() ; break ;138 case 'InsertOrderedList' : oCommand = new FCKListCommand( 'insertorderedlist', 'ol' ) ; break ;139 case 'InsertUnorderedList' : oCommand = new FCKListCommand( 'insertunorderedlist', 'ul' ) ; break ;140 case 'ShowBlocks' : oCommand = new FCKShowBlockCommand( 'ShowBlocks', FCKConfig.StartupShowBlocks ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ) ; break ;141142 // Generic Undefined command (usually used when a command is under development).143 case 'Undefined' : oCommand = new FCKUndefinedCommand() ; break ;144145 // By default we assume that it is a named command.146 default:147 if ( FCKRegexLib.NamedCommands.test( commandName ) )148 oCommand = new FCKNamedCommand( commandName ) ;149 else150 {151 alert( FCKLang.UnknownCommand.replace( /%1/g, commandName ) ) ;152 return null ;153 }154 }155156 FCKCommands.LoadedCommands[ commandName ] = oCommand ;157158 return oCommand ;159}160161// Gets the state of the "Document Properties" button. It must be enabled only162// when "Full Page" editing is available.163FCKCommands.GetFullPageState = function()164{165 return FCKConfig.FullPage ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ;166}167168169FCKCommands.GetBooleanState = function( isDisabled )170{171 return isDisabled ? FCK_TRISTATE_DISABLED : FCK_TRISTATE_OFF ; ...

Full Screen

Full Screen

commandbutton.js

Source:commandbutton.js Github

copy

Full Screen

1// Copyright (c) 2012 The Chromium Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4/**5 * @fileoverview This implements a common button control, bound to command.6 */7/**8 * Creates a new button element.9 * @param {Object=} opt_propertyBag Optional properties.10 * @constructor11 * @extends {HTMLDivElement}12 */13 var CommandButton = cr.ui.define('button');14/** @override */15CommandButton.prototype.__proto__ = HTMLButtonElement.prototype;16/**17 * Associated command.18 * @type {Command}19 * @private20 */21CommandButton.prototype.command_ = null;22/**23 * Initializes the menu item.24 */25CommandButton.prototype.decorate = function() {26 var commandId;27 if ((commandId = this.getAttribute('command')))28 this.setCommand(commandId);29 this.addEventListener('click', this.handleClick_.bind(this));30 this.addEventListener('keypress', this.handleKeyPress_.bind(this));31};32/**33 * Returns associated command.34 * @return {cr.ui.Command} associated command.35 */36CommandButton.prototype.getCommand = function() {37 return this.command_;38};39/**40 * Associates command with this button.41 * @param {string|cr.ui.Command} command Command id, or command object to42 * associate with this button.43 */44CommandButton.prototype.setCommand = function(command) {45 if (this.command_) {46 this.command_.removeEventListener('labelChange', this);47 this.command_.removeEventListener('disabledChange', this);48 this.command_.removeEventListener('hiddenChange', this);49 }50 if (typeof command == 'string' && command[0] == '#') {51 command = this.ownerDocument.getElementById(command.slice(1));52 cr.ui.decorate(command, cr.ui.Command);53 }54 this.command_ = command;55 if (command) {56 if (command.id)57 this.setAttribute('command', '#' + command.id);58 this.setLabel(command.label);59 this.disabled = command.disabled;60 this.hidden = command.hidden;61 this.command_.addEventListener('labelChange', this);62 this.command_.addEventListener('disabledChange', this);63 this.command_.addEventListener('hiddenChange', this);64 }65};66/**67 * Returns button label68 * @return {string} Button label.69 */70CommandButton.prototype.getLabel = function() {71 return this.textContent;72};73/**74 * Sets button label.75 * @param {string} label New button label.76 */77CommandButton.prototype.setLabel = function(label) {78 this.textContent = label;79};80/**81 * Handles click event and dispatches associated command.82 * @param {Event} e The mouseup event object.83 * @private84 */85CommandButton.prototype.handleClick_ = function(e) {86 if (!this.disabled && this.command_)87 this.command_.execute(this);88};89/**90 * Handles keypress event and dispatches associated command.91 * @param {Event} e The mouseup event object.92 * @private93 */94CommandButton.prototype.handleKeyPress_ = function(e) {95 if (!this.command_) return;96 switch (util.getKeyModifiers(e) + e.keyCode) {97 case '13': // Enter98 case '32': // Space99 this.command_.execute(this);100 break;101 }102};103/**104 * Handles changes to the associated command.105 * @param {Event} e The event object.106 */107CommandButton.prototype.handleEvent = function(e) {108 switch (e.type) {109 case 'disabledChange':110 this.disabled = this.command_.disabled;111 break;112 case 'hiddenChange':113 this.hidden = this.command_.hidden;114 break;115 case 'labelChange':116 this.setLabel(this.command_.label);117 break;118 }119};120/**121 * Whether the button is disabled or not.122 * @type {boolean}123 */124cr.defineProperty(CommandButton, 'disabled',125 cr.PropertyKind.BOOL_ATTR);126/**127 * Whether the button is hidden or not.128 * @type {boolean}129 */130cr.defineProperty(CommandButton, 'hidden',...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var j = require('java');2j.classpath.push('/Users/username/Downloads/appium-1.6.0-beta3.jar');3var AppiumDriver = j.import('io.appium.java_client.android.AndroidDriver');4var DesiredCapabilities = j.import('org.openqa.selenium.remote.DesiredCapabilities');5var URL = j.import('java.net.URL');6var capabilities = DesiredCapabilities.android();7capabilities.setCapability('platformName', 'Android');8capabilities.setCapability('platformVersion', '6.0');9capabilities.setCapability('deviceName', 'Android Emulator');10capabilities.setCapability('app', '/Users/username/Downloads/ApiDemos-debug.apk');

Full Screen

Using AI Code Generation

copy

Full Screen

1var j = require('java');2j.classpath.push('path_to_appium_base_driver.jar');3j.import('io.appium.java_client.android.AndroidDriver');4var driver = new j.AndroidDriver();5driver.command('startActivity', {appPackage: 'com.android.vending', appActivity: 'com.android.vending.AssetBrowserActivity'});6var j = require('java');7j.classpath.push('path_to_appium_base_driver.jar');8j.import('io.appium.java_client.android.AndroidDriver');9var driver = new j.AndroidDriver();10driver.callStaticMethod('startActivity', {appPackage: 'com.android.vending', appActivity: 'com.android.vending.AssetBrowserActivity'});11var j = require('java');12j.classpath.push('path_to_appium_base_driver.jar');13j.import('io.appium.java_client.android.AndroidDriver');14var driver = new j.AndroidDriver();15driver.callMethod('startActivity', {appPackage: 'com.android.vending', appActivity: 'com.android.vending.AssetBrowserActivity'});16var j = require('java');17j.classpath.push('path_to_appium_base_driver.jar');18j.import('io.appium.java_client.android.AndroidDriver');19var driver = new j.AndroidDriver();20driver.staticCallMethod('startActivity', {appPackage: 'com.android.vending', appActivity: 'com.android.vending.AssetBrowserActivity'});21var j = require('java');22j.classpath.push('path_to_appium_base_driver.jar');23j.import('io.appium.java_client.android.AndroidDriver');24var driver = new j.AndroidDriver();25driver.callStaticMethodSync('startActivity', {appPackage: 'com.android.vending', appActivity: 'com.android.vending.AssetBrowserActivity'});26var j = require('java');27j.classpath.push('path_to_appium_base_driver.jar');28j.import('io.appium.java_client.android.AndroidDriver');29var driver = new j.AndroidDriver();30driver.callMethodSync('startActivity', {appPackage: 'com.android.vending', appActivity: 'com.android.vending.AssetBrowserActivity'

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.startActivity("com.android.calculator2", "com.android.calculator2.Calculator");2driver.click("com.android.calculator2:id/digit_1");3var text = driver.getText("com.android.calculator2:id/digit_1");4var bounds = driver.getBounds("com.android.calculator2:id/digit_1");5var contentDescription = driver.getContentDescription("com.android.calculator2:id/digit_1");6var enabled = driver.isEnabled("com.android.calculator2:id/digit_1");7var focused = driver.isFocused("com.android.calculator2:id/digit_1");8var checked = driver.isChecked("com.android.calculator2:id/digit_1");9var selected = driver.isSelected("com.android.calculator2:id/digit_1");10var longClick = driver.isLongClick("com.android.calculator2:id/digit_1");11var password = driver.isPassword("com.android.calculator2:id/digit_1");

Full Screen

Using AI Code Generation

copy

Full Screen

1var j = require('wd-bridge')(driver);2j.command({3}, function(err, result) {4 console.log(result);5});6module.exports = function(args) {7 var cb = args[args.length - 1];8 cb(null, 'arg1: ' + args[0] + ', arg2: ' + args[1]);9};

Full Screen

Using AI Code Generation

copy

Full Screen

1var j = require('appium-base-driver').jwpSuccess;2j.command('/wd/hub/session/1234/element/0', 'POST', 'click');3var j = require('appium-base-driver').jwpSuccess;4j.command('/wd/hub/session/1234/element/0', 'POST', 'click');5var j = require('appium-base-driver').jwpSuccess;6j.command('/wd/hub/session/1234/element/0', 'POST', 'click');7var j = require('appium-base-driver').jwpSuccess;8j.command('/wd/hub/session/1234/element/0', 'POST', 'click');9var j = require('appium-base-driver').jwpSuccess;10j.command('/wd/hub/session/1234/element/0', 'POST', 'click');11var j = require('appium-base-driver').jwpSuccess;12j.command('/wd/hub/session/1234/element/0', 'POST', 'click');13var j = require('appium-base-driver').jwpSuccess;14j.command('/wd/hub/session/1234/element/0', 'POST', 'click');15var j = require('appium-base-driver').jwpSuccess;16j.command('/wd/hub/session/1234/element/0', 'POST', 'click');17var j = require('appium-base-driver').jwpSuccess;18j.command('/wd/hub/session/1234/element/0', 'POST', 'click');19var j = require('appium-base-driver').jwp

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Base Driver 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