diff --git a/test/test_custom_method.js b/test/test_custom_method.js
index 37d7e66..93a76a1 100644
--- a/test/test_custom_method.js
+++ b/test/test_custom_method.js
@@ -87,6 +87,49 @@ describe('test custom XSS method', function () {
assert.equal(html, source);
});
+ it('#onIgnoreTag - match tag', function () {
+ var source = 'ddhaha
ff';
+ var i = 0;
+ var html = xss(source, {
+ onIgnoreTag: function (tag, html, options) {
+ console.log(arguments);
+ i++;
+ if (i === 1) {
+ assert.equal(tag, 'c');
+ assert.equal(html, '');
+ assert.equal(options.isClosing, false);
+ assert.equal(options.position, 17);
+ assert.equal(options.originPosition, 17);
+ assert.equal(options.isWhite, false);
+ } else if (i === 2) {
+ assert.equal(tag, 'c');
+ assert.equal(html, '');
+ assert.equal(options.isClosing, true);
+ assert.equal(options.position, 30);
+ assert.equal(options.originPosition, 24);
+ assert.equal(options.isWhite, false);
+ } else {
+ throw new Error();
+ }
+ }
+ });
+ console.log(html);
+ assert.equal(html, 'dd<c>haha</c>
ff');
+ });
+
+ it('#onIgnoreTag - return new html', function () {
+ var source = 'ddhaha
ff';
+ var i = 0;
+ var html = xss(source, {
+ onIgnoreTag: function (tag, html, options) {
+ console.log(html);
+ return '[' + (options.isClosing ? '/' : '') + 'removed]';
+ }
+ });
+ console.log(html);
+ assert.equal(html, 'dd[removed]haha[/removed]
ff');
+ });
+
/*
// 自定义过滤属性函数
it('#process attribute value', function () {