devstar插件

This commit is contained in:
2025-07-26 16:40:29 +08:00
commit 30033daafe
4387 changed files with 1041101 additions and 0 deletions

36
node_modules/mark.js/test/specs/iframes/disabled.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
'use strict';
describe('mark with disabled iframes', function() {
var $ctx, $elements, errCall;
beforeEach(function(done) {
loadFixtures('iframes/disabled.html');
$elements = $();
$ctx = $('.iframes-disabled');
errCall = 0;
try {
new Mark($ctx[0]).mark('lorem', {
'diacritics': false,
'separateWordSearch': false,
'iframes': false,
'each': function($m) {
$elements = $elements.add($($m));
},
'done': done
});
} catch (e) {
errCall++;
}
}, 30000); // 30 sec timeout
it('should ignore matches inside iframes if specified', function() {
expect(errCall).toBe(0);
var unequal = false;
$elements.each(function() {
if ($(this).prop('ownerDocument') !== $ctx.prop('ownerDocument')) {
unequal = true;
}
});
expect(unequal).toBe(false);
expect($elements).toHaveLength(4);
});
});

26
node_modules/mark.js/test/specs/iframes/exclude.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
'use strict';
describe('mark with iframes and exclude', function() {
var $ctx, $elements;
beforeEach(function(done) {
loadFixtures('iframes/exclude.html');
$elements = $();
$ctx = $('.iframes-exclude');
new Mark($ctx[0]).mark('lorem', {
'diacritics': false,
'separateWordSearch': false,
'iframes': true,
'exclude': [
'.ignore'
],
'each': function($m) {
$elements = $elements.add($($m));
},
'done': done
});
});
it('should ignore iframes matching exclude selectors', function() {
expect($elements).toHaveLength(4);
});
});

View File

@@ -0,0 +1,29 @@
'use strict';
describe('mark in inaccessible iframes', function() {
var $ctx, $elements, errCall;
beforeEach(function(done) {
loadFixtures('iframes/inaccessible.html');
$elements = $();
$ctx = $('.iframes-inaccessible');
errCall = 0;
try {
new Mark($ctx[0]).mark('lorem', {
'diacritics': false,
'separateWordSearch': false,
'iframes': true,
'each': function($m) {
$elements = $elements.add($($m));
},
'done': done
});
} catch (e) {
errCall++;
}
}, 30000); // 30 sec timeout
it('should silently skip iframes which can not be accessed', function() {
expect(errCall).toBe(0);
expect($elements).toHaveLength(4);
});
});

37
node_modules/mark.js/test/specs/iframes/main.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
describe('mark with iframes', function() {
var $ctx, $elements, errCall;
beforeEach(function(done) {
loadFixtures('iframes/main.html');
$elements = $();
$ctx = $('.iframes');
errCall = 0;
try {
new Mark($ctx[0]).mark('lorem', {
'diacritics': false,
'separateWordSearch': false,
'iframes': true,
'each': function($m) {
$elements = $elements.add($($m));
},
'done': done
});
} catch (e) {
errCall++;
}
}, 30000); // 30 sec timeout
it('should wrap matches inside iframes', function() {
expect(errCall).toBe(0);
expect($elements).toHaveLength(8);
var unequal = false;
$elements.each(function() {
// make sure that some elements are inside an iframe
if ($(this).prop('ownerDocument') !== $ctx.prop('ownerDocument')) {
unequal = true;
}
});
expect(unequal).toBe(true);
});
});

View File

@@ -0,0 +1,40 @@
'use strict';
describe('unmark with nested iframes', function() {
var $ctx, $elements, errCall;
beforeEach(function(done) {
loadFixtures('iframes/nested.html');
$ctx = $('.iframes-nested');
$elements = $();
errCall = 0;
try {
var instance = new Mark($ctx[0]);
instance.mark('lorem', {
'diacritics': false,
'separateWordSearch': false,
'iframes': true,
'each': function($el) {
$elements = $elements.add($($el));
},
'done': function() {
instance.unmark({
'iframes': true,
'done': done
});
}
});
} catch (e) {
errCall++;
}
});
it(
'should remove all marked elements inside iframes recursively',
function() {
expect(errCall).toBe(0);
$elements.each(function() {
expect(this).not.toBeInDOM();
});
}
);
});

29
node_modules/mark.js/test/specs/iframes/nested.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
'use strict';
describe('mark in nested iframes', function() {
var $ctx, $elements, errCall;
beforeEach(function(done) {
loadFixtures('iframes/nested.html');
$elements = $();
$ctx = $('.iframes-nested');
errCall = 0;
try {
new Mark($ctx[0]).mark('lorem', {
'diacritics': false,
'separateWordSearch': false,
'iframes': true,
'each': function($m) {
$elements = $elements.add($($m));
},
'done': done
});
} catch (e) {
errCall++;
}
}, 30000); // 30 sec timeout
it('should wrap matches inside iframes recursively', function() {
expect(errCall).toBe(0);
expect($elements).toHaveLength(12);
});
});

39
node_modules/mark.js/test/specs/iframes/onload.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
'use strict';
describe('mark with iframes where onload was not fired yet', function() {
// Note that in Chrome the onload event will already be fired. Reason
// is that Chrome initializes every iframe with an empty page, which will
// fire the onload event too respectively set readyState complete
var $ctx, $elements, errCall;
beforeEach(function(done) {
loadFixtures('iframes/onload.html');
$elements = $();
$ctx = $('.iframes-onload');
errCall = 0;
try {
new Mark($ctx[0]).mark('test', {
'diacritics': false,
'separateWordSearch': false,
'iframes': true,
'each': function($m) {
$elements = $elements.add($($m));
},
'done': done
});
} catch (e) {
errCall++;
}
}, 30000); // 30 sec timeout
it('should wrap matches inside iframes', function() {
expect(errCall).toBe(0);
expect($elements).toHaveLength(2);
var unequal = false;
$elements.each(function() {
if ($(this).prop('ownerDocument') !== $ctx.prop('ownerDocument')) {
unequal = true;
}
});
expect(unequal).toBe(true);
});
});

33
node_modules/mark.js/test/specs/iframes/order.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
'use strict';
describe('mark with iframes DOM order', function() {
var $ctx, elements;
beforeEach(function(done) {
loadFixtures('iframes/order.html');
$ctx = $('.iframes-order');
elements = [];
new Mark($ctx[0]).mark('lorem', {
'diacritics': false,
'separateWordSearch': false,
'iframes': true,
'each': function(node) {
elements.push(node);
},
'done': done
});
});
it('should wrap elements in the DOM order', function() {
expect(elements.length).toBe(6);
elements.forEach(function(node, i){
var thisDoc = $(node).prop('ownerDocument'),
ownerDoc = $ctx.prop('ownerDocument'),
equalDocs = thisDoc === ownerDoc;
if ((i + 1) === 1 || (i + 1) === 6){ // first and last element
expect(equalDocs).toBe(true);
} else { // other elements should be in an iframe
expect(equalDocs).toBe(false);
}
});
});
});

46
node_modules/mark.js/test/specs/iframes/readystate.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
'use strict';
describe('mark with iframes where onload was already fired', function() {
var $ctx, $elements, errCall;
beforeEach(function(done) {
loadFixtures('iframes/readystate.html');
$elements = $();
$ctx = $('.iframes-readystate');
errCall = 0;
try {
var int = setInterval(function() {
var iCon = $ctx.find('iframe').first()[0].contentWindow,
readyState = iCon.document.readyState,
href = iCon.location.href;
// about:blank check is necessary for Chrome
// (see Mark~onIframeReady)
if (readyState === 'complete' && href !== 'about:blank') {
clearInterval(int);
new Mark($ctx[0]).mark('lorem', {
'diacritics': false,
'separateWordSearch': false,
'iframes': true,
'each': function($m) {
$elements = $elements.add($($m));
},
'done': done
});
}
}, 100);
} catch (e) {
errCall++;
}
}, 30000); // 30 sec timeout
it('should wrap matches inside iframes', function() {
expect(errCall).toBe(0);
expect($elements).toHaveLength(8);
var unequal = false;
$elements.each(function() {
if ($(this).prop('ownerDocument') !== $ctx.prop('ownerDocument')) {
unequal = true;
}
});
expect(unequal).toBe(true);
});
});

View File

@@ -0,0 +1,34 @@
'use strict';
describe('iframes unmark and mark with the same instance', function() {
var $ctx, $elements;
beforeEach(function(done) {
loadFixtures('iframes/unmark-same-instance.html');
$ctx = $('.iframes-unmark-same-instance');
$elements = $();
var instance = new Mark($ctx[0]);
instance.unmark({
'done': function() {
instance.mark('lorem ipsum', {
'diacritics': false,
'iframes': true,
'separateWordSearch': false,
'each': function(node) {
$elements = $elements.add($(node));
},
'done': done
});
}
});
});
it(
'should work when setting different options for method calls',
function() {
expect($elements).toHaveLength(8);
$elements.each(function() {
expect($(this)).toHaveText('Lorem ipsum');
});
}
);
});

37
node_modules/mark.js/test/specs/iframes/unmark.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
describe('unmark with iframes', function() {
var $ctx, $elements, errCall;
beforeEach(function(done) {
loadFixtures('iframes/main.html');
$ctx = $('.iframes');
$elements = $();
errCall = 0;
try {
var instance = new Mark($ctx[0]);
instance.mark('lorem', {
'diacritics': false,
'separateWordSearch': false,
'iframes': true,
'each': function($el) {
$elements = $elements.add($($el));
},
'done': function() {
instance.unmark({
'iframes': true,
'done': done
});
}
});
} catch (e) {
errCall++;
}
});
it('should remove all marked elements inside iframes', function() {
expect(errCall).toBe(0);
$elements.each(function() {
expect(this).not.toBeInDOM();
});
});
});