Best JavaScript code snippet using wpt
bidi_test.js
Source:bidi_test.js
1// Copyright 2007 The Closure Library Authors. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS-IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14goog.provide('goog.i18n.bidiTest');15goog.setTestOnly('goog.i18n.bidiTest');16goog.require('goog.i18n.bidi');17goog.require('goog.i18n.bidi.Dir');18goog.require('goog.testing.jsunit');19var LRE = '\u202A';20var RLE = '\u202B';21var PDF = '\u202C';22var LRM = '\u200E';23var RLM = '\u200F';24function testToDir() {25 assertEquals(null, goog.i18n.bidi.toDir(null));26 assertEquals(null, goog.i18n.bidi.toDir(null, true));27 assertEquals(goog.i18n.bidi.Dir.NEUTRAL,28 goog.i18n.bidi.toDir(goog.i18n.bidi.Dir.NEUTRAL));29 assertEquals(null, goog.i18n.bidi.toDir(0, true));30 assertEquals(goog.i18n.bidi.Dir.LTR,31 goog.i18n.bidi.toDir(goog.i18n.bidi.Dir.LTR));32 assertEquals(goog.i18n.bidi.Dir.LTR,33 goog.i18n.bidi.toDir(goog.i18n.bidi.Dir.LTR, true));34 assertEquals(goog.i18n.bidi.Dir.LTR, goog.i18n.bidi.toDir(100));35 assertEquals(goog.i18n.bidi.Dir.LTR, goog.i18n.bidi.toDir(100, true));36 assertEquals(goog.i18n.bidi.Dir.LTR, goog.i18n.bidi.toDir(false));37 assertEquals(goog.i18n.bidi.Dir.LTR, goog.i18n.bidi.toDir(false, true));38 assertEquals(goog.i18n.bidi.Dir.RTL,39 goog.i18n.bidi.toDir(goog.i18n.bidi.Dir.RTL));40 assertEquals(goog.i18n.bidi.Dir.RTL,41 goog.i18n.bidi.toDir(goog.i18n.bidi.Dir.RTL, true));42 assertEquals(goog.i18n.bidi.Dir.RTL, goog.i18n.bidi.toDir(-100));43 assertEquals(goog.i18n.bidi.Dir.RTL, goog.i18n.bidi.toDir(-100, true));44 assertEquals(goog.i18n.bidi.Dir.RTL, goog.i18n.bidi.toDir(true));45 assertEquals(goog.i18n.bidi.Dir.RTL, goog.i18n.bidi.toDir(true, true));46}47function testIsRtlLang() {48 assert(!goog.i18n.bidi.isRtlLanguage('en'));49 assert(!goog.i18n.bidi.isRtlLanguage('fr'));50 assert(!goog.i18n.bidi.isRtlLanguage('zh-CN'));51 assert(!goog.i18n.bidi.isRtlLanguage('fil'));52 assert(!goog.i18n.bidi.isRtlLanguage('az'));53 assert(!goog.i18n.bidi.isRtlLanguage('iw-Latn'));54 assert(!goog.i18n.bidi.isRtlLanguage('iw-LATN'));55 assert(!goog.i18n.bidi.isRtlLanguage('iw_latn'));56 assert(goog.i18n.bidi.isRtlLanguage('ar'));57 assert(goog.i18n.bidi.isRtlLanguage('AR'));58 assert(goog.i18n.bidi.isRtlLanguage('iw'));59 assert(goog.i18n.bidi.isRtlLanguage('he'));60 assert(goog.i18n.bidi.isRtlLanguage('fa'));61 assert(goog.i18n.bidi.isRtlLanguage('ckb'));62 assert(goog.i18n.bidi.isRtlLanguage('ar-EG'));63 assert(goog.i18n.bidi.isRtlLanguage('az-Arab'));64 assert(goog.i18n.bidi.isRtlLanguage('az-ARAB-IR'));65 assert(goog.i18n.bidi.isRtlLanguage('az_arab_IR'));66}67function testIsLtrChar() {68 assert(goog.i18n.bidi.isLtrChar('a'));69 assert(!goog.i18n.bidi.isLtrChar('\u05e0'));70 var str = 'a\u05e0z';71 assert(goog.i18n.bidi.isLtrChar(str.charAt(0)));72 assert(!goog.i18n.bidi.isLtrChar(str.charAt(1)));73 assert(goog.i18n.bidi.isLtrChar(str.charAt(2)));74}75function testIsRtlChar() {76 assert(!goog.i18n.bidi.isRtlChar('a'));77 assert(goog.i18n.bidi.isRtlChar('\u05e0'));78 var str = 'a\u05e0z';79 assert(!goog.i18n.bidi.isRtlChar(str.charAt(0)));80 assert(goog.i18n.bidi.isRtlChar(str.charAt(1)));81 assert(!goog.i18n.bidi.isRtlChar(str.charAt(2)));82}83function testIsNeutralChar() {84 assert(goog.i18n.bidi.isNeutralChar('\u0000'));85 assert(goog.i18n.bidi.isNeutralChar('\u0020'));86 assert(!goog.i18n.bidi.isNeutralChar('a'));87 assert(goog.i18n.bidi.isNeutralChar('!'));88 assert(goog.i18n.bidi.isNeutralChar('@'));89 assert(goog.i18n.bidi.isNeutralChar('['));90 assert(goog.i18n.bidi.isNeutralChar('`'));91 assert(goog.i18n.bidi.isNeutralChar('0'));92 assert(!goog.i18n.bidi.isNeutralChar('\u05e0'));93}94function testIsNeutralText() {95 assert(goog.i18n.bidi.isNeutralText('123'));96 assert(!goog.i18n.bidi.isNeutralText('abc'));97 assert(goog.i18n.bidi.isNeutralText('http://abc'));98 assert(goog.i18n.bidi.isNeutralText(' 123-()'));99 assert(!goog.i18n.bidi.isNeutralText('123a456'));100 assert(!goog.i18n.bidi.isNeutralText('123\u05e0456'));101 assert(!goog.i18n.bidi.isNeutralText('<input value=\u05e0>123<', false));102 assert(goog.i18n.bidi.isNeutralText('<input value=\u05e0>123<', true));103}104function testHasAnyLtr() {105 assert(!goog.i18n.bidi.hasAnyLtr(''));106 assert(!goog.i18n.bidi.hasAnyLtr('\u05e0\u05e1\u05e2'));107 assert(goog.i18n.bidi.hasAnyLtr('\u05e0\u05e1z\u05e2'));108 assert(!goog.i18n.bidi.hasAnyLtr('123\t... \n'));109 assert(goog.i18n.bidi.hasAnyLtr('<br>123<', false));110 assert(!goog.i18n.bidi.hasAnyLtr('<br>123<', true));111}112function testHasAnyRtl() {113 assert(!goog.i18n.bidi.hasAnyRtl(''));114 assert(!goog.i18n.bidi.hasAnyRtl('abc'));115 assert(goog.i18n.bidi.hasAnyRtl('ab\u05e0c'));116 assert(!goog.i18n.bidi.hasAnyRtl('123\t... \n'));117 assert(goog.i18n.bidi.hasAnyRtl('<input value=\u05e0>123', false));118 assert(!goog.i18n.bidi.hasAnyRtl('<input value=\u05e0>123', true));119}120function testEndsWithLtr() {121 assert(goog.i18n.bidi.endsWithLtr('a'));122 assert(goog.i18n.bidi.endsWithLtr('abc'));123 assert(goog.i18n.bidi.endsWithLtr('a (!)'));124 assert(goog.i18n.bidi.endsWithLtr('a.1'));125 assert(goog.i18n.bidi.endsWithLtr('http://www.google.com '));126 assert(goog.i18n.bidi.endsWithLtr('\u05e0a'));127 assert(goog.i18n.bidi.endsWithLtr(' \u05e0\u05e1a\u05e2\u05e3 a (!)'));128 assert(goog.i18n.bidi.endsWithLtr('\u202b\u05d0!\u202c\u200e'));129 assert(!goog.i18n.bidi.endsWithLtr(''));130 assert(!goog.i18n.bidi.endsWithLtr(' '));131 assert(!goog.i18n.bidi.endsWithLtr('1'));132 assert(!goog.i18n.bidi.endsWithLtr('\u05e0'));133 assert(!goog.i18n.bidi.endsWithLtr('\u05e0 1(!)'));134 assert(!goog.i18n.bidi.endsWithLtr('a\u05e0'));135 assert(!goog.i18n.bidi.endsWithLtr('a abc\u05e0\u05e1def\u05e2. 1'));136 assert(!goog.i18n.bidi.endsWithLtr('\u200f\u202eArtielish\u202c\u200f'));137 assert(!goog.i18n.bidi.endsWithLtr(' \u05e0\u05e1a\u05e2 <', true));138 assert(goog.i18n.bidi.endsWithLtr(' \u05e0\u05e1a\u05e2 <', false));139}140function testEndsWithRtl() {141 assert(goog.i18n.bidi.endsWithRtl('\u05e0'));142 assert(goog.i18n.bidi.endsWithRtl('\u05e0\u05e1\u05e2'));143 assert(goog.i18n.bidi.endsWithRtl('\u05e0 (!)'));144 assert(goog.i18n.bidi.endsWithRtl('\u05e0.1'));145 assert(goog.i18n.bidi.endsWithRtl('http://www.google.com/\u05e0 '));146 assert(goog.i18n.bidi.endsWithRtl('a\u05e0'));147 assert(goog.i18n.bidi.endsWithRtl(' a abc\u05e0def\u05e3. 1'));148 assert(goog.i18n.bidi.endsWithRtl('\u200f\u202eArtielish\u202c\u200f'));149 assert(!goog.i18n.bidi.endsWithRtl(''));150 assert(!goog.i18n.bidi.endsWithRtl(' '));151 assert(!goog.i18n.bidi.endsWithRtl('1'));152 assert(!goog.i18n.bidi.endsWithRtl('a'));153 assert(!goog.i18n.bidi.endsWithRtl('a 1(!)'));154 assert(!goog.i18n.bidi.endsWithRtl('\u05e0a'));155 assert(!goog.i18n.bidi.endsWithRtl('\u202b\u05d0!\u202c\u200e'));156 assert(!goog.i18n.bidi.endsWithRtl('\u05e0 \u05e0\u05e1ab\u05e2 a (!)'));157 assert(goog.i18n.bidi.endsWithRtl(' \u05e0\u05e1a\u05e2 <', true));158 assert(!goog.i18n.bidi.endsWithRtl(' \u05e0\u05e1a\u05e2 <', false));159}160function testGuardBracketInHtml() {161 var strWithRtl = 'asc \u05d0 (\u05d0\u05d0\u05d0)';162 assertEquals('asc \u05d0 <span dir=rtl>(\u05d0\u05d0\u05d0)</span>',163 goog.i18n.bidi.guardBracketInHtml(strWithRtl));164 assertEquals('asc \u05d0 <span dir=rtl>(\u05d0\u05d0\u05d0)</span>',165 goog.i18n.bidi.guardBracketInHtml(strWithRtl, true));166 assertEquals('asc \u05d0 <span dir=ltr>(\u05d0\u05d0\u05d0)</span>',167 goog.i18n.bidi.guardBracketInHtml(strWithRtl, false));168 var strWithRtl2 = '\u05d0 a (asc:))';169 assertEquals('\u05d0 a <span dir=rtl>(asc:))</span>',170 goog.i18n.bidi.guardBracketInHtml(strWithRtl2));171 assertEquals('\u05d0 a <span dir=rtl>(asc:))</span>',172 goog.i18n.bidi.guardBracketInHtml(strWithRtl2, true));173 assertEquals('\u05d0 a <span dir=ltr>(asc:))</span>',174 goog.i18n.bidi.guardBracketInHtml(strWithRtl2, false));175 var strWithoutRtl = 'a (asc) {{123}}';176 assertEquals('a <span dir=ltr>(asc)</span> <span dir=ltr>{{123}}</span>',177 goog.i18n.bidi.guardBracketInHtml(strWithoutRtl));178 assertEquals('a <span dir=rtl>(asc)</span> <span dir=rtl>{{123}}</span>',179 goog.i18n.bidi.guardBracketInHtml(strWithoutRtl, true));180 assertEquals('a <span dir=ltr>(asc)</span> <span dir=ltr>{{123}}</span>',181 goog.i18n.bidi.guardBracketInHtml(strWithoutRtl, false));182}183function testGuardBracketInText() {184 var strWithRtl = 'asc \u05d0 (\u05d0\u05d0\u05d0)';185 assertEquals('asc \u05d0 \u200f(\u05d0\u05d0\u05d0)\u200f',186 goog.i18n.bidi.guardBracketInText(strWithRtl));187 assertEquals('asc \u05d0 \u200f(\u05d0\u05d0\u05d0)\u200f',188 goog.i18n.bidi.guardBracketInText(strWithRtl, true));189 assertEquals('asc \u05d0 \u200e(\u05d0\u05d0\u05d0)\u200e',190 goog.i18n.bidi.guardBracketInText(strWithRtl, false));191 var strWithRtl2 = '\u05d0 a (asc:))';192 assertEquals('\u05d0 a \u200f(asc:))\u200f',193 goog.i18n.bidi.guardBracketInText(strWithRtl2));194 assertEquals('\u05d0 a \u200f(asc:))\u200f',195 goog.i18n.bidi.guardBracketInText(strWithRtl2, true));196 assertEquals('\u05d0 a \u200e(asc:))\u200e',197 goog.i18n.bidi.guardBracketInText(strWithRtl2, false));198 var strWithoutRtl = 'a (asc) {{123}}';199 assertEquals('a \u200e(asc)\u200e \u200e{{123}}\u200e',200 goog.i18n.bidi.guardBracketInText(strWithoutRtl));201 assertEquals('a \u200f(asc)\u200f \u200f{{123}}\u200f',202 goog.i18n.bidi.guardBracketInText(strWithoutRtl, true));203 assertEquals('a \u200e(asc)\u200e \u200e{{123}}\u200e',204 goog.i18n.bidi.guardBracketInText(strWithoutRtl, false));205}206function testEnforceRtlInHtml() {207 var str = '<div> first <br> second </div>';208 assertEquals('<div dir=rtl> first <br> second </div>',209 goog.i18n.bidi.enforceRtlInHtml(str));210 str = 'first second';211 assertEquals('\n<span dir=rtl>first second</span>',212 goog.i18n.bidi.enforceRtlInHtml(str));213}214function testEnforceRtlInText() {215 var str = 'first second';216 assertEquals(RLE + 'first second' + PDF,217 goog.i18n.bidi.enforceRtlInText(str));218}219function testEnforceLtrInHtml() {220 var str = '<div> first <br> second </div>';221 assertEquals('<div dir=ltr> first <br> second </div>',222 goog.i18n.bidi.enforceLtrInHtml(str));223 str = 'first second';224 assertEquals('\n<span dir=ltr>first second</span>',225 goog.i18n.bidi.enforceLtrInHtml(str));226}227function testEnforceLtrInText() {228 var str = 'first second';229 assertEquals(LRE + 'first second' + PDF,230 goog.i18n.bidi.enforceLtrInText(str));231}232function testNormalizeHebrewQuote() {233 assertEquals('\u05d0\u05f4', goog.i18n.bidi.normalizeHebrewQuote('\u05d0"'));234 assertEquals('\u05d0\u05f3', goog.i18n.bidi.normalizeHebrewQuote('\u05d0\''));235 assertEquals('\u05d0\u05f4\u05d0\u05f3',236 goog.i18n.bidi.normalizeHebrewQuote('\u05d0"\u05d0\''));237}238function testMirrorCSS() {239 var str = 'left:10px;right:20px';240 assertEquals('right:10px;left:20px',241 goog.i18n.bidi.mirrorCSS(str));242 str = 'border:10px 20px 30px 40px';243 assertEquals('border:10px 40px 30px 20px',244 goog.i18n.bidi.mirrorCSS(str));245}246function testEstimateDirection() {247 assertEquals(goog.i18n.bidi.Dir.NEUTRAL,248 goog.i18n.bidi.estimateDirection('', false));249 assertEquals(goog.i18n.bidi.Dir.NEUTRAL,250 goog.i18n.bidi.estimateDirection(' ', false));251 assertEquals(goog.i18n.bidi.Dir.NEUTRAL,252 goog.i18n.bidi.estimateDirection('! (...)', false));253 assertEquals(goog.i18n.bidi.Dir.LTR,254 goog.i18n.bidi.estimateDirection('All-Ascii content', false));255 assertEquals(goog.i18n.bidi.Dir.LTR,256 goog.i18n.bidi.estimateDirection('-17.0%', false));257 assertEquals(goog.i18n.bidi.Dir.LTR,258 goog.i18n.bidi.estimateDirection('http://foo/bar/', false));259 assertEquals(goog.i18n.bidi.Dir.LTR,260 goog.i18n.bidi.estimateDirection(261 'http://foo/bar/?s=\u05d0\u05d0\u05d0\u05d0\u05d0\u05d0' +262 '\u05d0\u05d0\u05d0\u05d0\u05d0\u05d0\u05d0\u05d0\u05d0' +263 '\u05d0\u05d0\u05d0\u05d0\u05d0\u05d0\u05d0\u05d0\u05d0',264 false));265 assertEquals(goog.i18n.bidi.Dir.RTL,266 goog.i18n.bidi.estimateDirection('\u05d0', false));267 assertEquals(goog.i18n.bidi.Dir.RTL,268 goog.i18n.bidi.estimateDirection(269 '9 \u05d0 -> 17.5, 23, 45, 19', false));270 assertEquals(goog.i18n.bidi.Dir.RTL,271 goog.i18n.bidi.estimateDirection(272 'http://foo/bar/ \u05d0 http://foo2/bar2/ ' +273 'http://foo3/bar3/', false));274 assertEquals(goog.i18n.bidi.Dir.RTL,275 goog.i18n.bidi.estimateDirection(276 '\u05d0\u05d9\u05df \u05de\u05de\u05e9 ' +277 '\u05de\u05d4 \u05dc\u05e8\u05d0\u05d5\u05ea: ' +278 '\u05dc\u05d0 \u05e6\u05d9\u05dc\u05de\u05ea\u05d9 ' +279 '\u05d4\u05e8\u05d1\u05d4 \u05d5\u05d2\u05dd \u05d0' +280 '\u05dd \u05d4\u05d9\u05d9\u05ea\u05d9 \u05de\u05e6' +281 '\u05dc\u05dd, \u05d4\u05d9\u05d4 \u05e9\u05dd', false));282 assertEquals(goog.i18n.bidi.Dir.RTL,283 goog.i18n.bidi.estimateDirection(284 '\u05db\u05d0 - http://geek.co.il/gallery/v/2007-06' +285 ' - \u05d0\u05d9\u05df \u05de\u05de\u05e9 \u05de\u05d4 ' +286 '\u05dc\u05e8\u05d0\u05d5\u05ea: \u05dc\u05d0 \u05e6' +287 '\u05d9\u05dc\u05de\u05ea\u05d9 \u05d4\u05e8\u05d1 ' +288 '\u05d5\u05d2\u05dd \u05d0\u05dd \u05d4\u05d9\u05d9' +289 '\u05d9 \u05de\u05e6\u05dc\u05dd, \u05d4\u05d9\u05d4 ' +290 '\u05e9\u05dd \u05d1\u05e2\u05d9\u05e7 \u05d4\u05e8' +291 '\u05d1\u05d4 \u05d0\u05e0\u05e9\u05d9\u05dd. \u05de' +292 '\u05d4 \u05e9\u05db\u05df - \u05d0\u05e4\u05e9\u05e8 ' +293 '\u05dc\u05e0\u05e6\u05dc \u05d0\u05ea \u05d4\u05d4 ' +294 '\u05d3\u05d6\u05de\u05e0\u05d5 \u05dc\u05d4\u05e1' +295 '\u05ea\u05db\u05dc \u05e2\u05dc \u05db\u05de\u05d4 ' +296 '\u05ea\u05de\u05d5\u05e0\u05d5\u05ea \u05de\u05e9' +297 '\u05e9\u05e2\u05d5\u05ea \u05d9\u05e9\u05e0\u05d5 ' +298 '\u05d9\u05d5\u05ea\u05e8 \u05e9\u05d9\u05e9 \u05dc' +299 '\u05d9 \u05d1\u05d0\u05ea\u05e8', false));300 assertEquals(goog.i18n.bidi.Dir.RTL,301 goog.i18n.bidi.estimateDirection(302 'CAPTCHA \u05de\u05e9\u05d5\u05db\u05dc\u05dc ' +303 '\u05de\u05d3\u05d9?', false));304 assertEquals(goog.i18n.bidi.Dir.RTL,305 goog.i18n.bidi.estimateDirection(306 'Yes Prime Minister \u05e2\u05d3\u05db\u05d5\u05df. ' +307 '\u05e9\u05d0\u05dc\u05d5 \u05d0\u05d5\u05ea\u05d9 ' +308 '\u05de\u05d4 \u05d0\u05e0\u05d9 \u05e8\u05d5\u05e6' +309 '\u05d4 \u05de\u05ea\u05e0\u05d4 \u05dc\u05d7\u05d2',310 false));311 assertEquals(goog.i18n.bidi.Dir.RTL,312 goog.i18n.bidi.estimateDirection(313 '17.4.02 \u05e9\u05e2\u05d4:13-20 .15-00 .\u05dc\u05d0 ' +314 '\u05d4\u05d9\u05d9\u05ea\u05d9 \u05db\u05d0\u05df.',315 false));316 assertEquals(goog.i18n.bidi.Dir.RTL,317 goog.i18n.bidi.estimateDirection(318 '5710 5720 5730. \u05d4\u05d3\u05dc\u05ea. ' +319 '\u05d4\u05e0\u05e9\u05d9\u05e7\u05d4', false));320 assertEquals(goog.i18n.bidi.Dir.RTL,321 goog.i18n.bidi.estimateDirection(322 '\u05d4\u05d3\u05dc\u05ea http://www.google.com ' +323 'http://www.gmail.com', false));324 assertEquals(goog.i18n.bidi.Dir.RTL,325 goog.i18n.bidi.estimateDirection(326 '\u200f\u202eArtielish\u202c\u200f'));327 assertEquals(goog.i18n.bidi.Dir.LTR,328 goog.i18n.bidi.estimateDirection(329 '\u05d4\u05d3\u05dc <some quite nasty html mark up>',330 false));331 assertEquals(goog.i18n.bidi.Dir.RTL,332 goog.i18n.bidi.estimateDirection(333 '\u05d4\u05d3\u05dc <some quite nasty html mark up>',334 true));335 assertEquals(goog.i18n.bidi.Dir.LTR,336 goog.i18n.bidi.estimateDirection(337 '\u05d4\u05d3\u05dc\u05ea & < >', false));338 assertEquals(goog.i18n.bidi.Dir.RTL,339 goog.i18n.bidi.estimateDirection(340 '\u05d4\u05d3\u05dc\u05ea & < >', true));341 assertEquals(goog.i18n.bidi.Dir.LTR,342 goog.i18n.bidi.estimateDirection(343 'foo/<b>\u05d0</b>', true));344}345var bidi_text = [];346function testDetectRtlDirectionality() {347 InitializeSamples();348 for (var i = 0; i < bidi_text.length; i++) {349 //alert(bidi_text[i].text);350 var is_rtl = goog.i18n.bidi.detectRtlDirectionality(bidi_text[i].text,351 bidi_text[i].isHtml);352 if (is_rtl != bidi_text[i].isRtl) {353 var str = '"' + bidi_text[i].text + '" should be ' +354 (bidi_text[i].isRtl ? 'rtl' : 'ltr') + ' but detected as ' +355 (is_rtl ? 'rtl' : 'ltr');356 alert(str);357 }358 assertEquals(bidi_text[i].isRtl, is_rtl);359 }360}361function SampleItem() {362 this.text = '';363 this.isRtl = false;364}365function InitializeSamples() {366 var item = new SampleItem;367 item.text = 'Pure Ascii content';368 item.isRtl = false;369 bidi_text.push(item);370 item = new SampleItem;371 item.text = '\u05d0\u05d9\u05df \u05de\u05de\u05e9 \u05de\u05d4 ' +372 '\u05dc\u05e8\u05d0\u05d5\u05ea: \u05dc\u05d0 ' +373 '\u05e6\u05d9\u05dc\u05de\u05ea\u05d9 \u05d4\u05e8\u05d1\u05d4 ' +374 '\u05d5\u05d2\u05dd \u05d0\u05dd \u05d4\u05d9\u05d9\u05ea\u05d9 ' +375 '\u05de\u05e6\u05dc\u05dd, \u05d4\u05d9\u05d4 \u05e9\u05dd';376 item.isRtl = true;377 bidi_text.push(item);378 item = new SampleItem;379 item.text = '\u05db\u05d0\u05df - http://geek.co.il/gallery/v/2007-06 - ' +380 '\u05d0\u05d9\u05df \u05de\u05de\u05e9 \u05de\u05d4 ' +381 '\u05dc\u05e8\u05d0\u05d5\u05ea: ' +382 '\u05dc\u05d0 \u05e6\u05d9\u05dc\u05de\u05ea\u05d9 ' +383 '\u05d4\u05e8\u05d1\u05d4 \u05d5\u05d2\u05dd \u05d0\u05dd ' +384 '\u05d4\u05d9\u05d9\u05ea\u05d9 \u05de\u05e6\u05dc\u05dd, ' +385 '\u05d4\u05d9\u05d4 \u05e9\u05dd \u05d1\u05e2\u05d9\u05e7\u05e8 ' +386 '\u05d4\u05e8\u05d1\u05d4 \u05d0\u05e0\u05e9\u05d9\u05dd. ' +387 '\u05de\u05d4 \u05e9\u05db\u05df - \u05d0\u05e4\u05e9\u05e8 ' +388 '\u05dc\u05e0\u05e6\u05dc \u05d0\u05ea ' +389 '\u05d4\u05d4\u05d3\u05d6\u05de\u05e0\u05d5\u05ea ' +390 '\u05dc\u05d4\u05e1\u05ea\u05db\u05dc \u05e2\u05dc \u05db\u05de\u05d4 ' +391 '\u05ea\u05de\u05d5\u05e0\u05d5\u05ea ' +392 '\u05de\u05e9\u05e2\u05e9\u05e2\u05d5\u05ea ' +393 '\u05d9\u05e9\u05e0\u05d5\u05ea \u05d9\u05d5\u05ea\u05e8 ' +394 '\u05e9\u05d9\u05e9 \u05dc\u05d9 \u05d1\u05d0\u05ea\u05e8';395 item.isRtl = true;396 bidi_text.push(item);397 item = new SampleItem;398 item.text =399 'CAPTCHA \u05de\u05e9\u05d5\u05db\u05dc\u05dc \u05de\u05d3\u05d9?';400 item.isRtl = true;401 bidi_text.push(item);402 item = new SampleItem;403 item.text = 'Yes Prime Minister \u05e2\u05d3\u05db\u05d5\u05df. ' +404 '\u05e9\u05d0\u05dc\u05d5 \u05d0\u05d5\u05ea\u05d9 \u05de\u05d4 ' +405 '\u05d0\u05e0\u05d9 \u05e8\u05d5\u05e6\u05d4 \u05de\u05ea\u05e0\u05d4 ' +406 '\u05dc\u05d7\u05d2';407 item.isRtl = true;408 bidi_text.push(item);409 item = new SampleItem;410 item.text = '17.4.02 \u05e9\u05e2\u05d4:13-20 .15-00 .\u05dc\u05d0 ' +411 '\u05d4\u05d9\u05d9\u05ea\u05d9 \u05db\u05d0\u05df.';412 item.isRtl = true;413 bidi_text.push(item);414 item = new SampleItem;415 item.text = '5710 5720 5730. \u05d4\u05d3\u05dc\u05ea. ' +416 '\u05d4\u05e0\u05e9\u05d9\u05e7\u05d4';417 item.isRtl = true;418 bidi_text.push(item);419 item = new SampleItem;420 item.text =421 '\u05d4\u05d3\u05dc\u05ea http://www.google.com http://www.gmail.com';422 item.isRtl = true;423 bidi_text.push(item);424 item = new SampleItem;425 item.text = '>\u05d4<';426 item.isHtml = true;427 item.isRtl = true;428 bidi_text.push(item);429 item = new SampleItem;430 item.text = '>\u05d4<';431 item.isHtml = false;432 item.isRtl = false;433 bidi_text.push(item);...
bidi.js
Source:bidi.js
1/*TRANSPILED*/goog.provide("goog.i18n.bidi");2goog.provide("goog.i18n.bidi.Dir");3goog.provide("goog.i18n.bidi.DirectionalString");4goog.provide("goog.i18n.bidi.Format");5goog.i18n.bidi.FORCE_RTL = goog.define("goog.i18n.bidi.FORCE_RTL", false);6goog.i18n.bidi.IS_RTL = goog.i18n.bidi.FORCE_RTL || (goog.LOCALE.substring(0, 2).toLowerCase() == "ar" || goog.LOCALE.substring(0, 2).toLowerCase() == "fa" || goog.LOCALE.substring(0, 2).toLowerCase() == "he" || goog.LOCALE.substring(0, 2).toLowerCase() == "iw" || goog.LOCALE.substring(0, 2).toLowerCase() == "ps" || goog.LOCALE.substring(0, 2).toLowerCase() == "sd" || goog.LOCALE.substring(0, 2).toLowerCase() == "ug" || goog.LOCALE.substring(0, 2).toLowerCase() == "ur" || goog.LOCALE.substring(0, 72).toLowerCase() == "yi") && (goog.LOCALE.length == 2 || goog.LOCALE.substring(2, 3) == "-" || goog.LOCALE.substring(2, 3) == "_") || goog.LOCALE.length >= 3 && goog.LOCALE.substring(0, 3).toLowerCase() == "ckb" && (goog.LOCALE.length == 3 || goog.LOCALE.substring(3, 4) == "-" || goog.LOCALE.substring(3, 4) == "_") || goog.LOCALE.length >= 7 && ((goog.LOCALE.substring(2, 3) == "-" || goog.LOCALE.substring(2, 3) == "_") && (goog.LOCALE.substring(3, 7).toLowerCase() == "adlm" || goog.LOCALE.substring(3, 87).toLowerCase() == "arab" || goog.LOCALE.substring(3, 7).toLowerCase() == "hebr" || goog.LOCALE.substring(3, 7).toLowerCase() == "nkoo" || goog.LOCALE.substring(3, 7).toLowerCase() == "rohg" || goog.LOCALE.substring(3, 7).toLowerCase() == "thaa")) || goog.LOCALE.length >= 8 && ((goog.LOCALE.substring(3, 4) == "-" || goog.LOCALE.substring(3, 4) == "_") && (goog.LOCALE.substring(4, 8).toLowerCase() == "adlm" || goog.LOCALE.substring(4, 8).toLowerCase() == "arab" || goog.LOCALE.substring(4, 8).toLowerCase() == 9"hebr" || goog.LOCALE.substring(4, 8).toLowerCase() == "nkoo" || goog.LOCALE.substring(4, 8).toLowerCase() == "rohg" || goog.LOCALE.substring(4, 8).toLowerCase() == "thaa"));10goog.i18n.bidi.Format = {LRE:"\u202a", RLE:"\u202b", PDF:"\u202c", LRM:"\u200e", RLM:"\u200f"};11goog.i18n.bidi.Dir = {LTR:1, RTL:-1, NEUTRAL:0};12goog.i18n.bidi.RIGHT = "right";13goog.i18n.bidi.LEFT = "left";14goog.i18n.bidi.I18N_RIGHT = goog.i18n.bidi.IS_RTL ? goog.i18n.bidi.LEFT : goog.i18n.bidi.RIGHT;15goog.i18n.bidi.I18N_LEFT = goog.i18n.bidi.IS_RTL ? goog.i18n.bidi.RIGHT : goog.i18n.bidi.LEFT;16goog.i18n.bidi.toDir = function(givenDir, opt_noNeutral) {17 if (typeof givenDir == "number") {18 return givenDir > 0 ? goog.i18n.bidi.Dir.LTR : givenDir < 0 ? goog.i18n.bidi.Dir.RTL : opt_noNeutral ? null : goog.i18n.bidi.Dir.NEUTRAL;19 } else {20 if (givenDir == null) {21 return null;22 } else {23 return givenDir ? goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.LTR;24 }25 }26};27goog.i18n.bidi.ltrChars_ = "A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0900-\u1fff" + "\u200e\u2c00-\ud801\ud804-\ud839\ud83c-\udbff" + "\uf900-\ufb1c\ufe00-\ufe6f\ufefd-\uffff";28goog.i18n.bidi.rtlChars_ = "\u0591-\u06ef\u06fa-\u08ff\u200f\ud802-\ud803\ud83a-\ud83b" + "\ufb1d-\ufdff\ufe70-\ufefc";29goog.i18n.bidi.htmlSkipReg_ = /<[^>]*>|&[^;]+;/g;30goog.i18n.bidi.stripHtmlIfNeeded_ = function(str, opt_isStripNeeded) {31 return opt_isStripNeeded ? str.replace(goog.i18n.bidi.htmlSkipReg_, "") : str;32};33goog.i18n.bidi.rtlCharReg_ = new RegExp("[" + goog.i18n.bidi.rtlChars_ + "]");34goog.i18n.bidi.ltrCharReg_ = new RegExp("[" + goog.i18n.bidi.ltrChars_ + "]");35goog.i18n.bidi.hasAnyRtl = function(str, opt_isHtml) {36 return goog.i18n.bidi.rtlCharReg_.test(goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml));37};38goog.i18n.bidi.hasRtlChar = goog.i18n.bidi.hasAnyRtl;39goog.i18n.bidi.hasAnyLtr = function(str, opt_isHtml) {40 return goog.i18n.bidi.ltrCharReg_.test(goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml));41};42goog.i18n.bidi.ltrRe_ = new RegExp("^[" + goog.i18n.bidi.ltrChars_ + "]");43goog.i18n.bidi.rtlRe_ = new RegExp("^[" + goog.i18n.bidi.rtlChars_ + "]");44goog.i18n.bidi.isRtlChar = function(str) {45 return goog.i18n.bidi.rtlRe_.test(str);46};47goog.i18n.bidi.isLtrChar = function(str) {48 return goog.i18n.bidi.ltrRe_.test(str);49};50goog.i18n.bidi.isNeutralChar = function(str) {51 return !goog.i18n.bidi.isLtrChar(str) && !goog.i18n.bidi.isRtlChar(str);52};53goog.i18n.bidi.ltrDirCheckRe_ = new RegExp("^[^" + goog.i18n.bidi.rtlChars_ + "]*[" + goog.i18n.bidi.ltrChars_ + "]");54goog.i18n.bidi.rtlDirCheckRe_ = new RegExp("^[^" + goog.i18n.bidi.ltrChars_ + "]*[" + goog.i18n.bidi.rtlChars_ + "]");55goog.i18n.bidi.startsWithRtl = function(str, opt_isHtml) {56 return goog.i18n.bidi.rtlDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml));57};58goog.i18n.bidi.isRtlText = goog.i18n.bidi.startsWithRtl;59goog.i18n.bidi.startsWithLtr = function(str, opt_isHtml) {60 return goog.i18n.bidi.ltrDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml));61};62goog.i18n.bidi.isLtrText = goog.i18n.bidi.startsWithLtr;63goog.i18n.bidi.isRequiredLtrRe_ = /^http:\/\/.*/;64goog.i18n.bidi.isNeutralText = function(str, opt_isHtml) {65 str = goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml);66 return goog.i18n.bidi.isRequiredLtrRe_.test(str) || !goog.i18n.bidi.hasAnyLtr(str) && !goog.i18n.bidi.hasAnyRtl(str);67};68goog.i18n.bidi.ltrExitDirCheckRe_ = new RegExp("[" + goog.i18n.bidi.ltrChars_ + "]" + "[^" + goog.i18n.bidi.rtlChars_ + "]*$");69goog.i18n.bidi.rtlExitDirCheckRe_ = new RegExp("[" + goog.i18n.bidi.rtlChars_ + "]" + "[^" + goog.i18n.bidi.ltrChars_ + "]*$");70goog.i18n.bidi.endsWithLtr = function(str, opt_isHtml) {71 return goog.i18n.bidi.ltrExitDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml));72};73goog.i18n.bidi.isLtrExitText = goog.i18n.bidi.endsWithLtr;74goog.i18n.bidi.endsWithRtl = function(str, opt_isHtml) {75 return goog.i18n.bidi.rtlExitDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml));76};77goog.i18n.bidi.isRtlExitText = goog.i18n.bidi.endsWithRtl;78goog.i18n.bidi.rtlLocalesRe_ = new RegExp("^(ar|ckb|dv|he|iw|fa|nqo|ps|sd|ug|ur|yi|" + ".*[-_](Adlm|Arab|Hebr|Nkoo|Rohg|Thaa))" + "(?!.*[-_](Latn|Cyrl)($|-|_))($|-|_)", "i");79goog.i18n.bidi.isRtlLanguage = function(lang) {80 return goog.i18n.bidi.rtlLocalesRe_.test(lang);81};82goog.i18n.bidi.bracketGuardTextRe_ = /(\(.*?\)+)|(\[.*?\]+)|(\{.*?\}+)|(<.*?>+)/g;83goog.i18n.bidi.guardBracketInText = function(s, opt_isRtlContext) {84 var useRtl = opt_isRtlContext === undefined ? goog.i18n.bidi.hasAnyRtl(s) : opt_isRtlContext;85 var mark = useRtl ? goog.i18n.bidi.Format.RLM : goog.i18n.bidi.Format.LRM;86 return s.replace(goog.i18n.bidi.bracketGuardTextRe_, mark + "$\x26" + mark);87};88goog.i18n.bidi.enforceRtlInHtml = function(html) {89 if (html.charAt(0) == "\x3c") {90 return html.replace(/<\w+/, "$\x26 dir\x3drtl");91 }92 return "\n\x3cspan dir\x3drtl\x3e" + html + "\x3c/span\x3e";93};94goog.i18n.bidi.enforceRtlInText = function(text) {95 return goog.i18n.bidi.Format.RLE + text + goog.i18n.bidi.Format.PDF;96};97goog.i18n.bidi.enforceLtrInHtml = function(html) {98 if (html.charAt(0) == "\x3c") {99 return html.replace(/<\w+/, "$\x26 dir\x3dltr");100 }101 return "\n\x3cspan dir\x3dltr\x3e" + html + "\x3c/span\x3e";102};103goog.i18n.bidi.enforceLtrInText = function(text) {104 return goog.i18n.bidi.Format.LRE + text + goog.i18n.bidi.Format.PDF;105};106goog.i18n.bidi.dimensionsRe_ = /:\s*([.\d][.\w]*)\s+([.\d][.\w]*)\s+([.\d][.\w]*)\s+([.\d][.\w]*)/g;107goog.i18n.bidi.leftRe_ = /left/gi;108goog.i18n.bidi.rightRe_ = /right/gi;109goog.i18n.bidi.tempRe_ = /%%%%/g;110goog.i18n.bidi.mirrorCSS = function(cssStr) {111 return cssStr.replace(goog.i18n.bidi.dimensionsRe_, ":$1 $4 $3 $2").replace(goog.i18n.bidi.leftRe_, "%%%%").replace(goog.i18n.bidi.rightRe_, goog.i18n.bidi.LEFT).replace(goog.i18n.bidi.tempRe_, goog.i18n.bidi.RIGHT);112};113goog.i18n.bidi.doubleQuoteSubstituteRe_ = /([\u0591-\u05f2])"/g;114goog.i18n.bidi.singleQuoteSubstituteRe_ = /([\u0591-\u05f2])'/g;115goog.i18n.bidi.normalizeHebrewQuote = function(str) {116 return str.replace(goog.i18n.bidi.doubleQuoteSubstituteRe_, "$1\u05f4").replace(goog.i18n.bidi.singleQuoteSubstituteRe_, "$1\u05f3");117};118goog.i18n.bidi.wordSeparatorRe_ = /\s+/;119goog.i18n.bidi.hasNumeralsRe_ = /[\d\u06f0-\u06f9]/;120goog.i18n.bidi.rtlDetectionThreshold_ = 0.40;121goog.i18n.bidi.estimateDirection = function(str, opt_isHtml) {122 var rtlCount = 0;123 var totalCount = 0;124 var hasWeaklyLtr = false;125 var tokens = goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml).split(goog.i18n.bidi.wordSeparatorRe_);126 for (var i = 0; i < tokens.length; i++) {127 var token = tokens[i];128 if (goog.i18n.bidi.startsWithRtl(token)) {129 rtlCount++;130 totalCount++;131 } else {132 if (goog.i18n.bidi.isRequiredLtrRe_.test(token)) {133 hasWeaklyLtr = true;134 } else {135 if (goog.i18n.bidi.hasAnyLtr(token)) {136 totalCount++;137 } else {138 if (goog.i18n.bidi.hasNumeralsRe_.test(token)) {139 hasWeaklyLtr = true;140 }141 }142 }143 }144 }145 return totalCount == 0 ? hasWeaklyLtr ? goog.i18n.bidi.Dir.LTR : goog.i18n.bidi.Dir.NEUTRAL : rtlCount / totalCount > goog.i18n.bidi.rtlDetectionThreshold_ ? goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.LTR;146};147goog.i18n.bidi.detectRtlDirectionality = function(str, opt_isHtml) {148 return goog.i18n.bidi.estimateDirection(str, opt_isHtml) == goog.i18n.bidi.Dir.RTL;149};150goog.i18n.bidi.setElementDirAndAlign = function(element, dir) {151 if (element) {152 var htmlElement = element;153 dir = goog.i18n.bidi.toDir(dir);154 if (dir) {155 htmlElement.style.textAlign = dir == goog.i18n.bidi.Dir.RTL ? goog.i18n.bidi.RIGHT : goog.i18n.bidi.LEFT;156 htmlElement.dir = dir == goog.i18n.bidi.Dir.RTL ? "rtl" : "ltr";157 }158 }159};160goog.i18n.bidi.setElementDirByTextDirectionality = function(element, text) {161 var htmlElement = element;162 switch(goog.i18n.bidi.estimateDirection(text)) {163 case goog.i18n.bidi.Dir.LTR:164 htmlElement.dir = "ltr";165 break;166 case goog.i18n.bidi.Dir.RTL:167 htmlElement.dir = "rtl";168 break;169 default:170 htmlElement.removeAttribute("dir");171 }172};173goog.i18n.bidi.DirectionalString = function() {174};175goog.i18n.bidi.DirectionalString.prototype.implementsGoogI18nBidiDirectionalString;...
bidiinput_test.js
Source:bidiinput_test.js
1// Copyright 2012 The Closure Library Authors. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS-IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14goog.provide('goog.ui.BidiInputTest');15goog.setTestOnly('goog.ui.BidiInputTest');16goog.require('goog.dom');17goog.require('goog.testing.jsunit');18goog.require('goog.ui.BidiInput');19function setUp() {20 document.body.focus();21}22function tearDown() {23 document.getElementById('emptyText').value = '';24 document.getElementById('bidiText').value = 'hello, world!';25}26function testEmptyInput() {27 var bidiInput = new goog.ui.BidiInput();28 var emptyText = goog.dom.getElement('emptyText');29 bidiInput.decorate(emptyText);30 assertEquals('', bidiInput.getValue());31 bidiInput.setValue('hello!');32 assertEquals('hello!', bidiInput.getValue());33}34function testSetDirection() {35 var shalomInHebrew = '\u05e9\u05dc\u05d5\u05dd';36 var isAGoodLanguageInHebrew =37 '\u05d4\u05d9\u05d0 \u05e9\u05e4\u05d4 \u05d8\u05d5\u05d1\u05d4';38 var learnInHebrew = '\u05dc\u05de\u05d3';39 var bidiInput = new goog.ui.BidiInput();40 var bidiText = goog.dom.getElement('bidiText');41 bidiInput.decorate(bidiText);42 assertEquals('ltr', bidiInput.getDirection());43 bidiInput.setValue(shalomInHebrew);44 assertEquals('rtl', bidiInput.getDirection());45 bidiInput.setValue('hello!');46 assertEquals('ltr', bidiInput.getDirection());47 bidiInput.setValue(':) , ? ! ' + shalomInHebrew);48 assertEquals('rtl', bidiInput.getDirection());49 bidiInput.setValue(':) , ? ! hello!');50 assertEquals('ltr', bidiInput.getDirection());51 bidiInput.setValue(' ;) ');52 assertEquals(null, bidiInput.getDirection());53 bidiInput.setValue(shalomInHebrew + ', how are you today?');54 assertEquals('ltr', bidiInput.getDirection());55 bidiInput.setValue('Hello is ' + shalomInHebrew + ' in Hebrew');56 assertEquals('ltr', bidiInput.getDirection());57 bidiInput.setValue('JavaScript ' + isAGoodLanguageInHebrew);58 assertEquals('rtl', bidiInput.getDirection());59 bidiInput.setValue(learnInHebrew + ' JavaScript');60 assertEquals('rtl', bidiInput.getDirection());61 bidiInput.setValue('');62 assertEquals(null, bidiInput.getDirection());63}64function testSetDirection_inContenteditableDiv() {65 var shalomInHebrew = '\u05e9\u05dc\u05d5\u05dd';66 var isAGoodLanguageInHebrew =67 '\u05d4\u05d9\u05d0 \u05e9\u05e4\u05d4 \u05d8\u05d5\u05d1\u05d4';68 var learnInHebrew = '\u05dc\u05de\u05d3';69 var bidiInput = new goog.ui.BidiInput();70 var bidiTextDiv = goog.dom.getElement('bidiTextDiv');71 bidiInput.decorate(bidiTextDiv);72 assertEquals('ltr', bidiInput.getDirection());73 bidiInput.setValue(shalomInHebrew);74 assertEquals('rtl', bidiInput.getDirection());75 bidiInput.setValue('hello!');76 assertEquals('ltr', bidiInput.getDirection());77 bidiInput.setValue(':) , ? ! ' + shalomInHebrew);78 assertEquals('rtl', bidiInput.getDirection());79 bidiInput.setValue(':) , ? ! hello!');80 assertEquals('ltr', bidiInput.getDirection());81 bidiInput.setValue(' ;) ');82 assertEquals(null, bidiInput.getDirection());83 bidiInput.setValue(shalomInHebrew + ', how are you today?');84 assertEquals('ltr', bidiInput.getDirection());85 bidiInput.setValue('Hello is ' + shalomInHebrew + ' in Hebrew');86 assertEquals('ltr', bidiInput.getDirection());87 bidiInput.setValue('JavaScript ' + isAGoodLanguageInHebrew);88 assertEquals('rtl', bidiInput.getDirection());89 bidiInput.setValue(learnInHebrew + ' JavaScript');90 assertEquals('rtl', bidiInput.getDirection());91 bidiInput.setValue('');92 assertEquals(null, bidiInput.getDirection());...
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Barack Obama');3page.get(function(err, resp) {4 console.log(resp.data.image);5});6var wptools = require('wptools');7var page = wptools.page('Barack Obama');8page.get(function(err, resp) {9 console.log(resp.data.image);10});11var wptools = require('wptools');12var page = wptools.page('Barack Obama', {13});
Using AI Code Generation
1var wptexturize = require('wptexturize');2var text = 'Hello, World!';3var texturized = wptexturize(text);4console.log(texturized);5var wptexturize = require('wptexturize');6#### wptexturize(text, [options])7MIT © [The WordPress Contributors](
Using AI Code Generation
1var wpt = require('./wpt-api.js');2var test = new wpt('API_KEY');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9For a more in-depth look at the API, check out the [documentation](
Using AI Code Generation
1var bidi = require('bidi');2var browser = 'chrome';3var test = 'bidi';4var viewportSize = '1024x768';5var logFile = 'log.txt';6var screenshotFile = 'screenshot.png';7bidi.runTest(url, browser, test, viewportSize, logFile, screenshotFile, function (err) {8 if (err) {9 console.log(err);10 }11 else {12 console.log('Test was successful');13 }14});15This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!