Best JavaScript code snippet using playwright-internal
projectService.js
Source:projectService.js
...232 this.resetCondition();233 this.reloadData(successCallBack)234 },235 reloadData: function (successCallBack) {236 this.resetCachedData();237 this.loadProjectList(successCallBack);238 },239 resetCachedData: function () {240 this.setPageIndex(0);241 this.setHasNextPage(true);242 this.setProjectList([]);243 },244 resetCondition: function () {245 condition.org = {orgId: 0, orgName: 'ä¸é'};246 condition.cities = [];247 condition.provinces = [];248 condition.provinceText = 'ä¸é';249 condition.contractMode = {Aid: 0, name: 'ä¸é', Bid: 0, AName: ''};250 condition.buildingType = {Aid: 0, name: 'ä¸é', Bid: 0, Cid: 0, AName: '', BName: ''};...
snapshotterInjected.js
Source:snapshotterInjected.js
...28 const kBlobUrlPrefix = 'http://playwright.bloburl/#' // Symbols for our own info on Nodes/StyleSheets.29 const kSnapshotFrameId = Symbol('__playwright_snapshot_frameid_')30 const kCachedData = Symbol('__playwright_snapshot_cache_')31 const kEndOfList = Symbol('__playwright_end_of_list_')32 function resetCachedData(obj) {33 delete obj[kCachedData]34 }35 function ensureCachedData(obj) {36 if (!obj[kCachedData]) obj[kCachedData] = {}37 return obj[kCachedData]38 }39 function removeHash(url) {40 try {41 const u = new URL(url)42 u.hash = ''43 return u.toString()44 } catch (e) {45 return url46 }47 }48 class Streamer {49 // To avoid invalidating due to our own reads.50 constructor() {51 this._removeNoScript = true52 this._lastSnapshotNumber = 053 this._staleStyleSheets = new Set()54 this._readingStyleSheet = false55 this._fakeBase = void 056 this._observer = void 057 this._interceptNativeMethod(58 window.CSSStyleSheet.prototype,59 'insertRule',60 (sheet) => this._invalidateStyleSheet(sheet)61 )62 this._interceptNativeMethod(63 window.CSSStyleSheet.prototype,64 'deleteRule',65 (sheet) => this._invalidateStyleSheet(sheet)66 )67 this._interceptNativeMethod(68 window.CSSStyleSheet.prototype,69 'addRule',70 (sheet) => this._invalidateStyleSheet(sheet)71 )72 this._interceptNativeMethod(73 window.CSSStyleSheet.prototype,74 'removeRule',75 (sheet) => this._invalidateStyleSheet(sheet)76 )77 this._interceptNativeGetter(78 window.CSSStyleSheet.prototype,79 'rules',80 (sheet) => this._invalidateStyleSheet(sheet)81 )82 this._interceptNativeGetter(83 window.CSSStyleSheet.prototype,84 'cssRules',85 (sheet) => this._invalidateStyleSheet(sheet)86 )87 this._interceptNativeMethod(88 window.CSSStyleSheet.prototype,89 'replaceSync',90 (sheet) => this._invalidateStyleSheet(sheet)91 )92 this._interceptNativeAsyncMethod(93 window.CSSStyleSheet.prototype,94 'replace',95 (sheet) => this._invalidateStyleSheet(sheet)96 )97 this._fakeBase = document.createElement('base')98 this._observer = new MutationObserver((list) =>99 this._handleMutations(list)100 )101 const observerConfig = {102 attributes: true,103 subtree: true104 }105 this._observer.observe(document, observerConfig)106 }107 _interceptNativeMethod(obj, method, cb) {108 const native = obj[method]109 if (!native) return110 obj[method] = function (...args) {111 const result = native.call(this, ...args)112 cb(this, result)113 return result114 }115 }116 _interceptNativeAsyncMethod(obj, method, cb) {117 const native = obj[method]118 if (!native) return119 obj[method] = async function (...args) {120 const result = await native.call(this, ...args)121 cb(this, result)122 return result123 }124 }125 _interceptNativeGetter(obj, prop, cb) {126 const descriptor = Object.getOwnPropertyDescriptor(obj, prop)127 Object.defineProperty(obj, prop, {128 ...descriptor,129 get: function () {130 const result = descriptor.get.call(this)131 cb(this, result)132 return result133 }134 })135 }136 _handleMutations(list) {137 for (const mutation of list)138 ensureCachedData(mutation.target).attributesCached = undefined139 }140 _invalidateStyleSheet(sheet) {141 if (this._readingStyleSheet) return142 this._staleStyleSheets.add(sheet)143 }144 _updateStyleElementStyleSheetTextIfNeeded(sheet, forceText) {145 const data = ensureCachedData(sheet)146 if (147 this._staleStyleSheets.has(sheet) ||148 (forceText && data.cssText === undefined)149 ) {150 this._staleStyleSheets.delete(sheet)151 try {152 data.cssText = this._getSheetText(sheet)153 } catch (e) {154 // Sometimes we cannot access cross-origin stylesheets.155 data.cssText = ''156 }157 }158 return data.cssText159 } // Returns either content, ref, or no override.160 _updateLinkStyleSheetTextIfNeeded(sheet, snapshotNumber) {161 const data = ensureCachedData(sheet)162 if (this._staleStyleSheets.has(sheet)) {163 this._staleStyleSheets.delete(sheet)164 try {165 data.cssText = this._getSheetText(sheet)166 data.cssRef = snapshotNumber167 return data.cssText168 } catch (e) {169 // Sometimes we cannot access cross-origin stylesheets.170 }171 }172 return data.cssRef === undefined173 ? undefined174 : snapshotNumber - data.cssRef175 }176 markIframe(iframeElement, frameId) {177 iframeElement[kSnapshotFrameId] = frameId178 }179 reset() {180 this._staleStyleSheets.clear()181 const visitNode = (node) => {182 resetCachedData(node)183 if (node.nodeType === Node.ELEMENT_NODE) {184 const element = node185 if (element.shadowRoot) visitNode(element.shadowRoot)186 }187 for (let child = node.firstChild; child; child = child.nextSibling)188 visitNode(child)189 }190 visitNode(document.documentElement)191 visitNode(this._fakeBase)192 }193 _sanitizeUrl(url) {194 if (url.startsWith('javascript:')) return '' // Rewrite blob urls so that Service Worker can intercept them.195 if (url.startsWith('blob:')) return kBlobUrlPrefix + url196 return url...
Directory.js
Source:Directory.js
...118 }119 this.getView().setMasked({xtype:'loadmask'});120 if(record) {121 this.toggleDisabledOfButton(false);122 this.resetCachedData(record);123 var contactContainer = this.getContactContainer();124 var contactInfoManagement = contactContainer.getItems().items[0];125 126 if(contactInfoManagement.getItemId() !== 'contactInfoManagementPanel') {127 contactContainer.removeAll(true, true);128 contactInfoManagement = this.createContactInfoMangementPanel();129 }130 131 if(record.get('details')) {132 contactInfoManagement.setRecord(record.get('details'));133 this.getView().setMasked(false);134 //cache record to the specified button135 this.setContactInfoData(record.get('details'));136 this.toggleColorOfButtons(this.getContactInformationStaffButton());...
employeeService.js
Source:employeeService.js
...140 this.resetCondition();141 this.reloadData(successCallBack)142 },143 reloadData: function (successCallBack) {144 this.resetCachedData();145 this.loadEmployeeList(successCallBack);146 },147 resetCachedData: function () {148 this.setPageIndex(0);149 this.setHasNextPage(true);150 this.setEmployeeList([]);151 },152 resetCondition: function () {153 condition.isInsured = -1,154 condition.sex = -1,155 condition.realName = '',156 condition.org = {orgId: 0, orgName: 'ä¸é'},157 condition.telephone = '';158 return condition;...
ConversationState.js
Source:ConversationState.js
1// @@@LICENSE2//3// Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.4//5// Licensed under the Apache License, Version 2.0 (the "License");6// you may not use this file except in compliance with the License.7// You may obtain a copy of the License at8//9// http://www.apache.org/licenses/LICENSE-2.010//11// Unless required by applicable law or agreed to in writing, software12// distributed under the License is distributed on an "AS IS" BASIS,13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14// See the License for the specific language governing permissions and15// limitations under the License.16//17// LICENSE@@@18enyo.kind({19 name: "ConversationState",20 kind: "enyo.Object",21 constructor: function (data) {22 // FIXME use constants23 this.data = data || { _kind: "com.palm.email.conversation:1", count: 0, flags: {read: true}, attributes: {} };24 this.changedProps = data ? {} : { _kind: true, count: true, flags: true };25 this.newEmailIds = [];26 this.deletedEmailIds = [];27 },28 // Set the property to a default value *iff* it was present.29 // This way, when the subobject is written to the database the value will be overwritten.30 // If the property wasn't set before, leave it alone so we don't waste database space.31 resetProps: function (obj, props, defaultValue) {32 var i;33 for (i = 0; i < props.length; i += 1) {34 var prop = props[i];35 if (typeof obj[prop] !== 'undefined') {36 obj[prop] = defaultValue;37 }38 }39 },40 // reset conversation data and repopulate it from the emails41 // almost all properties should be reset here, except messageIds42 resetCachedData: function () {43 this.data.count = 0;44 this.data.flags = this.data.flags || {};45 // Always update read status46 this.data.flags.read = true;47 // Set default value of other flags to false48 this.resetProps(this.data.flags, ["flagged", "replied", "forwarded"], false);49 // Cleanup attributes50 this.data.attributes = this.data.attributes || {};51 this.resetProps(this.data.attributes, ["hasMeetingInfo"], false);52 this.data.folderKeys = [];53 this.data.timestamp = undefined;54 this.data.emailIds = [];55 this.data.senders = [];56 if (this.data.priority) {57 this.data.priority = "";58 this.changedProps.priority = true;59 }60 },61 62 addToResultsSet: function (items, hash) {63 if (!items) {64 return;65 }66 67 for (var i = 0; i < items.length; i += 1) {68 var item = items[i];69 70 if (hash[item]) {71 hash[item].push(this);72 } else {73 hash[item] = [this];74 }75 }76 },77 addToResults: function (convResultsHash, key) {78 var i;79 var convResults = convResultsHash[key] ||80 { messageIdHash: {}, threadTopicHash: {}, serverConversationIds: {} };81 82 this.addToResultsSet(this.data.messageIds, convResults.messageIdHash);83 this.addToResultsSet(this.data.threadTopics, convResults.threadTopicHash);84 this.addToResultsSet(this.data.serverConversationIds, convResults.serverConversationIdHash);85 convResultsHash[key] = convResults;86 },87 addToList: function (propName, data) {88 if (!data || data === "") {89 return;90 }91 var list = this.data[propName];92 if (!list) {93 list = this.data[propName] = [];94 }95 // Only add if not already in the list96 if (list.indexOf(data) === -1) {97 list.push(data);98 this.changedProps[propName] = true;99 }100 },101 setAccountId: function (accountId) {102 this.data.accountId = accountId;103 this.changedProps.accountId = true;104 },105 setFolderId: function (folderId) {106 this.data.folderId = folderId;107 this.changedProps.folderId = true;108 },109 110 getAccountId: function () {111 return this.data.accountId;112 },113 114 getFolderId: function () {115 return this.data.folderId;116 },117 insertSender: function (senders, newSender, newTimestamp, isOutbound) {118 var pos;119 // Remove sender from existing list120 senders = senders.filter(function (sender) {121 return sender.addr !== newSender.addr;122 });123 // Add sender to correct position according to timestamp124 // Ordered from newest to oldest125 for (pos = 0; pos < senders.length; pos += 1) {126 if (senders[pos].timestamp < newTimestamp) {127 break;128 }129 }130 var sender = {131 name: newSender.name,132 addr: newSender.addr,133 timestamp: newTimestamp134 };135 136 if (isOutbound) {137 sender.isOutbound = true;138 }139 senders.splice(pos, 0, sender);140 return senders;141 },142 addSender: function (newSender, newTimestamp, isOutbound) {143 this.data.senders = this.insertSender(this.data.senders || [], newSender, newTimestamp, isOutbound);144 this.changedProps.senders = true;145 },146 addFolderKey: function (folderKey) {147 this.addToList("folderKeys", folderKey);148 },149 addEmail: function (email, isNewEmail) {150 var i;151 var accountId = enyo.application.folderProcessor.getFolderAccount(email.folderId);152 var account = accountId && enyo.application.accounts.getAccount(accountId);153 //this.log("adding email " + email.subject);154 // Timestamp/summary taken from newest email155 if (!this.data.timestamp || email.timestamp >= this.data.timestamp) {156 this.data.timestamp = email.timestamp;157 this.data.summary = email.summary;158 this.changedProps.timestamp = true;159 this.changedProps.summary = true;160 }161 // Subject taken from oldest email162 if (!this.data.earliestTimestamp || email.timestamp <= this.data.earliestTimestamp) {163 this.data.earliestTimestamp = email.timestamp;164 this.data.subject = email.subject;165 this.changedProps.earliestTimestamp = true;166 this.changedProps.subject = true;167 }168 // Add sender169 if (email.from) {170 this.addSender(email.from, email.timestamp);171 }172 173 // For outgoing emails, add recipients174 if (email.to && account && account.isOutgoingFolderId(email.folderId)) {175 enyo.forEach(email.to, function (recipient) {176 this.addSender(recipient, email.timestamp+1, true);177 }, this);178 }179 // Increment count180 this.data.count = this.data.count + 1;181 this.changedProps.count = true;182 // Update flags183 var emailFlags = email.flags || {};184 this.changedProps.flags = true;185 this.changedProps.attributes = true;186 if (!emailFlags.read) {187 this.data.flags.read = false;188 }189 if (emailFlags.replied) {190 this.data.flags.replied = true;191 }192 if (emailFlags.forwarded) {193 this.data.flags.forwarded = true;194 }195 if (emailFlags.flagged) {196 this.data.flags.flagged = true;197 }198 if (email.meetingInfo) {199 this.data.attributes.hasMeetingInfo = true;200 }201 if (email.sendStatus && email.sendStatus.error && email.sendStatus.error.errorCode) {202 this.data.attributes.hasError = true;203 this.changedProps.hasError = true;204 }205 // Update priority206 if (this.data.priority === "high") {207 // high is never replaced208 this.changedProps.priority = false;209 } else if (this.data.priority === "low") {210 // low is overwritten by anything211 this.data.priority = email.priority || "";212 this.changedProps.priority = true;213 } else if (email.priority === "high") {214 // normal is overwritten by high215 this.data.priority = email.priority;216 this.changedProps.priority = true;217 }218 // Add hasAttachment attribute219 if (email.parts) {220 for (i = 0; i < email.parts.length; i += 1) {221 if (email.parts[i].type === "attachment") {222 this.data.attributes.hasAttachment = true;223 this.changedProps.attributes = true;224 break;225 }226 }227 }228 // Add folders229 this.updateFolderKeys(accountId, email);230 // FIXME -- should just query for emails by conversationId instead of storing it here231 this.addToList("emailIds", email._id);232 // Only if the email isn't part of this conversation233 if (isNewEmail) {234 // Set accountId235 //this.data.accountId = accountId;236 //this.changedProps.accountId = true;237 // Add messageId and references238 if (email.messageId || email.inReplyTo || email.references) {239 this.addToList("messageIds", email.messageId);240 this.addToList("messageIds", email.inReplyTo);241 var self = this;242 var mids = this.data.messageIds || [];243 if (email.references) {244 email.references.forEach(function (messageId) {245 self.addToList("messageIds", messageId);246 });247 }248 this.data.messageIds = mids;249 }250 // Add serverConversationId251 this.addToList("serverConversationIds", email.serverConversationId);252 // Add conversation topic based on subject253 if (email.threadTopic) {254 this.addToList("threadTopics", email.threadTopic);255 } else if (email.subject && email.subject.length > 0) {256 // Strip re: and similar from subject257 var stripped = EmailProcessorUtils.stripSubject(email.subject);258 this.addToList("threadTopics", stripped);259 }260 this.newEmailIds.push(email._id);261 }262 },263 deleteEmail: function (email) {264 this.deletedEmailIds.push(email._id);265 },266 updateFolderKeys: function (accountId, email) {267 var account = enyo.application.accounts.getAccount(accountId);268 this.data.folderKeys = this.data.folderKeys || [];269 // Add folder270 this.addFolderKey(email.folderId);271 // Folder keys that shouldn't apply to emails in the trash272 if (!account || account.getTrashFolderId() !== email.folderId) {273 this.addFolderKey("#NONTRASH#");274 // Add aggregate folders275 if (account && account.getInboxFolderId() === email.folderId) {276 this.addFolderKey("#INBOXES#");277 }278 if (email.flags && email.flags.flagged) {279 this.addFolderKey("#FLAGGED#");280 }281 // TODO: virtual folders?282 }283 this.changedProps.folderKeys = true;284 },285 setId: function (id) {286 this.data._id = id;287 },288 getId: function () {289 return this.data._id;290 },291 getEmailCount: function () {292 return this.data.count;293 },294 // Get changes relevant to this conversation and append them to the changes array295 appendChanges: function (changes) {296 var i;297 var changedKeys = Object.keys(this.changedProps);298 if (changedKeys.length > 0 || this.data.count === 0) {299 var myChanges = { _id: this.data._id };300 for (i = 0; i < changedKeys.length; i += 1) {301 var key = changedKeys[i];302 myChanges[key] = this.data[key];303 }304 // Handle deleted conversations305 if (this.data.count === 0) {306 myChanges._del = true;307 }308 // Merge the updated conversation309 changes.push(myChanges);310 }311 if (this.newEmailIds.length) {312 // Add conversationId to each of the new emails313 for (i = 0; i < this.newEmailIds.length; i += 1) {314 changes.push({_id: this.newEmailIds[i], conversationId: this.data._id});315 }316 }317 if (this.deletedEmailIds.length) {318 // Remove conversationId from emails319 for (i = 0; i < this.deletedEmailIds.length; i += 1) {320 changes.push({_id: this.deletedEmailIds[i], conversationId: null});321 }322 }323 }...
StylesSectionModel.js
Source:StylesSectionModel.js
1// Copyright (c) 2014 The Chromium Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4/**5 * @constructor6 * @param {!WebInspector.SectionCascade} cascade7 * @param {?WebInspector.CSSRule} rule8 * @param {!WebInspector.CSSStyleDeclaration} style9 * @param {string} customSelectorText10 * @param {?WebInspector.DOMNode=} inheritedFromNode11 */12WebInspector.StylesSectionModel = function(cascade, rule, style, customSelectorText, inheritedFromNode)13{14 this._cascade = cascade;15 this._rule = rule;16 this._style = style;17 this._customSelectorText = customSelectorText;18 this._editable = !!(this._style && this._style.styleSheetId);19 this._inheritedFromNode = inheritedFromNode || null;20}21WebInspector.StylesSectionModel.prototype = {22 /**23 * @return {!WebInspector.SectionCascade}24 */25 cascade: function()26 {27 return this._cascade;28 },29 /**30 * @return {boolean}31 */32 hasMatchingSelectors: function()33 {34 return this.rule() ? this.rule().matchingSelectors.length > 0 && this.mediaMatches() : true;35 },36 /**37 * @return {boolean}38 */39 mediaMatches: function()40 {41 var media = this.media();42 for (var i = 0; media && i < media.length; ++i) {43 if (!media[i].active())44 return false;45 }46 return true;47 },48 /**49 * @return {boolean}50 */51 inherited: function()52 {53 return !!this._inheritedFromNode;54 },55 /**56 * @return {?WebInspector.DOMNode}57 */58 parentNode: function()59 {60 return this._inheritedFromNode;61 },62 /**63 * @return {string}64 */65 selectorText: function()66 {67 if (this._customSelectorText)68 return this._customSelectorText;69 return this.rule() ? this.rule().selectorText() : "";70 },71 /**72 * @return {boolean}73 */74 editable: function()75 {76 return this._editable;77 },78 /**79 * @param {boolean} editable80 */81 setEditable: function(editable)82 {83 this._editable = editable;84 },85 /**86 * @return {!WebInspector.CSSStyleDeclaration}87 */88 style: function()89 {90 return this._style;91 },92 /**93 * @return {?WebInspector.CSSRule}94 */95 rule: function()96 {97 return this._rule;98 },99 /**100 * @return {?Array.<!WebInspector.CSSMedia>}101 */102 media: function()103 {104 return this.rule() ? this.rule().media : null;105 },106 resetCachedData: function()107 {108 this._cascade._resetUsedProperties();109 },110 /**111 * @param {string} propertyName112 * @return {boolean}113 */114 isPropertyInCascade: function(propertyName)115 {116 if (!this.hasMatchingSelectors())117 return false;118 if (this.inherited() && !WebInspector.CSSMetadata.isPropertyInherited(propertyName))119 return false;120 return true;121 },122 /**123 * @param {string} propertyName124 * @return {boolean}125 */126 isPropertyOverloaded: function(propertyName)127 {128 if (!this.isPropertyInCascade(propertyName))129 return false;130 var usedProperties = this._cascade._usedPropertiesForModel(this);131 var canonicalName = WebInspector.CSSMetadata.canonicalPropertyName(propertyName);132 return !usedProperties.has(canonicalName);133 }134}135/**136 * @constructor137 */138WebInspector.SectionCascade = function()139{140 this._models = [];141 this._resetUsedProperties();142}143WebInspector.SectionCascade.prototype = {144 /**145 * @return {!Array.<!WebInspector.StylesSectionModel>}146 */147 sectionModels: function()148 {149 return this._models;150 },151 /**152 * @param {!WebInspector.CSSRule} rule153 * @param {!WebInspector.StylesSectionModel} insertAfterStyleRule154 * @return {!WebInspector.StylesSectionModel}155 */156 insertModelFromRule: function(rule, insertAfterStyleRule)157 {158 return this._insertModel(new WebInspector.StylesSectionModel(this, rule, rule.style, "", null), insertAfterStyleRule);159 },160 /**161 * @param {!WebInspector.CSSStyleDeclaration} style162 * @param {string} selectorText163 * @param {?WebInspector.DOMNode=} inheritedFromNode164 * @return {!WebInspector.StylesSectionModel}165 */166 appendModelFromStyle: function(style, selectorText, inheritedFromNode)167 {168 return this._insertModel(new WebInspector.StylesSectionModel(this, style.parentRule, style, selectorText, inheritedFromNode));169 },170 /**171 * @return {!Set.<string>}172 */173 allUsedProperties: function()174 {175 this._recomputeUsedPropertiesIfNeeded();176 return this._allUsedProperties;177 },178 /**179 * @param {!WebInspector.StylesSectionModel} model180 * @param {!WebInspector.StylesSectionModel=} insertAfter181 * @return {!WebInspector.StylesSectionModel}182 */183 _insertModel: function(model, insertAfter)184 {185 if (insertAfter) {186 var index = this._models.indexOf(insertAfter);187 console.assert(index !== -1, "The insertAfter anchor could not be found in cascade");188 this._models.splice(index + 1, 0, model);189 } else {190 this._models.push(model);191 }192 this._resetUsedProperties();193 return model;194 },195 _recomputeUsedPropertiesIfNeeded: function()196 {197 if (this._usedPropertiesPerModel.size > 0)198 return;199 var usedProperties = WebInspector.SectionCascade._computeUsedProperties(this._models, this._allUsedProperties);200 for (var i = 0; i < usedProperties.length; ++i)201 this._usedPropertiesPerModel.set(this._models[i], usedProperties[i]);202 },203 _resetUsedProperties: function()204 {205 /** @type {!Set.<string>} */206 this._allUsedProperties = new Set();207 /** @type {!Map.<!WebInspector.StylesSectionModel, !Set.<string>>} */208 this._usedPropertiesPerModel = new Map();209 },210 /**211 * @param {!WebInspector.StylesSectionModel} model212 * @return {!Set.<string>}213 */214 _usedPropertiesForModel: function(model)215 {216 this._recomputeUsedPropertiesIfNeeded();217 return /**@type {!Set.<string>}*/ (this._usedPropertiesPerModel.get(model));218 }219}220/**221 * @param {!Array.<!WebInspector.StylesSectionModel>} styleRules222 * @param {!Set.<string>} allUsedProperties223 * @return {!Array.<!Set.<string>>}224 */225WebInspector.SectionCascade._computeUsedProperties = function(styleRules, allUsedProperties)226{227 /** @type {!Set.<string>} */228 var foundImportantProperties = new Set();229 /** @type {!Map.<string, !Set.<string>>} */230 var propertyToEffectiveRule = new Map();231 /** @type {!Map.<string, !WebInspector.DOMNode>} */232 var inheritedPropertyToNode = new Map();233 var stylesUsedProperties = [];234 for (var i = 0; i < styleRules.length; ++i) {235 var styleRule = styleRules[i];236 /** @type {!Set.<string>} */237 var styleRuleUsedProperties = new Set();238 stylesUsedProperties.push(styleRuleUsedProperties);239 if (!styleRule.hasMatchingSelectors())240 continue;241 var style = styleRule.style();242 var allProperties = style.allProperties;243 for (var j = 0; j < allProperties.length; ++j) {244 var property = allProperties[j];245 if (!property.activeInStyle())246 continue;247 // Do not pick non-inherited properties from inherited styles.248 if (styleRule.inherited() && !WebInspector.CSSMetadata.isPropertyInherited(property.name))249 continue;250 var canonicalName = WebInspector.CSSMetadata.canonicalPropertyName(property.name);251 if (foundImportantProperties.has(canonicalName))252 continue;253 if (!property.important && allUsedProperties.has(canonicalName))254 continue;255 var isKnownProperty = propertyToEffectiveRule.has(canonicalName);256 var parentNode = styleRule.parentNode();257 if (!isKnownProperty && parentNode && !inheritedPropertyToNode.has(canonicalName))258 inheritedPropertyToNode.set(canonicalName, parentNode);259 if (property.important) {260 if (styleRule.inherited() && isKnownProperty && styleRule.parentNode() !== inheritedPropertyToNode.get(canonicalName))261 continue;262 foundImportantProperties.add(canonicalName);263 if (isKnownProperty)264 propertyToEffectiveRule.get(canonicalName).delete(canonicalName);265 }266 styleRuleUsedProperties.add(canonicalName);267 allUsedProperties.add(canonicalName);268 propertyToEffectiveRule.set(canonicalName, styleRuleUsedProperties);269 }270 // If every longhand of the shorthand is not active, then the shorthand is not active too.271 for (var property of style.leadingProperties()) {272 var canonicalName = WebInspector.CSSMetadata.canonicalPropertyName(property.name);273 if (!styleRuleUsedProperties.has(canonicalName))274 continue;275 var longhands = style.longhandProperties(property.name);276 if (!longhands.length)277 continue;278 var notUsed = true;279 for (var longhand of longhands) {280 var longhandCanonicalName = WebInspector.CSSMetadata.canonicalPropertyName(longhand.name);281 notUsed = notUsed && !styleRuleUsedProperties.has(longhandCanonicalName);282 }283 if (!notUsed)284 continue;285 styleRuleUsedProperties.delete(canonicalName);286 allUsedProperties.delete(canonicalName);287 }288 }289 return stylesUsedProperties;...
books.js
Source:books.js
...135 136 // Set data to Redis137 client.setex(updated_isbn, 3600, JSON.stringify(book))138 139 resetCachedData()140 141 const message = { "success" : "book updated.." }142 return res.end(JSON.stringify(message));143 } catch {144 const message = { "success" : "input error, check all the fields.." }145 return res.end(JSON.stringify(message));146 }147 } else {148 const message = { "success" : error_message }149 return res.end(JSON.stringify(message)); 150 }151})152router.delete('/', async (req, res) => { 153 const requested_isbn = req.body.isbn154 await Book.destroy({ where: { isbn: requested_isbn } })155 resetCachedData()156 const message = { "success" : "book removed.." }157 return res.end(JSON.stringify(message));158})...
employeeListController.js
Source:employeeListController.js
...65 $scope.hasNextPage = true;66 //è¿åæ¶,æ¸
é¤æç´¢æ¡ä»¶67 $scope.back = function () {68 employeeService.resetCondition();69 employeeService.resetCachedData();70 $state.go('market-management');71 };72 //å页å è½½73 $scope.loadListData = function () {74 employeeService.loadEmployeeList(function () {75 $scope.fillData();76 $scope.$broadcast('scroll.infiniteScrollComplete');77 });78 };79 $scope.fillData = function () {80 $scope.employeeList = employeeService.getEmployeeList();81 $scope.hasNextPage = employeeService.hasNextPage();82 };83 //å®ç°æ¨¡ç³æ¥è¯¢...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const page = await browser.newPage();5 await page.screenshot({ path: 'example.png' });6 await page.context().resetCachedData();7 await page.close();8 await browser.close();9})();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext({ acceptDownloads: false });5 const page = await context.newPage();6 await page.close();7 await context.close();8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext({ acceptDownloads: false });14 const page = await context.newPage();15 await page.close();16 await context.close();17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext({ acceptDownloads: false });23 const page = await context.newPage();24 await page.close();25 await context.close();26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext({ acceptDownloads: false });32 const page = await context.newPage();33 await page.close();34 await context.close();35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext({ acceptDownloads: false });41 const page = await context.newPage();42 await page.close();43 await context.close();44 await browser.close();45})();46const { chromium } = require('playwright');47(async () => {48 const browser = await chromium.launch();49 const context = await browser.newContext({ accept
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 await browser.resetCachedData();5 await browser.close();6})();7const { chromium } = require('playwright');8(async () => {9 const browser = await chromium.launch();10 await browser.resetCachedData();11 await browser.close();12})();13const { chromium } = require('playwright');14(async () => {15 const browser = await chromium.launch();16 await browser.resetCachedData();17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 await browser.resetCachedData();23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 await browser.resetCachedData();29 await browser.close();30})();31const { chromium } = require('playwright');32(async () => {33 const browser = await chromium.launch();34 await browser.resetCachedData();35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 await browser.resetCachedData();41 await browser.close();42})();43const { chromium } = require('playwright');44(async () => {45 const browser = await chromium.launch();46 await browser.resetCachedData();47 await browser.close();48})();49const { chromium } = require('playwright');50(async () => {const { chromium } = require('playwright');51 const browser = await (hramium.lausch();52 await browser.resetCachedData();53 await browser.cloye();54})();55const { chromium } = require(' () => {');56(async() >{57 const bowsr = await chromium.launch();58 await browser.resetCachedData();
Using AI Code Generation
1 const browser = await chromium.launch();2 await browser.resetCachedData();3 await browser.close();4})();5const { chromium } = require('playwright');6(async () => {7 const browser = await chromium.launch();8 await browser.resetCachedData();9 await browser.close();10})();11const { chromium } = require('playwright');12(async () => {13 const browser = await chromium.launch();14 await browser.resetCachedData();15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch();20 await browser.resetCachedData();21 await browser.close();22})();23const { chromium } = require('playwright');24(async () => {25 const browser = await chromium.launch();26 await browser.resetCachedData();27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch();32 await browser.resetCachedData();33 await browser.close();34})();35const { chromium } = require('playwright');36(async () => {37 const browser = await chromium.launch();38 await browser.resetCachedData();39 await browser.close();40})();41const { chromium } = require('playwright');42(async () => {43 const browser = await chromium.launch();44 await browser.resetCachedData();45 await browser.close();46})();47const { chromium } = require('playwright');48(async () => {49 const browser = await chromium.launch();50 await browser.resetCachedData();51 await browser.close();52})();
Using AI Code Generation
1const playwright = require("playwright");2const { chromium } = playwright;3(async () => {4 const browser = await chromium.launch();5 await browser.close();6 await browser._initializer.resetCachedData();7})();8const { chromium } = require('playwright');9(async () => {10 const browser = await chromium.launch();11 await browser.resetCachedData();
Using AI Code Generation
1const playwright = require('playwright');2const chromium = playwright.chromium;3const path = require('path');4(async () => {5 const browser = await chromium.launch({ headless: false });6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.screenshot({ path: path.join(__dirname, 'example.png') });9 await browser.close();10})();11const playwright = require('playwright');12const chromium = playwright.chromium;13const path = require('path');14(async () => {15 const browser = await chromium.launch({ headless: false });16 const context = await browser.newContext();17 const page = await context.newPage();18 await page.screenshot({ path: path.join(__dirname, 'example.png') });19 await browser.close();20})();21const playwright = require('playwright');22const chromium = playwright.chromium;23const path = require('path');24(async () => {25 const browser = await chromium.launch({ headless: false });26 const context = await browser.newContext();27 const page = await context.newPage();28 await page.screenshot({ path: path.join(__dirname, 'example.png') });29 await browser.close();30})();
Using AI Code Generation
1const playwright = require('playwright');2const { chromium } = playwright;3const browser = await chromium.launch();4const context = await browser.newContext();5await context._loadDefaultContextModule('resetCachedData');6await context.resetCachedData();7await browser.close();
Using AI Code Generation
1const playwright = require("playwright");2const { chromium } = playwright;3(async () => {4 const browser = await chromium.launch();5 await browser.close();6 await browser._initializer.resetCachedData();7})();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launchPersistentContext('/tmp/my-profile', {4 });5 const page = await browser.newPage();6 await browser.close();7})();8const { chromium } = require('playwright');9(async () => {10 const browser = await chromium.launchPersistentContext('/tmp/my-profile', {11 });12 const page = await browser.newPage();13 await browser.close();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launchPersistentContext('/tmp/my-profile', {18 });19 const page = await browser.newPage();20 await browser.close();21})();22const { chromium } = require('playwright');23(async () => {24 const browser = await chromium.launchPersistentContext('/tmp/my-profile', {25 });26 const page = await browser.newPage();27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launchPersistentContext('/tmp/my-profile', {32 });33 const page = await browser.newPage();34 await browser.close();35})();
Using AI Code Generation
1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 await browser.resetCachedData();5 await browser.close();6})();7* browser(webkit): fix crash on macOS 11.6 ([#8508](
Using AI Code Generation
1const playwright = require('playwright');2(async () => {3 await playwright.chromium.resetCachedData();4})();5const playwright = require('playwright');6(async () => {7 await playwright.chromium.resetBrowserData();8})();9const playwright = require('playwright');10(async () => {11 await playwright.chromium.resetProfile();12})();13const playwright = require('playwright');14(async () => {15 await playwright.chromium.resetExecutable();16})();17const playwright = require('playwright');18(async () => {19 await playwright.chromium.resetBrowser();20})();21const playwright = require('playwright');22(async () => {23 await playwright.chromium.resetBrowser();24})();
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.
Get 100 minutes of automation test minutes FREE!!