How to use getPreciseType method in Playwright Internal

Best JavaScript code snippet using playwright-internal

factoryWithTypeCheckers.js

Source:factoryWithTypeCheckers.js Github

copy

Full Screen

...214 if (propType !== expectedType) {215 // `propValue` being instance of, say, date/regexp, pass the 'object'216 // check, but we can offer a more precise error message here rather than217 // 'of type `object`'.218 var preciseType = getPreciseType(propValue);219 return new PropTypeError(220 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),221 {expectedType: expectedType}222 );223 }224 return null;225 }226 return createChainableTypeChecker(validate);227 }228 function createAnyTypeChecker() {229 return createChainableTypeChecker(emptyFunctionThatReturnsNull);230 }231 function createArrayOfTypeChecker(typeChecker) {232 function validate(props, propName, componentName, location, propFullName) {233 if (typeof typeChecker !== 'function') {234 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');235 }236 var propValue = props[propName];237 if (!Array.isArray(propValue)) {238 var propType = getPropType(propValue);239 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));240 }241 for (var i = 0; i < propValue.length; i++) {242 var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);243 if (error instanceof Error) {244 return error;245 }246 }247 return null;248 }249 return createChainableTypeChecker(validate);250 }251 function createElementTypeChecker() {252 function validate(props, propName, componentName, location, propFullName) {253 var propValue = props[propName];254 if (!isValidElement(propValue)) {255 var propType = getPropType(propValue);256 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));257 }258 return null;259 }260 return createChainableTypeChecker(validate);261 }262 function createElementTypeTypeChecker() {263 function validate(props, propName, componentName, location, propFullName) {264 var propValue = props[propName];265 if (!ReactIs.isValidElementType(propValue)) {266 var propType = getPropType(propValue);267 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));268 }269 return null;270 }271 return createChainableTypeChecker(validate);272 }273 function createInstanceTypeChecker(expectedClass) {274 function validate(props, propName, componentName, location, propFullName) {275 if (!(props[propName] instanceof expectedClass)) {276 var expectedClassName = expectedClass.name || ANONYMOUS;277 var actualClassName = getClassName(props[propName]);278 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));279 }280 return null;281 }282 return createChainableTypeChecker(validate);283 }284 function createEnumTypeChecker(expectedValues) {285 if (!Array.isArray(expectedValues)) {286 if (process.env.NODE_ENV !== 'production') {287 if (arguments.length > 1) {288 printWarning(289 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +290 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'291 );292 } else {293 printWarning('Invalid argument supplied to oneOf, expected an array.');294 }295 }296 return emptyFunctionThatReturnsNull;297 }298 function validate(props, propName, componentName, location, propFullName) {299 var propValue = props[propName];300 for (var i = 0; i < expectedValues.length; i++) {301 if (is(propValue, expectedValues[i])) {302 return null;303 }304 }305 var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {306 var type = getPreciseType(value);307 if (type === 'symbol') {308 return String(value);309 }310 return value;311 });312 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));313 }314 return createChainableTypeChecker(validate);315 }316 function createObjectOfTypeChecker(typeChecker) {317 function validate(props, propName, componentName, location, propFullName) {318 if (typeof typeChecker !== 'function') {319 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');320 }321 var propValue = props[propName];322 var propType = getPropType(propValue);323 if (propType !== 'object') {324 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));325 }326 for (var key in propValue) {327 if (has(propValue, key)) {328 var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);329 if (error instanceof Error) {330 return error;331 }332 }333 }334 return null;335 }336 return createChainableTypeChecker(validate);337 }338 function createUnionTypeChecker(arrayOfTypeCheckers) {339 if (!Array.isArray(arrayOfTypeCheckers)) {340 process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;341 return emptyFunctionThatReturnsNull;342 }343 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {344 var checker = arrayOfTypeCheckers[i];345 if (typeof checker !== 'function') {346 printWarning(347 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +348 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'349 );350 return emptyFunctionThatReturnsNull;351 }352 }353 function validate(props, propName, componentName, location, propFullName) {354 var expectedTypes = [];355 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {356 var checker = arrayOfTypeCheckers[i];357 var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);358 if (checkerResult == null) {359 return null;360 }361 if (checkerResult.data && has(checkerResult.data, 'expectedType')) {362 expectedTypes.push(checkerResult.data.expectedType);363 }364 }365 var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';366 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));367 }368 return createChainableTypeChecker(validate);369 }370 function createNodeChecker() {371 function validate(props, propName, componentName, location, propFullName) {372 if (!isNode(props[propName])) {373 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));374 }375 return null;376 }377 return createChainableTypeChecker(validate);378 }379 function invalidValidatorError(componentName, location, propFullName, key, type) {380 return new PropTypeError(381 (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +382 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'383 );384 }385 function createShapeTypeChecker(shapeTypes) {386 function validate(props, propName, componentName, location, propFullName) {387 var propValue = props[propName];388 var propType = getPropType(propValue);389 if (propType !== 'object') {390 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));391 }392 for (var key in shapeTypes) {393 var checker = shapeTypes[key];394 if (typeof checker !== 'function') {395 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));396 }397 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);398 if (error) {399 return error;400 }401 }402 return null;403 }404 return createChainableTypeChecker(validate);405 }406 function createStrictShapeTypeChecker(shapeTypes) {407 function validate(props, propName, componentName, location, propFullName) {408 var propValue = props[propName];409 var propType = getPropType(propValue);410 if (propType !== 'object') {411 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));412 }413 // We need to check all keys in case some are required but missing from props.414 var allKeys = assign({}, props[propName], shapeTypes);415 for (var key in allKeys) {416 var checker = shapeTypes[key];417 if (has(shapeTypes, key) && typeof checker !== 'function') {418 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));419 }420 if (!checker) {421 return new PropTypeError(422 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +423 '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +424 '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')425 );426 }427 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);428 if (error) {429 return error;430 }431 }432 return null;433 }434 return createChainableTypeChecker(validate);435 }436 function isNode(propValue) {437 switch (typeof propValue) {438 case 'number':439 case 'string':440 case 'undefined':441 return true;442 case 'boolean':443 return !propValue;444 case 'object':445 if (Array.isArray(propValue)) {446 return propValue.every(isNode);447 }448 if (propValue === null || isValidElement(propValue)) {449 return true;450 }451 var iteratorFn = getIteratorFn(propValue);452 if (iteratorFn) {453 var iterator = iteratorFn.call(propValue);454 var step;455 if (iteratorFn !== propValue.entries) {456 while (!(step = iterator.next()).done) {457 if (!isNode(step.value)) {458 return false;459 }460 }461 } else {462 // Iterator will provide entry [k,v] tuples rather than values.463 while (!(step = iterator.next()).done) {464 var entry = step.value;465 if (entry) {466 if (!isNode(entry[1])) {467 return false;468 }469 }470 }471 }472 } else {473 return false;474 }475 return true;476 default:477 return false;478 }479 }480 function isSymbol(propType, propValue) {481 // Native Symbol.482 if (propType === 'symbol') {483 return true;484 }485 // falsy value can't be a Symbol486 if (!propValue) {487 return false;488 }489 // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'490 if (propValue['@@toStringTag'] === 'Symbol') {491 return true;492 }493 // Fallback for non-spec compliant Symbols which are polyfilled.494 if (typeof Symbol === 'function' && propValue instanceof Symbol) {495 return true;496 }497 return false;498 }499 // Equivalent of `typeof` but with special handling for array and regexp.500 function getPropType(propValue) {501 var propType = typeof propValue;502 if (Array.isArray(propValue)) {503 return 'array';504 }505 if (propValue instanceof RegExp) {506 // Old webkits (at least until Android 4.0) return 'function' rather than507 // 'object' for typeof a RegExp. We'll normalize this here so that /bla/508 // passes PropTypes.object.509 return 'object';510 }511 if (isSymbol(propType, propValue)) {512 return 'symbol';513 }514 return propType;515 }516 // This handles more types than `getPropType`. Only used for error messages.517 // See `createPrimitiveTypeChecker`.518 function getPreciseType(propValue) {519 if (typeof propValue === 'undefined' || propValue === null) {520 return '' + propValue;521 }522 var propType = getPropType(propValue);523 if (propType === 'object') {524 if (propValue instanceof Date) {525 return 'date';526 } else if (propValue instanceof RegExp) {527 return 'regexp';528 }529 }530 return propType;531 }532 // Returns a string that is postfixed to a warning about an invalid type.533 // For example, "undefined" or "of type array"534 function getPostfixForTypeWarning(value) {535 var type = getPreciseType(value);536 switch (type) {537 case 'array':538 case 'object':539 return 'an ' + type;540 case 'boolean':541 case 'date':542 case 'regexp':543 return 'a ' + type;544 default:545 return type;546 }547 }548 // Returns class name of the object, if any.549 function getClassName(propValue) {...

Full Screen

Full Screen

prototype.js

Source:prototype.js Github

copy

Full Screen

...71 if (propType !== expectedType) {72 // `propValue` being instance of, say, date/regexp, pass the 'object'73 // check, but we can offer a more precise error message here rather than74 // 'of type `object`'.75 const preciseType = getPreciseType(propValue);76 return new PropTypeError(77 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),78 {expectedType: expectedType}79 );80 }81 return null;82 }83 return createChainableTypeChecker(validate);84 }85 function createAnyTypeChecker() {86 return createChainableTypeChecker(emptyFunctionThatReturnsNull);87 }88 function createArrayOfTypeChecker(typeChecker) {89 function validate(props, propName, componentName, location, propFullName) {90 if (typeof typeChecker !== 'function') {91 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');92 }93 const propValue = props[propName];94 if (!Array.isArray(propValue)) {95 const propType = getPropType(propValue);96 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));97 }98 for (let i = 0; i < propValue.length; i++) {99 const error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', TypeCheckerSecret);100 if (error instanceof Error) {101 return error;102 }103 }104 return null;105 }106 return createChainableTypeChecker(validate);107 }108 function createInstanceTypeChecker(expectedClass) {109 function validate(props, propName, componentName, location, propFullName) {110 if (!(props[propName] instanceof expectedClass)) {111 const expectedClassName = expectedClass.name || ANONYMOUS;112 const actualClassName = getClassName(props[propName]);113 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));114 }115 return null;116 }117 return createChainableTypeChecker(validate);118 }119 function createEnumTypeChecker(expectedValues) {120 if (!Array.isArray(expectedValues)) {121 if (arguments.length > 1) {122 console.warn(123 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +124 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).')125 } else {126 console.warn('Invalid argument supplied to oneOf, expected an array.');127 }128 return emptyFunctionThatReturnsNull;129 }130 function validate(props, propName, componentName, location, propFullName) {131 const propValue = props[propName];132 for (let i = 0; i < expectedValues.length; i++) {133 if (is(propValue, expectedValues[i])) {134 return null;135 }136 }137 const valuesString = JSON.stringify(expectedValues, function replacer(key, value) {138 const type = getPreciseType(value);139 if (type === 'symbol') {140 return String(value);141 }142 return value;143 });144 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));145 }146 return createChainableTypeChecker(validate);147 }148 function createObjectOfTypeChecker(typeChecker) {149 function validate(props, propName, componentName, location, propFullName) {150 if (typeof typeChecker !== 'function') {151 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');152 }153 const propValue = props[propName];154 const propType = getPropType(propValue);155 if (propType !== 'object') {156 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));157 }158 for (const key in propValue) {159 if (has(propValue, key)) {160 const error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, TypeCheckerSecret);161 if (error instanceof Error) {162 return error;163 }164 }165 }166 return null;167 }168 return createChainableTypeChecker(validate);169 }170 function createUnionTypeChecker(arrayOfTypeCheckers) {171 if (!Array.isArray(arrayOfTypeCheckers)) {172 console.warn('Invalid argument supplied to oneOfType, expected an instance of array.')173 return emptyFunctionThatReturnsNull;174 }175 for (let i = 0; i < arrayOfTypeCheckers.length; i++) {176 const checker = arrayOfTypeCheckers[i];177 if (typeof checker !== 'function') {178 console.warn(179 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +180 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'181 );182 return emptyFunctionThatReturnsNull;183 }184 }185 function validate(props, propName, componentName, location, propFullName) {186 const expectedTypes = [];187 for (let i = 0; i < arrayOfTypeCheckers.length; i++) {188 const checker = arrayOfTypeCheckers[i];189 const checkerResult = checker(props, propName, componentName, location, propFullName, TypeCheckerSecret);190 if (checkerResult == null) {191 return null;192 }193 if (checkerResult.data.hasOwnProperty('expectedType')) {194 expectedTypes.push(checkerResult.data.expectedType);195 }196 }197 const expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']' : '';198 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));199 }200 return createChainableTypeChecker(validate);201 }202 function invalidValidatorError(componentName, location, propFullName, key, type) {203 return new PropTypeError(204 (componentName || 'Object') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +205 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'206 );207 }208 function createShapeTypeChecker(shapeTypes) {209 function validate(props, propName, componentName, location, propFullName) {210 const propValue = props[propName];211 const propType = getPropType(propValue);212 if (propType !== 'object') {213 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));214 }215 for (const key in shapeTypes) {216 const checker = shapeTypes[key];217 if (typeof checker !== 'function') {218 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));219 }220 const error = checker(propValue, key, componentName, location, propFullName + '.' + key, TypeCheckerSecret);221 if (error) {222 return error;223 }224 }225 return null;226 }227 return createChainableTypeChecker(validate);228 }229 function createStrictShapeTypeChecker(shapeTypes) {230 function validate(props, propName, componentName, location, propFullName) {231 const propValue = props[propName];232 const propType = getPropType(propValue);233 if (propType !== 'object') {234 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));235 }236 // We need to check all keys in case some are required but missing from237 // props.238 const allKeys = Object.assign(Object.create(null), props[propName], shapeTypes);239 for (const key in allKeys) {240 const checker = shapeTypes[key];241 if (has(shapeTypes, key) && typeof checker !== 'function') {242 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));243 }244 if (!checker) {245 return new PropTypeError(246 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +247 '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +248 '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')249 );250 }251 const error = checker(propValue, key, componentName, location, propFullName + '.' + key, TypeCheckerSecret);252 if (error) {253 return error;254 }255 }256 return null;257 }258 return createChainableTypeChecker(validate);259 }260 function isSymbol(propType, propValue) {261 // Native Symbol.262 if (propType === 'symbol') {263 return true;264 }265 // falsy value can't be a Symbol266 if (!propValue) {267 return false;268 }269 // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'270 if (propValue['@@toStringTag'] === 'Symbol') {271 return true;272 }273 // Fallback for non-spec compliant Symbols which are polyfilled.274 return typeof Symbol === 'function' && propValue instanceof Symbol;275 }276 // Equivalent of `typeof` but with special handling for array and regexp.277 function getPropType(propValue) {278 const propType = typeof propValue;279 if (Array.isArray(propValue)) {280 return 'array';281 }282 if (propValue instanceof RegExp) {283 // Old webkits (at least until Android 4.0) return 'function' rather than284 // 'object' for typeof a RegExp. We'll normalize this here so that /bla/285 // passes PropTypes.object.286 return 'object';287 }288 if (isSymbol(propType, propValue)) {289 return 'symbol';290 }291 return propType;292 }293 // This handles more types than `getPropType`. Only used for error messages.294 // See `createPrimitiveTypeChecker`.295 function getPreciseType(propValue) {296 if (typeof propValue === 'undefined' || propValue === null) {297 return '' + propValue;298 }299 const propType = getPropType(propValue);300 if (propType === 'object') {301 if (propValue instanceof Date) {302 return 'date';303 } else if (propValue instanceof RegExp) {304 return 'regexp';305 }306 }307 return propType;308 }309 // Returns a string that is postfixed to a warning about an invalid type.310 // For example, "undefined" or "of type array"311 function getPostfixForTypeWarning(value) {312 const type = getPreciseType(value);313 switch (type) {314 case 'array':315 case 'object':316 return 'an ' + type;317 case 'boolean':318 case 'date':319 case 'regexp':320 return 'a ' + type;321 default:322 return type;323 }324 }325 // Returns class name of the object, if any.326 function getClassName(propValue) {...

Full Screen

Full Screen

propTypes.js

Source:propTypes.js Github

copy

Full Screen

...73 return propType74}75// This handles more types than `getPropType`. Only used for error messages.76// Copied from React.PropTypes77function getPreciseType(propValue) {78 const propType = getPropType(propValue)79 if (propType === "object") {80 if (propValue instanceof Date) {81 return "date"82 } else if (propValue instanceof RegExp) {83 return "regexp"84 }85 }86 return propType87}88function createObservableTypeCheckerCreator(allowNativeType, mobxType) {89 return createChainableTypeChecker(function(90 props,91 propName,92 componentName,93 location,94 propFullName95 ) {96 return untracked(() => {97 if (allowNativeType) {98 if (getPropType(props[propName]) === mobxType.toLowerCase()) return null99 }100 let mobxChecker101 switch (mobxType) {102 case "Array":103 mobxChecker = isObservableArray104 break105 case "Object":106 mobxChecker = isObservableObject107 break108 case "Map":109 mobxChecker = isObservableMap110 break111 default:112 throw new Error(`Unexpected mobxType: ${mobxType}`)113 }114 const propValue = props[propName]115 if (!mobxChecker(propValue)) {116 const preciseType = getPreciseType(propValue)117 const nativeTypeExpectationMessage = allowNativeType118 ? " or javascript `" + mobxType.toLowerCase() + "`"119 : ""120 return new Error(121 "Invalid prop `" +122 propFullName +123 "` of type `" +124 preciseType +125 "` supplied to" +126 " `" +127 componentName +128 "`, expected `mobx.Observable" +129 mobxType +130 "`" +...

Full Screen

Full Screen

commonbak.js

Source:commonbak.js Github

copy

Full Screen

...62 return hdHeight * scale;63 }64}6566function getPreciseType(type){67 switch(type){68 case 1:69 return "按产品";70 case 2:71 return "按影片元数据关键字";72 case 3:73 return "按受众";74 case 4:75 return "按影片分类";76 case 5:77 return "按回看频道";78 }79}80function showMaterialPre(path,content,type){81 if(type!=null){82 switch(type){83 case 0:showImage(path);break;84 case 1:showVideo(path);break;85 case 2:showText(content);break;86 }87 }88}89/**显示图片*/90function showImage(path){91 $("#mImage").attr("src",getContextPath()+"/"+path);92 $("#mImage").show();93 $("#video").hide();94 videoFlag=0;95}96/**显示视频*/97function showVideo(path){98 $("#temp").hide();99 $("#temp").remove();100 $("#video").html('<embed id="temp" width="'+width+'" height="'+height+'" version="VideoLAN.VLCPlugin.2" pluginspage="http://www.videolan.org" type="application/x-vlc-plugin" src="'+getContextPath()+"/"+path+'"/>');101 $("#video").show();102 videoFlag=1;103 $("#mImage").hide();104}105/**显示文字*/106function showText(content){107 $("#text").show();108 $("#textContent").html(content);109}110111/**112 * 弹出策略选择层113 */114function showSelectDiv(divId){115 $('#'+divId).show();116 $('#bg').show();117 $('#popIframe').show();118 $("#video").hide();119}120/**121 * 关闭策略选择层122 */123function closeSelectDiv(divId){124 $('#'+divId).hide();125 $('#bg').hide();126 $('#popIframe').hide();127 if(videoFlag==1){128 $("#video").show();129 } 130}131/**132 * 查看绑定策略详情133 * */134function showPloyInfo(){135 var title = "<td>策略名称</td><td>开始时段</td><td>结束时段</td><td>关联区域</td><td>关联频道</td>";136 $("#ployInfoTitle").html(title);137 var content = "<tr><td>";138 content +=selPloy.name;139 content +="</td><td>";140 content += selPloy.startTime;141 content +="</td><td>";142 content += selPloy.endTime;143 content +="</td>";144 content +=fillAreaChannelInfo(selPloy.areas);145 content +="</tr>"; 146 $("#ployInfoContent").html(content);147 $("#ployInfoName").html("策略");148 $("#plBtn").show();149 $("#preBtn").hide();150 showSelectDiv("ployInfoDiv");151}152153/**154 * 查看绑定精准详情155 * */156function showPreciseInfo(i){ 157 var title = "<td>精准名称</td><td>类型</td><td>产品</td><td>频道</td><td>影片关键字</td><td>用户区域</td>" +158 "<td>行业类别</td><td>用户级别</td><td>TVN号段</td><td>优先级</td><td>节点</td>";159 $("#ployInfoTitle").html(title);160 var content="<tr><td>";161 content +=precises[i].name;162 content +="</td><td>";163 content += getPreciseType(precises[i].type);164 content +="</td><td>";165 content += precises[i].products;166 content +="</td><td>";167 content +=precises[i].channels;168 content +="</td><td>";169 content += precises[i].key;170 content +="</td><td>";171 content += precises[i].userArea;172 content +="</td><td>";173 content +=precises[i].userIndustrys;174 content +="</td><td>";175 content += precises[i].userLevels;176 content +="</td><td>";177 content += precises[i].tvnNumber; ...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

...100 return propType;101}102// This handles more types than `getPropType`. Only used for error messages.103// See `createPrimitiveTypeChecker`.104function getPreciseType(propValue) {105 var propType = getPropType(propValue);106 if (propType === 'object') {107 if (propValue instanceof Date) {108 return 'date';109 } else if (propValue instanceof RegExp) {110 return 'regexp';111 }112 }113 return propType;114}115// Returns class name of the object, if any.116var ANONYMOUS = '<<anonymous>>';117function getClassName(propValue) {118 if (!propValue.constructor || !propValue.constructor.name) {...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...16 return propType;17}18// This handles more types than `getPropType`. Only used for error messages.19// See `createPrimitiveTypeChecker`.20function getPreciseType(propValue) {21 const propType = getPropType(propValue);22 if (propType === 'object') {23 if (propValue instanceof Date) {24 return 'date';25 } else if (propValue instanceof RegExp) {26 return 'regexp';27 }28 }29 return propType;30}31function checkServiceName(propName, fn, serviceName) {32 let result = fn(serviceName);33 if (!(isObject(result) && isString(result.url))) {34 throw new Error(`Invalid props '${propName}' can't configure serviceRegistry for service name '${serviceName}'`)35 }36}37export default function(services) {38 return function(props, propName, componentName) {39 let fn = props[propName];40 if (fn) {41 if (isFunction(fn)) {42 if (Array.isArray(services)) {43 for (let i = 0; i < services.length; i++) {44 checkServiceName(propName, fn, services[i]);45 }46 } else {47 checkServiceName(propName, fn, services);48 }49 } else {50 const preciseType = getPreciseType(fn);51 throw new Error(`Invalid props '${propName}' of type '${preciseType}'52 supplied to '${componentName}', expected 'function'.`);53 }54 } else {55 throw new Error('Required props `' + propName + '` was not specified in ' + ('`' + componentName + '`.'));56 }57 }...

Full Screen

Full Screen

util.js

Source:util.js Github

copy

Full Screen

...6 * LICENSE file in the root directory of this source tree.7 */8// This handles more types than `getType`. Only used for error messages.9// See `createPrimitiveTypeChecker`.10function getPreciseType(propValue) {11 if (typeof propValue === 'undefined' || propValue === null) {12 return '' + propValue13 }14 const propType = getType(propValue)15 if (propType === 'object') {16 if (propValue instanceof Date) {17 return 'date'18 } else if (propValue instanceof RegExp) {19 return 'regexp'20 }21 }22 return propType23}24function isSymbol(propType, propValue) {...

Full Screen

Full Screen

util.test.js

Source:util.test.js Github

copy

Full Screen

...19 assert(getType(new Symbol) === 'symbol')20 Symbol = RealSymbol21 })22})23describe('getPreciseType()', () => {24 it('works', () => {25 assert(getPreciseType([]) === 'array')26 assert(getPreciseType({}) === 'object')27 assert(getPreciseType('') === 'string')28 assert(getPreciseType(() => {}) === 'function')29 assert(getPreciseType(Symbol()) === 'symbol')30 assert(getPreciseType(undefined) === 'undefined')31 assert(getPreciseType(null) === 'null')32 assert(getPreciseType(new Date) === 'date')33 assert(getPreciseType(/hey/) === 'regexp')34 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPreciseType } = require('playwright/lib/utils/stackTrace');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.click('text=Get started');8 await page.click('text=Docs');9 await page.click('text=API');10 await page.click('text=class: BrowserType');11 await page.click('text=launch');12 const preciseType = getPreciseType(page, 'launch', 0);13 console.log(preciseType);14 await browser.close();15})();16Object {17 Object {18 },19 Object {20 },21 Object {22 },23 Object {24 },25 Object {26 },27 Object {28 },29 Object {30 },31 Object {32 },33 Object {34 },35 Object {36 },37 Object {38 },39 Object {40 },41 Object {42 },43 Object {44 },45 Object {46 },47 Object {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPreciseType } = require('playwright/lib/utils/utils');2console.log(getPreciseType({}));3console.log(getPreciseType([]));4console.log(getPreciseType(0));5console.log(getPreciseType(''));6console.log(getPreciseType(null));7console.log(getPreciseType(undefined));8console.log(getPreciseType(true));9console.log(getPreciseType(false));10console.log(getPreciseType(Symbol()));11console.log(getPreciseType(new Date()));12console.log(getPreciseType(/abc/));

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPreciseType } = require('@playwright/test/lib/utils/utils');2const { Page } = require('@playwright/test/lib/server/page');3const { ElementHandle } = require('@playwright/test/lib/server/dom');4const { JSHandle } = require('@playwright/test/lib/server/jsHandle');5const page = new Page();6const elementHandle = new ElementHandle(page, 'elementId');7const jsHandle = new JSHandle(elementHandle, 'object', 'object');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPreciseType } = require('playwright/lib/utils/utils');2console.log(getPreciseType(1));3console.log(getPreciseType('test'));4console.log(getPreciseType({}));5console.log(getPreciseType(null));6console.log(getPreciseType(undefined));

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPreciseType } = require('playwright/lib/utils/utils');2console.log(getPreciseType({ a: 1 }));3console.log(getPreciseType(1));4console.log(getPreciseType('1'));5console.log(getPreciseType(true));6console.log(getPreciseType(null));7console.log(getPreciseType(undefined));8console.log(getPreciseType([]));9console.log(getPreciseType([1, 2, 3]));10console.log(getPreciseType([1, '2', true]));11console.log(getPreciseType({}));12console.log(getPreciseType({ a: 1 }));13console.log(getPreciseType({ a: '1' }));14console.log(getPreciseType({ a: true }));15console.log(getPreciseType({ a: null }));16console.log(getPreciseType({ a: undefined }));17console.log(getPreciseType({ a: [] }));18console.log(getPreciseType({ a: [1, 2, 3] }));19console.log(getPreciseType({ a: [1, '2', true] }));20console.log(getPreciseType({ a: [1, [1, '2', true], true] }));

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPreciseType } = require('playwright/lib/utils/utils');2console.log(getPreciseType({ name: 'John' }));3console.log(getPreciseType(10));4console.log(getPreciseType('John'));5console.log(getPreciseType(null));6console.log(getPreciseType(undefined));7console.log(getPreciseType(true));8console.log(getPreciseType(Symbol('John')));

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPreciseType } = require('playwright/lib/server/dom.js');2const { EventEmitter } = require('events');3const { createJSHandle } = require('playwright/lib/server/JSHandle.js');4const { createExecutionContext } = require('playwright/lib/server/ExecutionContext.js');5const { createFrame } = require('playwright/lib/server/Frame.js');6const { createPage } = require('playwright/lib/server/Page.js');7const { createBrowserContext } = require('playwright/lib/server/BrowserContext.js');8const { createBrowser } = require('playwright/lib/server/Browser.js');9const { createPlaywright } = require('playwright/lib/server/Playwright.js');10const { createConnection } = require('playwright/lib/server/browserType.js');11async function main() {12 const playwright = createPlaywright();13 const browserServer = await playwright.chromium.launchServer();14 const wsEndpoint = browserServer.wsEndpoint();15 const connection = await createConnection(wsEndpoint);16 const browser = await createBrowser(connection, playwright);17 const context = await createBrowserContext(browser, null, {});18 const page = await createPage(context, null, {});19 const frame = await createFrame(page, null, {});20 const executionContext = await createExecutionContext(frame, null, {});21 const eventEmitter = new EventEmitter();22 const result = await createJSHandle(executionContext, eventEmitter, {}, 'Hello World');23 console.log(await getPreciseType(result));24}25main();

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