How to use emitError method in Playwright Internal

Best JavaScript code snippet using playwright-internal

parse.js

Source:parse.js Github

copy

Full Screen

...73 node = parseInterpolation(context, mode);74 }75 else if (mode === 0 && s[0] === '<') {76 if (s.length === 1) {77 emitError(context, 8, 1);78 }79 else if (s[1] === '!') {80 if (startsWith(s, '<!--')) {81 node = parseComment(context);82 }83 else if (startsWith(s, '<!DOCTYPE')) {84 node = parseBogusComment(context);85 }86 else if (startsWith(s, '<![CDATA[')) {87 if (ns !== 0) {88 node = parseCDATA(context, ancestors);89 }90 else {91 emitError(context, 2);92 node = parseBogusComment(context);93 }94 }95 else {96 emitError(context, 14);97 node = parseBogusComment(context);98 }99 }100 else if (s[1] === '/') {101 if (s.length === 2) {102 emitError(context, 8, 2);103 }104 else if (s[2] === '>') {105 emitError(context, 17, 2);106 advanceBy(context, 3);107 continue;108 }109 else if (/[a-z]/i.test(s[2])) {110 emitError(context, 31);111 parseTag(context, 1, parent);112 continue;113 }114 else {115 emitError(context, 15, 2);116 node = parseBogusComment(context);117 }118 }119 else if (/[a-z]/i.test(s[1])) {120 node = parseElement(context, ancestors);121 }122 else if (s[1] === '?') {123 emitError(context, 28, 1);124 node = parseBogusComment(context);125 }126 else {127 emitError(context, 15, 1);128 }129 }130 if (!node) {131 node = parseText(context, mode);132 }133 if (Array.isArray(node)) {134 for (var i = 0; i < node.length; i++) {135 pushNode(nodes, node[i]);136 }137 }138 else {139 pushNode(nodes, node);140 }141 }142 var removedWhitespace = false;143 if (!parent || !context.options.isPreTag(parent.tag)) {144 for (var i = 0; i < nodes.length; i++) {145 var node = nodes[i];146 if (node.type === 2) {147 if (!node.content.trim()) {148 var prev = nodes[i - 1];149 var next = nodes[i + 1];150 if (!prev ||151 !next ||152 prev.type === 3 ||153 next.type === 3 ||154 (prev.type === 1 &&155 next.type === 1 &&156 /[\r\n]/.test(node.content))) {157 removedWhitespace = true;158 nodes[i] = null;159 }160 else {161 node.content = ' ';162 }163 }164 else {165 node.content = node.content.replace(/\s+/g, ' ');166 }167 }168 }169 }170 return removedWhitespace ? nodes.filter(function (node) { return node !== null; }) : nodes;171}172function pushNode(nodes, node) {173 if (!true && node.type === 3) {174 return;175 }176 if (node.type === 2) {177 var prev = last(nodes);178 if (prev &&179 prev.type === 2 &&180 prev.loc.end.offset === node.loc.start.offset) {181 prev.content += node.content;182 prev.loc.end = node.loc.end;183 prev.loc.source += node.loc.source;184 return;185 }186 }187 nodes.push(node);188}189function parseCDATA(context, ancestors) {190 true &&191 utils_1.assert(last(ancestors) == null || last(ancestors).ns !== 0);192 true && utils_1.assert(startsWith(context.source, '<![CDATA['));193 advanceBy(context, 9);194 var nodes = parseChildren(context, 3, ancestors);195 if (context.source.length === 0) {196 emitError(context, 9);197 }198 else {199 true && utils_1.assert(startsWith(context.source, ']]>'));200 advanceBy(context, 3);201 }202 return nodes;203}204function parseComment(context) {205 true && utils_1.assert(startsWith(context.source, '<!--'));206 var start = getCursor(context);207 var content;208 var match = /--(\!)?>/.exec(context.source);209 if (!match) {210 content = context.source.slice(4);211 advanceBy(context, context.source.length);212 emitError(context, 10);213 }214 else {215 if (match.index <= 3) {216 emitError(context, 0);217 }218 if (match[1]) {219 emitError(context, 13);220 }221 content = context.source.slice(4, match.index);222 var s = context.source.slice(0, match.index);223 var prevIndex = 1, nestedIndex = 0;224 while ((nestedIndex = s.indexOf('<!--', prevIndex)) !== -1) {225 advanceBy(context, nestedIndex - prevIndex + 1);226 if (nestedIndex + 4 < s.length) {227 emitError(context, 20);228 }229 prevIndex = nestedIndex + 1;230 }231 advanceBy(context, match.index + match[0].length - prevIndex + 1);232 }233 return {234 type: 3,235 content: content,236 loc: getSelection(context, start)237 };238}239function parseBogusComment(context) {240 true && utils_1.assert(/^<(?:[\!\?]|\/[^a-z>])/i.test(context.source));241 var start = getCursor(context);242 var contentStart = context.source[1] === '?' ? 1 : 2;243 var content;244 var closeIndex = context.source.indexOf('>');245 if (closeIndex === -1) {246 content = context.source.slice(contentStart);247 advanceBy(context, context.source.length);248 }249 else {250 content = context.source.slice(contentStart, closeIndex);251 advanceBy(context, closeIndex + 1);252 }253 return {254 type: 3,255 content: content,256 loc: getSelection(context, start)257 };258}259function parseElement(context, ancestors) {260 true && utils_1.assert(/^<[a-z]/i.test(context.source));261 var wasInPre = context.inPre;262 var parent = last(ancestors);263 var element = parseTag(context, 0, parent);264 var isPreBoundary = context.inPre && !wasInPre;265 if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {266 return element;267 }268 ancestors.push(element);269 var mode = context.options.getTextMode(element.tag, element.ns);270 var children = parseChildren(context, mode, ancestors);271 ancestors.pop();272 element.children = children;273 if (startsWithEndTagOpen(context.source, element.tag)) {274 parseTag(context, 1, parent);275 }276 else {277 emitError(context, 32);278 if (context.source.length === 0 && element.tag.toLowerCase() === 'script') {279 var first = children[0];280 if (first && startsWith(first.loc.source, '<!--')) {281 emitError(context, 11);282 }283 }284 }285 element.loc = getSelection(context, element.loc.start);286 if (isPreBoundary) {287 context.inPre = false;288 }289 return element;290}291function parseTag(context, type, parent) {292 true && utils_1.assert(/^<\/?[a-z]/i.test(context.source));293 true &&294 utils_1.assert(type === (startsWith(context.source, '</') ? 1 : 0));295 var start = getCursor(context);296 var match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);297 var tag = match[1];298 var ns = context.options.getNamespace(tag, parent);299 advanceBy(context, match[0].length);300 advanceSpaces(context);301 var cursor = getCursor(context);302 var currentSource = context.source;303 var props = parseAttributes(context, type);304 if (!context.inPre &&305 props.some(function (p) { return p.type === 7 && p.name === 'pre'; })) {306 context.inPre = true;307 shared_2.extend(context, cursor);308 context.source = currentSource;309 props = parseAttributes(context, type).filter(function (p) { return p.name !== 'v-pre'; });310 }311 var isSelfClosing = false;312 if (context.source.length === 0) {313 emitError(context, 12);314 }315 else {316 isSelfClosing = startsWith(context.source, '/>');317 if (type === 1 && isSelfClosing) {318 emitError(context, 7);319 }320 advanceBy(context, isSelfClosing ? 2 : 1);321 }322 var tagType = 0;323 if (!context.inPre && !context.options.isCustomElement(tag)) {324 if (context.options.isNativeTag) {325 if (!context.options.isNativeTag(tag))326 tagType = 1;327 }328 else {329 if (/^[A-Z]/.test(tag))330 tagType = 1;331 }332 if (tag === 'slot')333 tagType = 2;334 else if (tag === 'template')335 tagType = 3;336 else if (tag === 'portal' || tag === 'Portal')337 tagType = 4;338 else if (tag === 'suspense' || tag === 'Suspense')339 tagType = 5;340 }341 return {342 type: 1,343 ns: ns,344 tag: tag,345 tagType: tagType,346 props: props,347 isSelfClosing: isSelfClosing,348 children: [],349 loc: getSelection(context, start),350 codegenNode: undefined351 };352}353function parseAttributes(context, type) {354 var props = [];355 var attributeNames = new Set();356 while (context.source.length > 0 &&357 !startsWith(context.source, '>') &&358 !startsWith(context.source, '/>')) {359 if (startsWith(context.source, '/')) {360 emitError(context, 29);361 advanceBy(context, 1);362 advanceSpaces(context);363 continue;364 }365 if (type === 1) {366 emitError(context, 6);367 }368 var attr = parseAttribute(context, attributeNames);369 if (type === 0) {370 props.push(attr);371 }372 if (/^[^\t\r\n\f />]/.test(context.source)) {373 emitError(context, 19);374 }375 advanceSpaces(context);376 }377 return props;378}379function parseAttribute(context, nameSet) {380 true && utils_1.assert(/^[^\t\r\n\f />]/.test(context.source));381 var start = getCursor(context);382 var match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);383 var name = match[0];384 if (nameSet.has(name)) {385 emitError(context, 5);386 }387 nameSet.add(name);388 if (name[0] === '=') {389 emitError(context, 26);390 }391 {392 var pattern = /["'<]/g;393 var m = void 0;394 while ((m = pattern.exec(name)) !== null) {395 emitError(context, 24, m.index);396 }397 }398 advanceBy(context, name.length);399 var value = undefined;400 if (/^[\t\r\n\f ]*=/.test(context.source)) {401 advanceSpaces(context);402 advanceBy(context, 1);403 advanceSpaces(context);404 value = parseAttributeValue(context);405 if (!value) {406 emitError(context, 16);407 }408 }409 var loc = getSelection(context, start);410 if (!context.inPre && /^(v-|:|@|#)/.test(name)) {411 var match_1 = /(?:^v-([a-z0-9-]+))?(?:(?::|^@|^#)([^\.]+))?(.+)?$/i.exec(name);412 var arg = void 0;413 if (match_1[2]) {414 var startOffset = name.split(match_1[2], 2).shift().length;415 var loc_1 = getSelection(context, getNewPosition(context, start, startOffset), getNewPosition(context, start, startOffset + match_1[2].length));416 var content = match_1[2];417 var isStatic = true;418 if (content.startsWith('[')) {419 isStatic = false;420 if (!content.endsWith(']')) {421 emitError(context, 34);422 }423 content = content.substr(1, content.length - 2);424 }425 arg = {426 type: 4,427 content: content,428 isStatic: isStatic,429 isConstant: isStatic,430 loc: loc_1431 };432 }433 if (value && value.isQuoted) {434 var valueLoc = value.loc;435 valueLoc.start.offset++;436 valueLoc.start.column++;437 valueLoc.end = utils_1.advancePositionWithClone(valueLoc.start, value.content);438 valueLoc.source = valueLoc.source.slice(1, -1);439 }440 return {441 type: 7,442 name: match_1[1] ||443 (startsWith(name, ':')444 ? 'bind'445 : startsWith(name, '@')446 ? 'on'447 : 'slot'),448 exp: value && {449 type: 4,450 content: value.content,451 isStatic: false,452 isConstant: false,453 loc: value.loc454 },455 arg: arg,456 modifiers: match_1[3] ? match_1[3].substr(1).split('.') : [],457 loc: loc458 };459 }460 return {461 type: 6,462 name: name,463 value: value && {464 type: 2,465 content: value.content,466 loc: value.loc467 },468 loc: loc469 };470}471function parseAttributeValue(context) {472 var start = getCursor(context);473 var content;474 var quote = context.source[0];475 var isQuoted = quote === "\"" || quote === "'";476 if (isQuoted) {477 advanceBy(context, 1);478 var endIndex = context.source.indexOf(quote);479 if (endIndex === -1) {480 content = parseTextData(context, context.source.length, 4);481 }482 else {483 content = parseTextData(context, endIndex, 4);484 advanceBy(context, 1);485 }486 }487 else {488 var match = /^[^\t\r\n\f >]+/.exec(context.source);489 if (!match) {490 return undefined;491 }492 var unexpectedChars = /["'<=`]/g;493 var m = void 0;494 while ((m = unexpectedChars.exec(match[0])) !== null) {495 emitError(context, 25, m.index);496 }497 content = parseTextData(context, match[0].length, 4);498 }499 return { content: content, isQuoted: isQuoted, loc: getSelection(context, start) };500}501function parseInterpolation(context, mode) {502 var _a = context.options.delimiters, open = _a[0], close = _a[1];503 true && utils_1.assert(startsWith(context.source, open));504 var closeIndex = context.source.indexOf(close, open.length);505 if (closeIndex === -1) {506 emitError(context, 33);507 return undefined;508 }509 var start = getCursor(context);510 advanceBy(context, open.length);511 var innerStart = getCursor(context);512 var innerEnd = getCursor(context);513 var rawContentLength = closeIndex - open.length;514 var rawContent = context.source.slice(0, rawContentLength);515 var preTrimContent = parseTextData(context, rawContentLength, mode);516 var content = preTrimContent.trim();517 var startOffset = preTrimContent.indexOf(content);518 if (startOffset > 0) {519 utils_1.advancePositionWithMutation(innerStart, rawContent, startOffset);520 }521 var endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);522 utils_1.advancePositionWithMutation(innerEnd, rawContent, endOffset);523 advanceBy(context, close.length);524 return {525 type: 5,526 content: {527 type: 4,528 isStatic: false,529 isConstant: false,530 content: content,531 loc: getSelection(context, innerStart, innerEnd)532 },533 loc: getSelection(context, start)534 };535}536function parseText(context, mode) {537 true && utils_1.assert(context.source.length > 0);538 var open = context.options.delimiters[0];539 var endIndex = Math.min.apply(Math, [540 context.source.indexOf('<', 1),541 context.source.indexOf(open, 1),542 mode === 3 ? context.source.indexOf(']]>') : -1,543 context.source.length544 ].filter(function (n) { return n !== -1; }));545 true && utils_1.assert(endIndex > 0);546 var start = getCursor(context);547 var content = parseTextData(context, endIndex, mode);548 return {549 type: 2,550 content: content,551 loc: getSelection(context, start)552 };553}554function parseTextData(context, length, mode) {555 if (mode === 2 || mode === 3) {556 var text_1 = context.source.slice(0, length);557 advanceBy(context, length);558 return text_1;559 }560 var end = context.offset + length;561 var text = '';562 while (context.offset < end) {563 var head = /&(?:#x?)?/i.exec(context.source);564 if (!head || context.offset + head.index >= end) {565 var remaining = end - context.offset;566 text += context.source.slice(0, remaining);567 advanceBy(context, remaining);568 break;569 }570 text += context.source.slice(0, head.index);571 advanceBy(context, head.index);572 if (head[0] === '&') {573 var name_1 = '', value = undefined;574 if (/[0-9a-z]/i.test(context.source[1])) {575 for (var length_1 = context.maxCRNameLength; !value && length_1 > 0; --length_1) {576 name_1 = context.source.substr(1, length_1);577 value = context.options.namedCharacterReferences[name_1];578 }579 if (value) {580 var semi = name_1.endsWith(';');581 if (mode === 4 &&582 !semi &&583 /[=a-z0-9]/i.test(context.source[1 + name_1.length] || '')) {584 text += '&';585 text += name_1;586 advanceBy(context, 1 + name_1.length);587 }588 else {589 text += value;590 advanceBy(context, 1 + name_1.length);591 if (!semi) {592 emitError(context, 18);593 }594 }595 }596 else {597 emitError(context, 30);598 text += '&';599 text += name_1;600 advanceBy(context, 1 + name_1.length);601 }602 }603 else {604 text += '&';605 advanceBy(context, 1);606 }607 }608 else {609 var hex = head[0] === '&#x';610 var pattern = hex ? /^&#x([0-9a-f]+);?/i : /^&#([0-9]+);?/;611 var body = pattern.exec(context.source);612 if (!body) {613 text += head[0];614 emitError(context, 1);615 advanceBy(context, head[0].length);616 }617 else {618 var cp = Number.parseInt(body[1], hex ? 16 : 10);619 if (cp === 0) {620 emitError(context, 22);621 cp = 0xfffd;622 }623 else if (cp > 0x10ffff) {624 emitError(context, 3);625 cp = 0xfffd;626 }627 else if (cp >= 0xd800 && cp <= 0xdfff) {628 emitError(context, 23);629 cp = 0xfffd;630 }631 else if ((cp >= 0xfdd0 && cp <= 0xfdef) || (cp & 0xfffe) === 0xfffe) {632 emitError(context, 21);633 }634 else if ((cp >= 0x01 && cp <= 0x08) ||635 cp === 0x0b ||636 (cp >= 0x0d && cp <= 0x1f) ||637 (cp >= 0x7f && cp <= 0x9f)) {638 emitError(context, 4);639 cp = CCR_REPLACEMENTS[cp] || cp;640 }641 text += String.fromCodePoint(cp);642 advanceBy(context, body[0].length);643 if (!body[0].endsWith(';')) {644 emitError(context, 18);645 }646 }647 }648 }649 return text;650}651function getCursor(context) {652 var column = context.column, line = context.line, offset = context.offset;653 return { column: column, line: line, offset: offset };654}655function getSelection(context, start, end) {656 end = end || getCursor(context);657 return {658 start: start,659 end: end,660 source: context.originalSource.slice(start.offset, end.offset)661 };662}663function last(xs) {664 return xs[xs.length - 1];665}666function startsWith(source, searchString) {667 return source.startsWith(searchString);668}669function advanceBy(context, numberOfCharacters) {670 var source = context.source;671 true && utils_1.assert(numberOfCharacters <= source.length);672 utils_1.advancePositionWithMutation(context, source, numberOfCharacters);673 context.source = source.slice(numberOfCharacters);674}675function advanceSpaces(context) {676 var match = /^[\t\r\n\f ]+/.exec(context.source);677 if (match) {678 advanceBy(context, match[0].length);679 }680}681function getNewPosition(context, start, numberOfCharacters) {682 return utils_1.advancePositionWithClone(start, context.originalSource.slice(start.offset, numberOfCharacters), numberOfCharacters);683}684function emitError(context, code, offset) {685 var loc = getCursor(context);686 if (offset) {687 loc.offset += offset;688 loc.column += offset;689 }690 context.options.onError(errors_1.createCompilerError(code, {691 start: loc,692 end: loc,693 source: ''694 }));695}696function isEnd(context, mode, ancestors) {697 var s = context.source;698 switch (mode) {...

Full Screen

Full Screen

assimilation.js

Source:assimilation.js Github

copy

Full Screen

...164 function() {165 it('emits `error`', function(done) {166 var ts = new Thenstream({167 then: function(_, emitError) {168 emitError(sentinels.foo);169 }170 });171 ts.on('error', function(r) {172 assert.matchingSentinels(r, sentinels.foo);173 done();174 });175 });176 });177 describe('2.3.3.3.3: If both `setSource` and `emitError` are called, ' +178 'or multiple calls to the same argument are made, the first call ' +179 'takes precedence, and any further calls are ignored.',180 function() {181 function testRead(then) {182 it('reads from source without errors', function(done) {183 var ts = new Thenstream({184 then: then185 });186 var readSpy = sinon.spy(function() {187 assert.matchingSentinels(ts.read(), sentinels.foo);188 });189 var errorSpy = sinon.spy();190 ts.on('readable', readSpy);191 ts.on('error', errorSpy);192 setTimeout(function() {193 assert.calledOnce(readSpy);194 assert.notCalled(errorSpy);195 done();196 }, 10);197 });198 }199 function testError(then) {200 it('emits `error` without reading from source', function(done) {201 var ts = new Thenstream({202 then: then203 });204 var readSpy = sinon.spy();205 var errorSpy = sinon.spy();206 ts.on('readable', readSpy);207 ts.on('error', errorSpy);208 setTimeout(function() {209 assert.calledOnce(errorSpy);210 assert.notCalled(readSpy);211 assert.isNull(ts.read());212 done();213 }, 10);214 });215 }216 describe('calling `setSource` then `emitError`, both synchronously',217 function() {218 testRead(function(setSource, emitError) {219 setSource(pt);220 emitError();221 });222 });223 describe('calling `setSource` synchronously then `emitError` ' +224 'asynchronously',225 function() {226 testRead(function(setSource, emitError) {227 setSource(pt);228 setImmediate(emitError);229 });230 });231 describe('calling `setSource` then `emitError`, both ' +232 'asynchronously',233 function() {234 testRead(function(setSource, emitError) {235 setImmediate(function() { setSource(pt); });236 setImmediate(emitError);237 });238 });239 describe('calling `emitError` then `setSource`, both synchronously',240 function() {241 testError(function(setSource, emitError) {242 emitError();243 setSource(pt);244 });245 });246 describe('calling `emitError` synchronously then `setSource` ' +247 'asynchronously',248 function() {249 testError(function(setSource, emitError) {250 emitError();251 setImmediate(function() { setSource(pt); });252 });253 });254 describe('calling `emitError` then `setSource`, both ' +255 'asynchronously',256 function() {257 testError(function(setSource, emitError) {258 setImmediate(emitError);259 setImmediate(function() { setSource(pt); });260 });261 });262 describe('calling `setSource` twice synchronously',263 function() {264 testRead(function(setSource) {265 setSource(pt);266 setSource(pt2);267 });268 });269 describe('calling `setSource` twice, first synchronously then ' +270 'asynchronously',271 function() {272 testRead(function(setSource) {273 setSource(pt);274 setImmediate(function() { setSource(pt2); });275 });276 });277 describe('calling `setSource` twice, both times asynchronously',278 function() {279 testRead(function(setSource) {280 setImmediate(function() { setSource(pt); });281 setImmediate(function() { setSource(pt2); });282 });283 });284 describe('calling `emitError` twice synchronously',285 function() {286 testError(function(_, emitError) {287 emitError();288 emitError();289 });290 });291 describe('calling `emitError` twice, first synchronously then ' +292 'asynchronously',293 function() {294 testError(function(_, emitError) {295 emitError();296 setImmediate(emitError);297 });298 });299 describe('calling `emitError` twice, both times asynchronously',300 function() {301 testError(function(_, emitError) {302 setImmediate(emitError);303 setImmediate(emitError);304 });305 });306 });307 describe('2.3.3.3.4: If calling `then` throws an exception `e`,',308 function() {309 describe('2.3.3.3.4.1: If `setSource` or `emitError` have been ' +310 'called, ignore it.',311 function() {312 function testIgnored(then) {313 it('is ignored', function(done) {314 var e = new sentinels.Sentinel('e');315 var ts = new Thenstream({316 then: function(setSource, emitError) {317 then.call(this, setSource, emitError);318 throw e;319 }320 });321 var spy = sinon.spy();322 ts.on('error', spy);323 setTimeout(function() {324 assert.neverCalledWith(spy, e);325 done();326 }, 10);327 });328 }329 describe('`setSource` was called', function() {330 testIgnored(function(setSource) {331 setSource(pt);332 });333 });334 describe('`emitError` was called', function() {335 testIgnored(function(_, emitError) {336 emitError(pt);337 });338 });339 describe('`setSource` then `emitError` was called', function() {340 testIgnored(function(setSource, emitError) {341 setSource(pt);342 emitError();343 });344 });345 describe('`emitError` then `setSource` was called', function() {346 testIgnored(function(setSource, emitError) {347 emitError();348 setSource(pt);349 });350 });351 });352 describe('2.3.3.3.4.2: Otherwise, emit `error`.',353 function() {354 function testEmitted(then) {355 it('is emitted', function(done) {356 var e = new sentinels.Sentinel('e');357 var ts = new Thenstream({358 then: function(setSource, emitError) {359 then.call(this, setSource, emitError);360 throw e;361 }...

Full Screen

Full Screen

clarinet.js

Source:clarinet.js Github

copy

Full Screen

...75 76 var maxActual = 0;77 78 if (textNode !== undefined && textNode.length > MAX_BUFFER_LENGTH) {79 emitError("Max buffer length exceeded: textNode");80 maxActual = Math.max(maxActual, textNode.length);81 }82 if (numberNode.length > MAX_BUFFER_LENGTH) {83 emitError("Max buffer length exceeded: numberNode");84 maxActual = Math.max(maxActual, numberNode.length);85 }86 87 bufferCheckPosition = (MAX_BUFFER_LENGTH - maxActual)88 + position;89 }90 eventBus(STREAM_DATA).on(handleData);91 /* At the end of the http content close the clarinet 92 This will provide an error if the total content provided was not 93 valid json, ie if not all arrays, objects and Strings closed properly */94 eventBus(STREAM_END).on(handleStreamEnd); 95 function emitError (errorString) {96 if (textNode !== undefined) {97 emitValueOpen(textNode);98 emitValueClose();99 textNode = undefined;100 }101 latestError = Error(errorString + "\nLn: "+line+102 "\nCol: "+column+103 "\nChr: "+c);104 105 emitFail(errorReport(undefined, undefined, latestError));106 }107 function handleStreamEnd() {108 if( state == BEGIN ) {109 // Handle the case where the stream closes without ever receiving110 // any input. This isn't an error - response bodies can be blank,111 // particularly for 204 http responses112 113 // Because of how Oboe is currently implemented, we parse a114 // completely empty stream as containing an empty object.115 // This is because Oboe's done event is only fired when the116 // root object of the JSON stream closes.117 118 // This should be decoupled and attached instead to the input stream119 // from the http (or whatever) resource ending.120 // If this decoupling could happen the SAX parser could simply emit121 // zero events on a completely empty input.122 emitValueOpen({});123 emitValueClose();124 closed = true;125 return;126 }127 128 if (state !== VALUE || depth !== 0)129 emitError("Unexpected end");130 131 if (textNode !== undefined) {132 emitValueOpen(textNode);133 emitValueClose();134 textNode = undefined;135 }136 137 closed = true;138 }139 function whitespace(c){140 return c == '\r' || c == '\n' || c == ' ' || c == '\t';141 }142 143 function handleData (chunk) {144 145 // this used to throw the error but inside Oboe we will have already146 // gotten the error when it was emitted. The important thing is to147 // not continue with the parse.148 if (latestError)149 return;150 151 if (closed) {152 return emitError("Cannot write after close");153 }154 var i = 0;155 c = chunk[0]; 156 while (c) {157 p = c;158 c = chunk[i++];159 if(!c) break;160 position ++;161 if (c == "\n") {162 line ++;163 column = 0;164 } else column ++;165 switch (state) {166 case BEGIN:167 if (c === "{") state = OPEN_OBJECT;168 else if (c === "[") state = OPEN_ARRAY;169 else if (!whitespace(c))170 return emitError("Non-whitespace before {[.");171 continue;172 case OPEN_KEY:173 case OPEN_OBJECT:174 if (whitespace(c)) continue;175 if(state === OPEN_KEY) stack.push(CLOSE_KEY);176 else {177 if(c === '}') {178 emitValueOpen({});179 emitValueClose();180 state = stack.pop() || VALUE;181 continue;182 } else stack.push(CLOSE_OBJECT);183 }184 if(c === '"')185 state = STRING;186 else187 return emitError("Malformed object key should start with \" ");188 continue;189 case CLOSE_KEY:190 case CLOSE_OBJECT:191 if (whitespace(c)) continue;192 if(c===':') {193 if(state === CLOSE_OBJECT) {194 stack.push(CLOSE_OBJECT);195 if (textNode !== undefined) {196 // was previously (in upstream Clarinet) one event197 // - object open came with the text of the first198 emitValueOpen({});199 emitSaxKey(textNode);200 textNode = undefined;201 }202 depth++;203 } else {204 if (textNode !== undefined) {205 emitSaxKey(textNode);206 textNode = undefined;207 }208 }209 state = VALUE;210 } else if (c==='}') {211 if (textNode !== undefined) {212 emitValueOpen(textNode);213 emitValueClose();214 textNode = undefined;215 }216 emitValueClose();217 depth--;218 state = stack.pop() || VALUE;219 } else if(c===',') {220 if(state === CLOSE_OBJECT)221 stack.push(CLOSE_OBJECT);222 if (textNode !== undefined) {223 emitValueOpen(textNode);224 emitValueClose();225 textNode = undefined;226 }227 state = OPEN_KEY;228 } else 229 return emitError('Bad object');230 continue;231 case OPEN_ARRAY: // after an array there always a value232 case VALUE:233 if (whitespace(c)) continue;234 if(state===OPEN_ARRAY) {235 emitValueOpen([]);236 depth++; 237 state = VALUE;238 if(c === ']') {239 emitValueClose();240 depth--;241 state = stack.pop() || VALUE;242 continue;243 } else {244 stack.push(CLOSE_ARRAY);245 }246 }247 if(c === '"') state = STRING;248 else if(c === '{') state = OPEN_OBJECT;249 else if(c === '[') state = OPEN_ARRAY;250 else if(c === 't') state = TRUE;251 else if(c === 'f') state = FALSE;252 else if(c === 'n') state = NULL;253 else if(c === '-') { // keep and continue254 numberNode += c;255 } else if(c==='0') {256 numberNode += c;257 state = NUMBER_DIGIT;258 } else if('123456789'.indexOf(c) !== -1) {259 numberNode += c;260 state = NUMBER_DIGIT;261 } else 262 return emitError("Bad value");263 continue;264 case CLOSE_ARRAY:265 if(c===',') {266 stack.push(CLOSE_ARRAY);267 if (textNode !== undefined) {268 emitValueOpen(textNode);269 emitValueClose();270 textNode = undefined;271 }272 state = VALUE;273 } else if (c===']') {274 if (textNode !== undefined) {275 emitValueOpen(textNode);276 emitValueClose();277 textNode = undefined;278 }279 emitValueClose();280 depth--;281 state = stack.pop() || VALUE;282 } else if (whitespace(c))283 continue;284 else 285 return emitError('Bad array');286 continue;287 case STRING:288 if (textNode === undefined) {289 textNode = "";290 }291 // thanks thejh, this is an about 50% performance improvement.292 var starti = i-1;293 294 STRING_BIGLOOP: while (true) {295 // zero means "no unicode active". 1-4 mean "parse some more". end after 4.296 while (unicodeI > 0) {297 unicodeS += c;298 c = chunk.charAt(i++);299 if (unicodeI === 4) {300 // TODO this might be slow? well, probably not used too often anyway301 textNode += String.fromCharCode(parseInt(unicodeS, 16));302 unicodeI = 0;303 starti = i-1;304 } else {305 unicodeI++;306 }307 // we can just break here: no stuff we skipped that still has to be sliced out or so308 if (!c) break STRING_BIGLOOP;309 }310 if (c === '"' && !slashed) {311 state = stack.pop() || VALUE;312 textNode += chunk.substring(starti, i-1);313 break;314 }315 if (c === '\\' && !slashed) {316 slashed = true;317 textNode += chunk.substring(starti, i-1);318 c = chunk.charAt(i++);319 if (!c) break;320 }321 if (slashed) {322 slashed = false;323 if (c === 'n') { textNode += '\n'; }324 else if (c === 'r') { textNode += '\r'; }325 else if (c === 't') { textNode += '\t'; }326 else if (c === 'f') { textNode += '\f'; }327 else if (c === 'b') { textNode += '\b'; }328 else if (c === 'u') {329 // \uxxxx. meh!330 unicodeI = 1;331 unicodeS = '';332 } else {333 textNode += c;334 }335 c = chunk.charAt(i++);336 starti = i-1;337 if (!c) break;338 else continue;339 }340 stringTokenPattern.lastIndex = i;341 var reResult = stringTokenPattern.exec(chunk);342 if (!reResult) {343 i = chunk.length+1;344 textNode += chunk.substring(starti, i-1);345 break;346 }347 i = reResult.index+1;348 c = chunk.charAt(reResult.index);349 if (!c) {350 textNode += chunk.substring(starti, i-1);351 break;352 }353 }354 continue;355 case TRUE:356 if (!c) continue; // strange buffers357 if (c==='r') state = TRUE2;358 else359 return emitError( 'Invalid true started with t'+ c);360 continue;361 case TRUE2:362 if (!c) continue;363 if (c==='u') state = TRUE3;364 else365 return emitError('Invalid true started with tr'+ c);366 continue;367 case TRUE3:368 if (!c) continue;369 if(c==='e') {370 emitValueOpen(true);371 emitValueClose();372 state = stack.pop() || VALUE;373 } else374 return emitError('Invalid true started with tru'+ c);375 continue;376 case FALSE:377 if (!c) continue;378 if (c==='a') state = FALSE2;379 else380 return emitError('Invalid false started with f'+ c);381 continue;382 case FALSE2:383 if (!c) continue;384 if (c==='l') state = FALSE3;385 else386 return emitError('Invalid false started with fa'+ c);387 continue;388 case FALSE3:389 if (!c) continue;390 if (c==='s') state = FALSE4;391 else392 return emitError('Invalid false started with fal'+ c);393 continue;394 case FALSE4:395 if (!c) continue;396 if (c==='e') {397 emitValueOpen(false);398 emitValueClose();399 state = stack.pop() || VALUE;400 } else401 return emitError('Invalid false started with fals'+ c);402 continue;403 case NULL:404 if (!c) continue;405 if (c==='u') state = NULL2;406 else407 return emitError('Invalid null started with n'+ c);408 continue;409 case NULL2:410 if (!c) continue;411 if (c==='l') state = NULL3;412 else413 return emitError('Invalid null started with nu'+ c);414 continue;415 case NULL3:416 if (!c) continue;417 if(c==='l') {418 emitValueOpen(null);419 emitValueClose();420 state = stack.pop() || VALUE;421 } else 422 return emitError('Invalid null started with nul'+ c);423 continue;424 case NUMBER_DECIMAL_POINT:425 if(c==='.') {426 numberNode += c;427 state = NUMBER_DIGIT;428 } else 429 return emitError('Leading zero not followed by .');430 continue;431 case NUMBER_DIGIT:432 if('0123456789'.indexOf(c) !== -1) numberNode += c;433 else if (c==='.') {434 if(numberNode.indexOf('.')!==-1)435 return emitError('Invalid number has two dots');436 numberNode += c;437 } else if (c==='e' || c==='E') {438 if(numberNode.indexOf('e')!==-1 ||439 numberNode.indexOf('E')!==-1 )440 return emitError('Invalid number has two exponential');441 numberNode += c;442 } else if (c==="+" || c==="-") {443 if(!(p==='e' || p==='E'))444 return emitError('Invalid symbol in number');445 numberNode += c;446 } else {447 if (numberNode) {448 emitValueOpen(parseFloat(numberNode));449 emitValueClose();450 numberNode = "";451 }452 i--; // go back one453 state = stack.pop() || VALUE;454 }455 continue;456 default:457 return emitError("Unknown state: " + state);458 }459 }460 if (position >= bufferCheckPosition)461 checkBufferLength();462 }...

Full Screen

Full Screen

processBarcode-test.js

Source:processBarcode-test.js Github

copy

Full Screen

1import { processBarcode } from '../TableContainer';2import sinon from 'sinon';3import { Observable } from 'rxjs';4describe('processBarcode', () => {5 const appSession = {6 accessToken: '1234',7 museumId: 99,8 collectionId: 'd3982b48-0000-0000-0000-6e38b59d57ed'9 };10 const barCodeWithUUID = {11 uuid: true,12 code: 'd3982b48-56c7-4d27-bc81-6e38b59d57ed'13 };14 const barCodeWithNumber = {15 number: true,16 code: 12345678917 };18 it('should emit error when receiving a uuid that does not exist', () => {19 const emitError = sinon.spy();20 const props = {21 findNodeByUUID: () => Observable.of(null),22 classExistsOnDom: () => false,23 appSession,24 emitError25 };26 processBarcode(barCodeWithUUID, props);27 expect(emitError.calledOnce).toBe(true);28 });29 it('should update move dialog when receiving a uuid when move dialog is open', () => {30 const updateMoveDialog = sinon.spy();31 const props = {32 findNodeByUUID: () =>33 Observable.of({34 id: 1,35 nodeId: '1234',36 name: 'Test'37 }),38 classExistsOnDom: clazz => clazz === 'moveDialog',39 appSession,40 updateMoveDialog41 };42 processBarcode(barCodeWithUUID, props);43 expect(updateMoveDialog.calledOnce).toBe(true);44 });45 it('should emit error when receiving a uuid that exists when move history is open', () => {46 const emitError = sinon.spy();47 const props = {48 classExistsOnDom: clazz => clazz === 'moveHistory',49 appSession,50 emitError51 };52 processBarcode(barCodeWithUUID, props);53 expect(emitError.calledOnce).toBe(false);54 });55 it('should go to node location when receiving a uuid that exists', () => {56 const goTo = sinon.spy();57 const props = {58 findNodeByUUID: () =>59 Observable.of({60 id: 1,61 nodeId: '12344',62 name: 'Test'63 }),64 classExistsOnDom: () => false,65 appSession,66 goTo67 };68 processBarcode(barCodeWithUUID, props);69 expect(goTo.calledOnce).toBe(true);70 });71 it('should emit error when receiving a number that does not exist', () => {72 const emitError = sinon.spy();73 const props = {74 findNodeOrObjectByBarcode: () => Observable.of(null),75 classExistsOnDom: () => false,76 appSession,77 emitError78 };79 processBarcode(barCodeWithNumber, props);80 expect(emitError.calledOnce).toBe(true);81 });82 it('should emit error when receiving an number that resolves to an array with a single object without currentLocationId', () => {83 const emitError = sinon.spy();84 const props = {85 findNodeOrObjectByBarcode: () =>86 Observable.of([87 {88 id: 1,89 term: 'Fugl'90 }91 ]),92 classExistsOnDom: () => false,93 appSession,94 emitError95 };96 processBarcode(barCodeWithNumber, props);97 expect(emitError.calledOnce).toBe(true);98 });99 it('should emit error when receiving an number that does not exist when move dialog is open', () => {100 const emitError = sinon.spy();101 const props = {102 findNodeByBarcode: () => Observable.of(null),103 classExistsOnDom: clazz => clazz === 'moveDialog',104 appSession,105 emitError106 };107 processBarcode(barCodeWithNumber, props);108 expect(emitError.calledOnce).toBe(true);109 });110 it('should emit error when receiving an number that resolves to an array with a single object when move history is open', () => {111 const emitError = sinon.spy();112 const props = {113 findNodeOrObjectByBarcode: () =>114 Observable.of([115 {116 id: 1,117 term: 'Fugl',118 currentLocationId: 45119 }120 ]),121 classExistsOnDom: clazz => clazz === 'moveHistory',122 appSession,123 emitError124 };125 processBarcode(barCodeWithNumber, props);126 expect(emitError.calledOnce).toBe(false);127 });128 it('should go to node location when receiving an number that resolves to an array with a single object', () => {129 const goTo = sinon.spy();130 const props = {131 findNodeOrObjectByBarcode: () =>132 Observable.of([133 {134 id: 1,135 term: 'Fugl',136 currentLocationId: 45137 }138 ]),139 classExistsOnDom: () => false,140 appSession,141 goTo142 };143 processBarcode(barCodeWithNumber, props);144 expect(goTo.calledOnce).toBe(true);145 });146 it('should emit error when receiving an number that resolves to an array with multiple objects', () => {147 const emitError = sinon.spy();148 const props = {149 findNodeOrObjectByBarcode: () =>150 Observable.of([151 {152 id: 1,153 term: 'Fugl',154 currentLocationId: 45155 },156 {157 id: 2,158 term: 'Fisk',159 currentLocationId: 45160 }161 ]),162 classExistsOnDom: () => false,163 appSession,164 emitError165 };166 processBarcode(barCodeWithNumber, props);167 expect(emitError.calledOnce).toBe(true);168 });169 it('should update move dialog when receiving an number that resolves to a node when move dialog is open', () => {170 const updateMoveDialog = sinon.spy();171 const props = {172 findNodeByBarcode: () =>173 Observable.of({174 id: 1,175 nodeId: 'someUUID',176 name: 'Test'177 }),178 classExistsOnDom: clazz => clazz === 'moveDialog',179 appSession,180 updateMoveDialog181 };182 processBarcode(barCodeWithNumber, props);183 expect(updateMoveDialog.calledOnce).toBe(true);184 });185 it('should emit error when receiving an number that resolves to a node when move history is open', () => {186 const emitError = sinon.spy();187 const props = {188 findNodeOrObjectByBarcode: () =>189 Observable.of({190 id: 1,191 nodeId: 'someUUID',192 name: 'Test'193 }),194 classExistsOnDom: clazz => clazz === 'moveHistory',195 appSession,196 emitError197 };198 processBarcode(barCodeWithNumber, props);199 expect(emitError.calledOnce).toBe(false);200 });201 it('should go to node location when receiving an number that resolves to a node', () => {202 const goTo = sinon.spy();203 const props = {204 findNodeOrObjectByBarcode: () =>205 Observable.of({206 id: 1,207 nodeId: 'someUUID',208 name: 'Test'209 }),210 classExistsOnDom: () => false,211 appSession,212 goTo213 };214 processBarcode(barCodeWithNumber, props);215 expect(goTo.calledOnce).toBe(true);216 });217 it('should emit error if nothing found', () => {218 const emitError = sinon.spy();219 const props = {220 findNodeOrObjectByBarcode: () => Observable.of(null),221 classExistsOnDom: () => false,222 appSession,223 emitError224 };225 processBarcode(barCodeWithNumber, props);226 expect(emitError.calledOnce).toBe(true);227 });...

Full Screen

Full Screen

onCar.js

Source:onCar.js Github

copy

Full Screen

...8 UIManager9} from 'react-native';10import { Tcp } from 'NativeModules';11let onObj = {12 emitError(msg) {13 alert('通信异常', msg);14 },15 timeout: {16 motion: null,17 direction: null,18 }19}20let onData = {21 forward: {22 start() {23 console.log('前进开始')24 clearInterval(onObj.timeout.motion)25 Tcp.emit("w", onObj.emitError);26 onObj.timeout.motion = setInterval(() => {...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...20 )21 socket.on(22 'init',23 ({ socketid: _socketid, data: { channel: _channel, user: _user } }) => {24 if (!_user) return emitError(_socketid, 'UNAUTHORIZED')25 const channel = client.channels.get(_channel)26 if (!channel) return emitError(_socketid, 'INVAILD_CHANNEL')27 if (channel.type !== 'voice')28 return emitError(_socketid, 'INVAILD_CHANNEL_TYPE')29 if (channel.full) return emitError(_socketid, 'CHANNEL_IS_FULL')30 if (!channel.joinable) return emitError(_socketid, 'MISSING_PERMISSION')31 if (!channel.speakable) return emitError(_socketid, 'MISSING_PERMISSION')32 if (!channel.members.has(_user))33 return emitError(_socketid, 'USER_NOT_JOINED')34 const guild = channel.guild35 // 同じギルドのボイチャに参加済み36 if (guilds.has(guild.id)) {37 if (guilds.get(guild.id).id !== channel.id)38 return emitError(_socketid, 'ALREADY_JOINED')39 } else {40 // Botが参加していない41 guilds.set(42 guild.id,43 new VoiceChannel(channel, queue => {44 // io.to(guild.id).emit('list', queue)45 io.sockets.emit('room', {46 room: guild.id,47 emit: 'list',48 data: queue,49 })50 })51 )52 }53 socket.join(guild.id)54 io.sockets.emit('socketid', {55 socketid: _socketid,56 emit: 'volume',57 data: guilds.get(guild.id).volume,58 })59 io.sockets.emit('socketid', {60 socketid: _socketid,61 emit: 'repeat',62 data: guilds.get(guild.id).repeat,63 })64 io.sockets.emit('socketid', {65 socketid: _socketid,66 emit: 'list',67 data: guilds.get(guild.id).list,68 })69 io.sockets.emit('socketid', {70 socketid: _socketid,71 emit: 'ready',72 data: {73 guild: guild.name,74 channel: channel.name,75 id: guild.id,76 },77 })78 }79 )80 // socket.on('q', q => {81 // search(q)82 // .then(data => socket.emit('result', data))83 // .catch(error => emitError(_socketid, error))84 // })85 socket.on('add', ({ socketid: _socketid, data }) => {86 if (!guilds.has(data.guild)) emitError(_socketid, 'UNTREATED_CHANNEL')87 else88 guilds89 .get(data.guild)90 .add(data)91 .then(list =>92 io.sockets.emit('room', {93 room: data.guild,94 emit: 'list',95 data: list,96 })97 ) // io.to(data.guild).emit('list', list))98 .catch(error => emitError(_socketid, error))99 })100 socket.on('remove', ({ socketid: _socketid, data }) => {101 if (!guilds.has(data.id)) emitError(_socketid, 'UNTREATED_CHANNEL')102 else103 guilds104 .get(data.id)105 .remove(data.index)106 .then(list =>107 io.sockets.emit('room', {108 room: data.guild,109 emit: 'list',110 data: list,111 })112 ) // io.to(data.id).emit('list', list))113 .catch(error => emitError(_socketid, error))114 })115 socket.on('volume', ({ socketid: _socketid, data }) => {116 if (!guilds.has(data.id)) emitError(_socketid, 'UNTREATED_CHANNEL')117 else118 guilds119 .get(data.id)120 .setVolume(data.volume)121 .then(volume =>122 io.sockets.emit('room', {123 room: data.guild,124 emit: 'volume',125 data: volume,126 selfExclude: true,127 })128 ) // socket.broadcast.to(data.id).emit('volume', volume))129 .catch(error => emitError(_socketid, error))130 })131 socket.on('repeat', ({ socketid: _socketid, data }) => {132 if (!guilds.has(data.id)) emitError(_socketid, 'UNTREATED_CHANNEL')133 else134 guilds135 .get(data.id)136 .setRepeat(data.repeat)137 .then(repeat =>138 io.sockets.emit('room', {139 room: data.guild,140 emit: 'repeat',141 data: repeat,142 selfExclude: true,143 })144 ) // socket.broadcast.to(data.id).emit('repeat', repeat))145 })146 socket.on('skip', ({ socketid: _socketid, data: id }) => {147 if (!guilds.has(id)) emitError(_socketid, 'UNTREATED_CHANNEL')148 else149 guilds150 .get(id)151 .skip()152 .catch(error => emitError(_socketid, error))153 })154})155client.on('ready', () => {156 console.log(`Logged in as ${client.user.tag}!`)157})158client.login(env.DISCORD_TOKEN)159process.on('unhandledRejection', err => console.log(err))...

Full Screen

Full Screen

web3Actions.js

Source:web3Actions.js Github

copy

Full Screen

...30 if(chainId > 200) this.initContract(); // local chain 133731 else alert('Contract is not deployed on selected network.')32 });33 },34 emitError(err) {35 this.emitUpdate({web3_error: err});36 },37 initContract() {38 // Get the necessary contract artifact file and instantiate it with @truffle/contract39 this.contracts.Figurava = TruffleContract(FiguravaAbi);40 // Set the provider for our contract41 this.contracts.Figurava.setProvider(this.web3Provider);42 // Use our contract to retrieve wallet's tokens43 this.totalSupply();44 // check if already logged in45 if(window.ethereum && window.ethereum.selectedAddress)46 this.connect();47 },48 getDeployedContract() {49 return new Promise((resolve,reject) => {50 if(this.deployedContract)51 resolve(this.deployedContract);52 else53 this.contracts.Figurava.deployed()54 .then((instance) => {55 this.deployedContract = instance;56 resolve(this.deployedContract);57 });58 });59 },60 totalSupply() {61 this.getDeployedContract().then((instance) =>{62 // Using call() allows us to read data from the blockchain without having to send a full transaction, meaning we won't have to spend any ether.63 return instance.totalSupply.call();64 }).then((minted) => {65 this.emitUpdate({minted: Web3.utils.hexToNumber(minted)});66 })67 .catch((err) => {68 this.emitError(err)69 });70 },71 walletOfOwner() {72 this.emitError(null);73 this.getDeployedContract().then((instance) =>{74 // Using call() allows us to read data from the blockchain without having to send a full transaction, meaning we won't have to spend any ether.75 return instance.walletOfOwner.call(this.account);76 })77 .then((tokens) => {78 tokens = tokens.map((item)=> Web3.utils.hexToNumber(item))79 this.emitUpdate({tokens: tokens});80 })81 .catch((err) => {82 this.emitError(err)83 });84 },85 requireWeb3() {86 if(this.web3) return false;87 alert('Web3 required');88 return true;89 },90 async connect() {91 if(this.requireWeb3()) return;92 this.emitError(null);93 try {94 // Request account access95 await window.ethereum.request({ method: "eth_requestAccounts" });;96 } catch (err) {97 // User denied account access...98 console.error("User denied account access");99 this.emitError(err);100 return;101 }102 this.web3.eth.getAccounts((error, accounts) =>{103 if (error) {104 this.emitError(error);105 return106 }107 this.emitError(null);108 this.account = accounts[0];109 this.emitUpdate({account: this.account});110 this.listenAccountsChanges();111 return this.walletOfOwner();112 }).catch((err) => {113 this.emitError(err);114 });115 },116 listenAccountsChanges() {117 window.ethereum.on("accountsChanged", (accounts) => {118 if(!accounts || !accounts.length || this.account != accounts[0])119 window.location.reload();120 });121 },122 mint(count) {123 this.emitError(null);124 // make sure decimal number is correctly converted to string125 const price = (count * 0.05).toFixed(2).toString();126 this.getDeployedContract().then((instance) =>{127 // Execute mint as a transaction by sending account128 return instance.mint(this.account,count, {from: this.account, value : Web3.utils.toHex( Web3.utils.toWei(price, 'ether'))});129 }).then((result) =>{130 this.totalSupply();131 return this.walletOfOwner();132 }).catch((err) =>{133 this.emitError(err);134 });135 }...

Full Screen

Full Screen

Car.js

Source:Car.js Github

copy

Full Screen

...13 }14 componentWillMount() {15 Orientation.lockToLandscape(); //强行横屏16 }17 emitError(msg) {18 alert('通信异常', msg);19 }20 render() {21 return (22 <View>23 <View style={{ ...styles.wh }}>24 <TouchableHighlight25 underlayColor="rgba(34, 26, 38, 0.1)"26 onPressIn={() => {27 console.log("onPressIn");28 clearInterval(this.timeout.motion)29 Tcp.emit("w", this.emitError);30 this.timeout.motion = setInterval(() => {31 console.log("w");...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('test', async ({ page }) => {3 await page.waitForSelector('text=Get Started');4 await page.click('text=Get Started');5 await page.waitForSelector('text=Get Started');6 await page.click('text=Get Started');7});8const { test, expect } = require('@playwright/test');9test('test', async ({ page }) => {10 await page.waitForSelector('text=Get Started');11 await page.click('text=Get Started');12 await page.waitForSelector('text=Get Started');13 await page.click('text=Get Started');14});15import { test, expect } from '@playwright/test';16test('test', async ({ page }) => {17 await page.waitForSelector('text=Get Started');18 await page.click('text=Get Started');19 await page.waitForSelector('text=Get Started');20 await page.click('text=Get Started');21});22Screenshot 2021-05-28 at 2.53.15 PM.png (9.0 KB)23Screenshot 2021-05-28 at 2.54.29 PM.png (15.1 KB)24logs.txt (2.7 KB)25Video Recording 2021-05-28 at 2.57.57 PM.mov (3.2 MB)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { InternalError } = require('playwright/lib/errors');2const internalError = new InternalError('Test Internal Error');3internalError.emitError();4const { TimeoutError } = require('playwright/lib/errors');5const timeoutError = new TimeoutError('Test Timeout Error');6timeoutError.emitError();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Internal } = require('playwright/lib/transport');2Internal.prototype.emitError = function (error) {3 console.log(error);4 throw error;5};6const { chromium } = require('playwright');7(async () => {8 const browser = await chromium.launch({ headless: false });9 const context = await browser.newContext();10 const page = await context.newPage();11 await page.screenshot({ path: `example.png` });12 await browser.close();13})();14const { Internal } = require('playwright/lib/transport');15Internal.prototype.emitError = function (error) {16 console.log(error);17 throw error;18};19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch({ headless: false });22 const context = await browser.newContext();23 const page = await context.newPage();24 await page.screenshot({ path: `example.png` });25 await browser.close();26})();27const { Internal } = require('playwright/lib/transport');28Internal.prototype.emitError = function (error) {29 console.log(error);30 throw error;31};32const { chromium } = require('playwright');33(async () => {34 const browser = await chromium.launch({ headless: false });35 const context = await browser.newContext();36 const page = await context.newPage();37 await page.screenshot({ path: `example.png` });38 await browser.close();39})();40const { Internal } = require('playwright/lib/transport');41Internal.prototype.emitError = function (error) {42 console.log(error);43 throw error;44};45const { chromium } = require('playwright');46(async () => {47 const browser = await chromium.launch({ headless: false });

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Playwright } = require('playwright-core/lib/server/playwright');2const playwright = new Playwright();3const browserServer = await playwright.chromium.launchServer();4browserServer.emitError(new Error('test'));5const { Playwright } = require('playwright-core/lib/server/playwright');6const playwright = new Playwright();7const browserServer = await playwright.chromium.launchServer();8browserServer.emitError(new Error('test'));

Full Screen

Using AI Code Generation

copy

Full Screen

1const { PlaywrightError } = require('playwright-core/lib/errors');2const error = new PlaywrightError('Test Error');3error.emitError();4 at Object.emitError (node_modules/playwright-core/lib/errors.js:28:11)5 at Object.<anonymous> (test.js:4:9)6const { PlaywrightError } = require('playwright-core/lib/errors');7const error = new PlaywrightError('Test Error');8error.emitError();9 at Object.emitError (node_modules/playwright-core/lib/errors.js:28:11)10 at Object.<anonymous> (test.js:4:9)11 Edge: Spartan (44.19041.1023.0), Chromium (96.0.1054.43)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { emitError } = require('playwright-core/lib/internal/stackTrace');2emitError(new Error('Error from test.js'));3const { emitError } = require('playwright-core/lib/internal/stackTrace');4emitError(new Error('Error from test2.js'));5const { emitError } = require('playwright-core/lib/internal/stackTrace');6emitError(new Error('Error from test3.js'));7const { emitError } = require('playwright-core/lib/internal/stackTrace');8emitError(new Error('Error from test4.js'));9const { emitError } = require('playwright-core/lib/internal/stackTrace');10emitError(new Error('Error from test5.js'));11const { emitError } = require('playwright-core/lib/internal/stackTrace');12emitError(new Error('Error from test6.js'));13const { emitError } = require('playwright-core/lib/internal/stackTrace');14emitError(new Error('Error from test7.js'));15const { emitError } = require('playwright-core/lib/internal/stackTrace');16emitError(new Error('Error from test8.js'));17const { emitError } = require('playwright-core/lib/internal/stackTrace');18emitError(new Error('Error from test9.js'));19const { emitError } = require('playwright-core/lib/internal/stackTrace

Full Screen

Using AI Code Generation

copy

Full Screen

1const { PlaywrightError } = require('playwright-core/lib/errors');2const { test, expect, describe } = require('@playwright/test');3const { emitError } = require('playwright-core/lib/utils/stackTrace');4const { timeout } = require('playwright-core/lib/utils/utils');5describe('Playwright Internal Error', () => {6 test('Playwright Internal Error', async ({ page }) => {7 try {8 await page.click('text=Click Me');9 } catch (error) {10 emitError(new PlaywrightError(error.message));11 }12 });13});

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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