Merge branch 'master' of https://github.com/MozillaSecurity/octo
This commit is contained in:
commit
c5824a4083
11 changed files with 76 additions and 24 deletions
|
@ -61,7 +61,7 @@ var logger = (function () { // eslint-disable-line no-unused-vars
|
||||||
}
|
}
|
||||||
|
|
||||||
function comment (msg) {
|
function comment (msg) {
|
||||||
dumpln('/* ' + msg + ' */')
|
dumpln('/*L*/ // ' + msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
function separator () {
|
function separator () {
|
||||||
|
|
|
@ -5,10 +5,13 @@
|
||||||
make.arrays = {
|
make.arrays = {
|
||||||
filledArray: function (fn, limit) {
|
filledArray: function (fn, limit) {
|
||||||
let array = []
|
let array = []
|
||||||
let size = limit || random.number(make.number.tiny)
|
let size = limit || random.number(make.number.tiny()) + 1
|
||||||
|
|
||||||
for (let i = 0; i < size; i++) {
|
for (let i = 0; i < size; i++) {
|
||||||
array.push(random.pick(fn))
|
let value = random.pick(fn)
|
||||||
|
if (value !== undefined) {
|
||||||
|
array.push(value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array
|
return array
|
||||||
|
|
|
@ -6,32 +6,32 @@ make.command = {
|
||||||
_data: {
|
_data: {
|
||||||
'backcolor': function () { return make.colors.any() },
|
'backcolor': function () { return make.colors.any() },
|
||||||
'bold': null,
|
'bold': null,
|
||||||
'contentReadOnly': function () { random.bool() },
|
'contentReadOnly': function () { return random.bool() },
|
||||||
'copy': null,
|
'copy': null,
|
||||||
'createlink': function () { make.uri.any() },
|
'createlink': function () { return make.uri.any() },
|
||||||
'cut': null,
|
'cut': null,
|
||||||
'decreasefontsize': null,
|
'decreasefontsize': null,
|
||||||
'delete': null,
|
'delete': null,
|
||||||
'enableInlineTableEditing': function () { random.bool() },
|
'enableInlineTableEditing': function () { return random.bool() },
|
||||||
'enableObjectResizing': function () { random.bool() },
|
'enableObjectResizing': function () { return random.bool() },
|
||||||
'fontname': function () { make.font.family() },
|
'fontname': function () { return make.font.family() },
|
||||||
'fontsize': function () { make.font.relativeSize() },
|
'fontsize': function () { return make.font.relativeSize() },
|
||||||
'formatblock': ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'pre', 'address', 'blockquote', 'dl', 'div'],
|
'formatblock': ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'pre', 'address', 'blockquote', 'dl', 'div'],
|
||||||
'forwarddelete': null,
|
'forwarddelete': null,
|
||||||
'forecolor': function () { make.colors.any() },
|
'forecolor': function () { return make.colors.any() },
|
||||||
'gethtml': null,
|
'gethtml': null,
|
||||||
'heading': null,
|
'heading': null,
|
||||||
'hilitecolor': function () { make.colors.any() },
|
'hilitecolor': function () { return make.colors.any() },
|
||||||
'increasefontsize': null,
|
'increasefontsize': null,
|
||||||
'indent': null,
|
'indent': null,
|
||||||
'insertBrOnReturn': function () { random.bool() },
|
'insertBrOnReturn': function () { return random.bool() },
|
||||||
'inserthorizontalrule': null,
|
'inserthorizontalrule': null,
|
||||||
// 'inserthtml': function () { },
|
// 'inserthtml': function () { },
|
||||||
'insertlinebreak': null,
|
'insertlinebreak': null,
|
||||||
'insertimage': function () { make.uri.any() },
|
'insertimage': function () { return make.uri.any() },
|
||||||
'insertorderedlist': null,
|
'insertorderedlist': null,
|
||||||
'insertparagraph': null,
|
'insertparagraph': null,
|
||||||
'inserttext': function () { make.text.any() },
|
'inserttext': function () { return make.text.any() },
|
||||||
'insertunorderedlist': null,
|
'insertunorderedlist': null,
|
||||||
'italic': null,
|
'italic': null,
|
||||||
'justifycenter': null,
|
'justifycenter': null,
|
||||||
|
@ -44,7 +44,7 @@ make.command = {
|
||||||
'removeformat': null,
|
'removeformat': null,
|
||||||
'selectall': null,
|
'selectall': null,
|
||||||
'strikethrough': null,
|
'strikethrough': null,
|
||||||
'styleWithCSS': function () { random.bool() },
|
'styleWithCSS': function () { return random.bool() },
|
||||||
'subscript': null,
|
'subscript': null,
|
||||||
'superscript': null,
|
'superscript': null,
|
||||||
'underline': null,
|
'underline': null,
|
||||||
|
|
|
@ -77,6 +77,24 @@ make.network = {
|
||||||
'2001:db8::1:1:1:1:1'
|
'2001:db8::1:1:1:1:1'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
hostname: function () {
|
||||||
|
return random.pick([this.randomIPv4, this.randomIPv6, this.goodHostnames, this.badHostnames])
|
||||||
|
},
|
||||||
|
port: function () {
|
||||||
|
return random.pick([80, 443, 21, 23, 9310])
|
||||||
|
},
|
||||||
|
hash: function () {
|
||||||
|
return random.pick(['', '#', '#main-content', function () { return '#' + make.text.any() }])
|
||||||
|
},
|
||||||
|
path: function () {
|
||||||
|
return random.pick(['', '/', '/index.html', function () { return '/' + make.text.any() }])
|
||||||
|
},
|
||||||
|
protocol: function () {
|
||||||
|
return random.pick(['http:', 'https:', 'ftp:', 'telnet:', 'chrome:', 'resource:'])
|
||||||
|
},
|
||||||
|
search: function () {
|
||||||
|
return random.pick(['', '?', '?foo=bar', function () { return '?' + make.text.any() }])
|
||||||
|
},
|
||||||
randomBitmask: function (list) {
|
randomBitmask: function (list) {
|
||||||
if (list.length <= 1) {
|
if (list.length <= 1) {
|
||||||
return list.join('')
|
return list.join('')
|
||||||
|
|
|
@ -41,7 +41,7 @@ make.number = {
|
||||||
if (random.chance(2)) {
|
if (random.chance(2)) {
|
||||||
return Math.abs(make.number.any())
|
return Math.abs(make.number.any())
|
||||||
}
|
}
|
||||||
return Math.pow(2, random.number(65)) + random.number(3) - 1
|
return Math.pow(2, random.number(random.number(65))) + random.number(3) - 1
|
||||||
},
|
},
|
||||||
even: function (number) {
|
even: function (number) {
|
||||||
return number % 2 === 1 ? ++number : number
|
return number % 2 === 1 ? ++number : number
|
||||||
|
|
16
lib/make/style.js
Normal file
16
lib/make/style.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
make.style = {
|
||||||
|
pseudoElement: function () {
|
||||||
|
return random.item([
|
||||||
|
'::after',
|
||||||
|
'::before',
|
||||||
|
'::cue',
|
||||||
|
'::first-letter',
|
||||||
|
'::first-line',
|
||||||
|
'::selection',
|
||||||
|
'::backdrop',
|
||||||
|
'::placeholder',
|
||||||
|
'::marker',
|
||||||
|
'::spelling-error',
|
||||||
|
'::grammar-error'])
|
||||||
|
}
|
||||||
|
}
|
|
@ -216,7 +216,7 @@ make.text = {
|
||||||
// This might be too slow to used for all 'texts' uses
|
// This might be too slow to used for all 'texts' uses
|
||||||
let s = ''
|
let s = ''
|
||||||
// TODO: Len calculation take from DOMFuzz - maybe we should revise this?
|
// TODO: Len calculation take from DOMFuzz - maybe we should revise this?
|
||||||
let len = random.number(1000) * random.number(10) + random.number(10)
|
let len = random.pick([make.number.tiny, make.number.range])
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
s += make.text.chars()
|
s += make.text.chars()
|
||||||
}
|
}
|
||||||
|
|
14
lib/make/time.js
Normal file
14
lib/make/time.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
make.time = {
|
||||||
|
unit: function () {
|
||||||
|
return random.pick([
|
||||||
|
's', 'ms'
|
||||||
|
])
|
||||||
|
},
|
||||||
|
any: function () {
|
||||||
|
return make.number.any() + make.time.unit()
|
||||||
|
}
|
||||||
|
}
|
|
@ -50,10 +50,11 @@ var random = { // eslint-disable-line no-unused-vars
|
||||||
return Math.exp(this.float() * Math.log(limit))
|
return Math.exp(this.float() * Math.log(limit))
|
||||||
},
|
},
|
||||||
item: function (list) {
|
item: function (list) {
|
||||||
if (!(Array.isArray(list) || (list !== undefined && typeof list !== 'string' && list.hasOwnProperty('length')))) {
|
if (list === undefined || typeof list === 'string' || list.length === undefined) {
|
||||||
logger.traceback()
|
logger.traceback()
|
||||||
throw new TypeError('this.item() received a non array type: \'' + list + '\'')
|
throw new TypeError('random.item() received an invalid object: \'' + list + '\'')
|
||||||
}
|
}
|
||||||
|
|
||||||
return list[this.number(list.length)]
|
return list[this.number(list.length)]
|
||||||
},
|
},
|
||||||
key: function (obj) {
|
key: function (obj) {
|
||||||
|
|
2
lib/utils/prototypes.js
vendored
2
lib/utils/prototypes.js
vendored
|
@ -69,7 +69,7 @@ Object.defineProperty(Array.prototype, 'extend', {
|
||||||
|
|
||||||
Object.defineProperty(Object, 'isObject', {
|
Object.defineProperty(Object, 'isObject', {
|
||||||
value: function (obj) {
|
value: function (obj) {
|
||||||
return (obj != null && typeof obj === 'object' &&
|
return (obj !== null && typeof obj === 'object' &&
|
||||||
Object.prototype.toString.call(obj) === '[object Object]')
|
Object.prototype.toString.call(obj) === '[object Object]')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -179,10 +179,10 @@ QUnit.test("random.ludOneTo() distribution", function(assert) {
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("random.item() exception cases", function(assert) {
|
QUnit.test("random.item() exception cases", function(assert) {
|
||||||
assert.throws(random.item, /non array type/);
|
assert.throws(random.item, /received an invalid object/);
|
||||||
assert.throws(function(){ return random.item(1); }, /non array type/);
|
assert.throws(function(){ return random.item(1); }, /received an invalid object/);
|
||||||
assert.throws(function(){ return random.item("1"); }, /non array type/);
|
assert.throws(function(){ return random.item("1"); }, /received an invalid object/);
|
||||||
assert.throws(function(){ return random.item({}); }, /non array type/);
|
assert.throws(function(){ return random.item({}); }, /received an invalid object/);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("random.item() distribution with list", function(assert) {
|
QUnit.test("random.item() distribution with list", function(assert) {
|
||||||
|
|
Loading…
Reference in a new issue