Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lc2

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lc2 - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

src/util.js

2

lib/collector.js
/*jslint vars: true, sloppy: true, nomen: true */
/*global now: false, _, instructions */
var _ = require('../src/global')['_'];
var _ = require('../src/util');

@@ -6,0 +6,0 @@ //1_SYSTEM 2_USER -1_ERROR 0_NOTICE

{
"name": "lc2",
"version": "1.3.0",
"version": "1.3.1",
"description": "browser automation library",

@@ -17,5 +17,5 @@ "main": "index.js",

"dist/",
"lib",
"src/",
"index.js"
"lib",
"src/",
"index.js"
],

@@ -29,3 +29,3 @@ "keywords": [

"author": "李超",
"license": "MIT",
"license": "GPL-2.0",
"devDependencies": {

@@ -32,0 +32,0 @@ "angular": "^1.5.3",

[![Build Status](https://travis-ci.org/or-change/lemoncase2.svg?branch=develop)](https://travis-ci.org/or-change/lemoncase2)
[![Coverage Status](https://coveralls.io/repos/github/or-change/lemoncase2/badge.svg?branch=develop)](https://coveralls.io/github/or-change/lemoncase2?branch=develop)

@@ -3,0 +4,0 @@ #lemoncase2

/*jslint vars: true, sloppy: true, nomen: true */
/*global require, console, trigger, module */
var $CP = require('./case').$CP,
_ = require('../util'),
global = require('../global'),
_ = global['_'],
settings = global.settings,
getDocument = global.getDocument,
IF = require('./instruction'),
CALL = require('../instructionType').CALL;
function countDOM(cssPath) {
return getDocument().querySelectorAll(cssPath).length;
}
function getInnerHTML(cssPath) {
var DOM = getDocument().querySelector(cssPath);
if (DOM) {
if (DOM.value) {
if (DOM.type === 'checkbox' || DOM.type === 'radio') {
return DOM.checked;
}
return DOM.value;
}
return DOM.innerHTML;
}
return false;
}
function isVisible(cssPath) {
var DOM = getDocument().querySelector(cssPath);
if (!DOM) {
return false;
}
return (DOM.offsetHeight === 0 && DOM.offsetWidth === 0) ? false : true;
}
function match(src, obj) {
if (!_.isString(src)) {
return false;
}
if (_.isString(obj)) {
return src.indexOf(obj) !== -1;
}
if (obj.test) {
return obj.test(src);
}
return false;
}
$CP.$setIdleTask = function (taskFn) {

@@ -107,3 +151,3 @@ this.$$idleTask = _.isFunction(taskFn) ? taskFn : _.noop;

return expFn(this.$$vars, this.$objectList, this.$loopData,
_.countDOM, _.getInnerHTML, _.isVisible, _.match);
countDOM, getInnerHTML, isVisible, match);
}

@@ -110,0 +154,0 @@ return expFn;

/*jslint plusplus: true, sloppy: true, nomen: true */
/*global require, console, trigger, module */
var CALL = require('../instructionType').CALL,
EXIT = require('../instructionType').EXIT,
global = require('../global'),
_ = global['_'],
settings = global.settings,
var instructionType = require('../instructionType'),
CALL = instructionType.CALL,
EXIT = instructionType.EXIT,
_ = require('../util'),
settings = require('../global').settings,
Collector = require('../../lib/collector'),

@@ -9,0 +9,0 @@ IF = require('./instruction');

@@ -31,3 +31,3 @@ /*jslint vars: true, sloppy: true, nomen: true */

*/
var _ = require('../global')['_'];
var _ = require('../util');

@@ -34,0 +34,0 @@ function Dictionary(options) {

/*jslint vars: true, sloppy: true, nomen: true */
/*global require, console, trigger, module */
var callMainIns, exitIns, _, settings, setup;
var callMainIns, exitIns, settings, setup,
_ = require('./util');
_ = {
now: Date.now || function () {
return new Date().getTime();
},
isString: function (string) {
return typeof string === 'string';
},
isUndefined: function (value) {
return value === void 0;
},
isDefined: function (value) {
return !_.isUndefined(value);
},
isNumber: function (value) {
return typeof value === 'number';
},
isObject: function (obj) {
var type = typeof obj;
return type === 'function' || (type === 'object' && !!obj);
},
isElement: function (obj) {
return !!(obj && obj.nodeType === 1);
},
isFunction: function (obj) {
return typeof obj === 'function';
},
isArray: function (obj) {
return ({}).toString.call(obj) === '[object Array]';
},
last: function (array) {
return array[array.length - 1];
},
noop: function () {},
forEach: function (obj, iteratee, context) {
iteratee = iteratee.bind(context);
var i, length;
if (this.isArray(obj)) {
for (i = 0, length = obj.length; i < length; i += 1) {
iteratee(obj[i], i, obj);
}
} else {
var keys = Object.keys(obj);
for (i = 0, length = keys.length; i < length; i += 1) {
iteratee(obj[keys[i]], keys[i], obj);
}
}
return obj;
},
document: function () {
if (settings.contextFrame) {
return settings.contextFrame.contentWindow.document;
}
return document;
},
countDOM: function (cssPath) {
return _.document().querySelectorAll(cssPath).length;
},
getInnerHTML: function (cssPath) {
var DOM = _.document().querySelector(cssPath);
if (DOM) {
if (DOM.value) {
if (DOM.type === 'checkbox' || DOM.type === 'radio') {
return DOM.checked;
}
return DOM.value;
}
return DOM.innerHTML;
}
return false;
},
isVisible: function (cssPath) {
var DOM = _.document().querySelector(cssPath);
if (!DOM) {
return false;
}
return (DOM.offsetHeight === 0 && DOM.offsetWidth === 0) ? false : true;
},
match: function (src, obj) {
if (!_.isString(src)) {
return false;
}
if (_.isString(obj)) {
return !!src.indexOf(obj);
}
if (obj.test) {
return obj.test(src);
}
return false;
}
};
settings = {

@@ -147,5 +53,13 @@ contextFrame: document.createElement('iframe'),

function getDocument() {
if (settings.contextFrame) {
return settings.contextFrame.contentWindow.document;
}
return document;
}
module.exports = {
'_': _,
settings: settings,
getDocument: getDocument,
setup: setup,

@@ -152,0 +66,0 @@ init: init,

@@ -6,3 +6,4 @@ /*jslint sloppy: true, nomen: true */

settings = global.settings,
_ = global['_'],
getDocument = global.getDocument,
_ = require('./util'),

@@ -113,3 +114,3 @@ instructionType = require('./instructionType'),

try {
DOM = _.document().querySelectorAll(cssPath)[0];
DOM = getDocument().querySelectorAll(cssPath)[0];
if (!DOM) {

@@ -203,3 +204,3 @@ throw 'Can not find a DOM by cssPath: ' + cssPath;

operation: function Refresh() {
_.document().location.reload();
getDocument().location.reload();
this.$case.$pushLog([REFRESH], this.line());

@@ -206,0 +207,0 @@ }

@@ -1,2 +0,2 @@

var has = require('./util').has;
var has = require('../util').has;

@@ -3,0 +3,0 @@ var defaultOptions = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc