How to use parseHTML method in Playwright Internal

Best JavaScript code snippet using playwright-internal

fromhtml.js

Source:fromhtml.js Github

copy

Full Screen

1/* bender-tags: editor */2function parseHtml( raw, parent ) {3 var fragment = CKEDITOR.htmlParser.fragment.fromHtml( raw, parent || 'body', 'p' ),4 writer = new CKEDITOR.htmlParser.basicWriter();5 fragment.writeChildrenHtml( writer );6 return writer.getHtml( true );7}8bender.test( {9 test_parser_1: function() {10 assert.areSame( '<p><b>2</b> Test</p><table><tr><td>1</td><td>3</td></tr></table>',11 parseHtml( '<table><tr><td>1</td><p><b>2</b> Test</p><td>3</td></tr></table>' ) );12 },13 test_parser_2: function() {14 assert.areSame( '<table><tr><td><b>1</b></td><td><b>2</b></td></tr></table>',15 parseHtml( '<b><table><tr><td>1</td><td>2</td></tr></table></b>' ) );16 },17 test_parser_3_1: function() {18 assert.areSame( '<p><b><i>Table:</i></b></p><table><tr><td><b><i>1</i></b></td><td><b><i>2</i></b></td></tr></table>',19 parseHtml( '<b><i>Table:<table><tr><td>1</td><td>2</td></tr></table></i></b>' ) );20 },21 test_parser_3_2: function() {22 assert.areSame( '<table><tr><td><b><i>1</i></b></td><td><b><i>2</i></b></td></tr></table><p><b><i>Table</i></b></p>',23 parseHtml( '<b><i><table><tr><td>1</td><td>2</td></tr></table>Table</i></b>' ) );24 },25 test_parser_4: function() {26 assert.areSame( '<p><b><i>Test</i></b></p>',27 parseHtml( '<b><i>Test' ) );28 },29 test_parser_5: function() {30 assert.areSame( '<p>Para 1</p><p>Para 2</p><p>Para 3</p>',31 parseHtml( '<p>Para 1<p>Para 2<p>Para 3' ) );32 },33 test_parser_6: function() {34 assert.areSame( '<p><b>A</b><i>B</i></p>',35 parseHtml( '<b>A</b><i>B</i>' ) );36 },37 test_parser_7: function() {38 assert.areSame( '<p>Para 1</p><hr /><p>Para 2</p><h1>Para 3</h1>',39 parseHtml( '<p>Para 1<hr>Para 2<h1>Para 3' ) );40 },41 /**42 * Test remove empty inline element.43 */44 test_parser_8: function() {45 assert.areSame( '<p>text</p>',46 parseHtml( '<p><b></b>text</p>' ) );47 },48 /**49 * Test remove multiple empty inline elements.50 */51 test_parser_8_2: function() {52 assert.areSame( '<p>text</p>',53 parseHtml( '<p><b><i></b></i>text</p>' ) );54 },55 /**56 * Test remove empty links.57 */58 test_parser_8_3: function() {59 assert.areSame( '<p>test</p>',60 parseHtml( '<p>test<a href="foo"><a href="bar"></p>' ) );61 },62 /**63 * Test keep empty anchors.64 */65 test_parser_8_4: function() {66 assert.areSame( '<p>test<a name="foo"></a><a name="bar"></a></p>',67 parseHtml( '<p>test<a name="foo"><a name="bar"></p>' ) );68 },69 /**70 * Test fixing malformed inline element closing.71 */72 test_parser_9: function() {73 assert.areSame( '<p><b>bold<i>ita</i></b><i>lic</i></p>',74 parseHtml( '<p><b>bold<i>ita</b>lic</i></p>' ) );75 },76 test_parser_10: function() {77 assert.areSame( '<table><tbody><tr><td>A</td></tr></tbody></table>',78 parseHtml( '<table><tbody><tr><td>A<b></b></td></tr></tbody></table>' ) );79 },80 /*81 * Leaving table internals intact.82 */83 test_parser_11: function() {84 assert.areSame( '<td>1</td><tr><td>2</td></tr>',85 parseHtml( '<td>1</td><tr><td>2</td></tr>' ) );86 },87 /*88 * Forward lifting invalid table children..89 */90 test_parser_12: function() {91 assert.areSame( '<p>p1</p><p>p2</p><table><tr><td>c1</td></tr></table>',92 parseHtml( '<table><p>p1</p><tr><td>c1</td></tr><p>p2</p></table>' ) );93 },94 /**95 * Test fixing malformed nested list structure. (https://dev.ckeditor.com/ticket/3828)96 */97 test_parser_13: function() {98 assert.areSame( '<ul><li><ol></ol></li></ul>',99 parseHtml( '<ul><ol></ol></ul>' ) );100 assert.areSame( '<ul><li>level1<ul><li>level2<ul><li>level3</li></ul></li></ul></li></ul>',101 parseHtml( '<ul><li>level1</li><ul><li>level2</li><ul><li>level3</li></ul></ul></ul>' ) );102 },103 /**104 * Test fixing orphan list items twice.105 */106 test_parser_14: function() {107 assert.areSame( '<ul><li>1</li></ul><dl><dt>2</dt><dd>3</dd></dl>',108 parseHtml( '<li>1</li><dt>2</dt><dd>3</dd>' ) );109 assert.areSame( '<ul><li>1</li></ul><dl><dt>2</dt></dl>',110 parseHtml( '<li>1</li><dt>2</dt></ol>' ) );111 },112 /**113 * Test fixing orphan definition list items.114 */115 test_parser_14b: function() {116 assert.areSame( '<dl><dt><p>foo</p></dt><dd><p>bar</p></dd></dl>', parseHtml( '<dt><p>foo</p></dt><dd><p>bar</p></dd>' ) );117 assert.areSame( '<dl><dt>foo</dt></dl><td>bar</td>', parseHtml( '<dt><td>bar</td>foo</dt>' ) );118 },119 /**120 * Test fix body + optional close.121 */122 test_parser_15: function() {123 assert.areSame( '<p><br /></p>', parseHtml( '<br />' ) );124 assert.areSame( '<p><img /></p>', parseHtml( '<img /></p>' ) );125 assert.areSame( '<p><b>bold</b></p>', parseHtml( '<b>bold</p>' ) );126 assert.areSame( '<p>p1</p>', parseHtml( '<p>p1</div>' ) );127 },128 /**129 * Test auto paragrahing with different contexts.130 */131 'test auto paragraphing': function() {132 var editables = [ 'body', 'div', 'h1', 'table' ], ct, dtd, msg;133 for ( var i = 0 ; i < editables.length ; i++ ) {134 ct = editables[ i ];135 dtd = CKEDITOR.dtd[ ct ];136 msg = 'auto paragraphing for editable: ' + ct;137 if ( dtd.p )138 assert.areSame( '<p>foo</p>', parseHtml( 'foo', ct ), msg );139 else if ( ct == 'table' )140 assert.areSame( '<tbody><tr><td>foo</td></tr></tbody>', parseHtml( 'foo', ct ), msg );141 else142 assert.areSame( 'foo', parseHtml( 'foo', ct ), msg );143 }144 },145 'test whitespaces handling': function() {146 var source = '\n foo ',147 output = '<p>foo</p>';148 assert.areSame( output, parseHtml( source ), 'default context' );149 assert.areSame( output, parseHtml( source, 'body' ), 'body context' );150 assert.areSame( output, parseHtml( source, 'div' ), 'div context' );151 assert.areSame( output, parseHtml( source, 'figcaption' ), 'figcaption context' );152 assert.areSame( 'foo', parseHtml( source, 'p' ), 'p context' );153 source = '\n <p>foo</p> ';154 assert.areSame( output, parseHtml( source ), 'default context - block edges' );155 assert.areSame( output, parseHtml( source, 'body' ), 'body context - block edges' );156 assert.areSame( output, parseHtml( source, 'div' ), 'div context - block edges' );157 assert.areSame( output, parseHtml( source, 'figcaption' ), 'figcaption context - block edges' );158 source = '<p>foo</p> \n <p>bar</p>';159 output = '<p>foo</p><p>bar</p>';160 assert.areSame( output, parseHtml( source ), 'default context - between blocks' );161 assert.areSame( output, parseHtml( source, 'body' ), 'body context - between blocks' );162 assert.areSame( output, parseHtml( source, 'div' ), 'div context - between blocks' );163 assert.areSame( output, parseHtml( source, 'figcaption' ), 'figcaption context - between blocks' );164 },165 // Test whitespaces handling in different context. (https://dev.ckeditor.com/ticket/3715)166 'parse pre-formatted contents': function() {167 var pre = '<pre>\t\tfoo\nbar quz \n</pre>',168 textarea = '<p><textarea>\t\tfoo\nbar quz \n</textarea></p>';169 assert.areSame( pre, parseHtml( pre ) );170 assert.areSame( textarea, parseHtml( textarea ) );171 assert.areSame( '<p><b>foo bar</b></p>', parseHtml( '<p><b>foo bar</b></p>' ) );172 },173 'parse list and table contents (with context)': function() {174 // Given the list/table as the parent element, parser should not attempt175 // to fix partial content.176 var source = '<li>foo</li><li>bar</li>';177 assert.areSame( source, parseHtml( source, 'ul' ) );178 source = '<li>foo</li><li>bar</li>';179 assert.areSame( source, parseHtml( '<li>foo</li><li>bar</li>', 'ol' ) );180 source = '<dt>foo</dt><dd>bar</dd>';181 assert.areSame( source, parseHtml( '<dt>foo</dt><dd>bar</dd>', 'dl' ) );182 source = '<tr><td>foo</td><td>bar</td></tr>';183 assert.areSame( source, parseHtml( '<tr><td>foo</td><td>bar</td></tr>', 'table' ) );184 source = '<tbody><tr><td>foo</td><td>bar</td></tr></tbody>';185 assert.areSame( source, parseHtml( '<tbody><tr><td>foo</td><td>bar</td></tr></tbody>', 'table' ) );186 source = '<caption>foo</caption>';187 assert.areSame( source, parseHtml( '<caption>foo</caption>', 'table' ) );188 },189 'parse pre and textarea contents (with context)': function() {190 // Given the pre/textarea as context, parser should preserve all white spaces.191 var source = '\t\tfoo\nbar quz \n';192 assert.areSame( source, parseHtml( source, 'pre' ) );193 assert.areSame( source, parseHtml( source, 'textarea' ) );194 },195 'parser orphan text in list/table.': function() {196 assert.areSame( '<ul><li><strong>foo</strong>bar</li></ul>',197 parseHtml( '<ul><strong>foo</strong>bar</ul>' ) );198 assert.areSame( '<ul><li>foo</li><li>bar</li></ul>',199 parseHtml( '<ul>foo<li>bar</li></ul>' ) );200 assert.areSame( '<table><tbody><tr><td><strong>foo</strong>bar</td></tr></tbody></table>',201 parseHtml( '<table><strong>foo</strong>bar</table>' ) );202 assert.areSame( '<table><tbody><tr><td><strong>foo</strong></td><td>bar</td></tr></tbody></table>',203 parseHtml( '<table><strong>foo</strong><td>bar</td></table>' ) );204 assert.areSame( '<table><tbody><tr><td><strong>foo</strong></td></tr><tr><td>bar</td></tr></tbody></table>',205 parseHtml( '<table><strong>foo</strong><tr>bar</tr></table>' ) );206 assert.areSame( '<tr><td>foo</td></tr>', parseHtml( '<tr>foo</tr>' ) );207 // https://dev.ckeditor.com/ticket/11660208 assert.areSame( '<table><tbody><tr><td>1</td></tr><tr><td>Issue2</td></tr><tr><td>3</td></tr></tbody></table>',209 parseHtml( '<table><tbody><tr><td>1</td></tr>Issue2<tr><td>3</td></tr></tbody></table>' ) );210 },211 'test parser fix inline outside of block element': function() {212 assert.areSame( '<p>Line 1</p><p><b>Line 2</b></p><p><b>Line 3</b></p><p><b>Line 4</b></p><p>Line 5</p>',213 parseHtml( '<p>Line 1</p><b><p>Line 2</p><p>Line 3</p><p>Line 4</p></b><p>Line 5</p>' ) );214 },215 /**216 * Test fixing paragraph inside table row.217 */218 test_ticket_3195: function() {219 assert.areSame( '<p>2</p><table><tr><td>1</td><td>3</td></tr></table>',220 parseHtml( '<table><tr><td>1</td><p>2</p><td>3</td></tr></table>' ) );221 },222 /**223 * Test fixing paragraph inside list.224 */225 test_ticket_3195_2: function() {226 assert.areSame( '<p>2</p><ul><li>1</li><li>3</li></ul>',227 parseHtml( '<ul><li>1</li><p>2</p><li>3</li></ul>' ) );228 },229 /**230 * Test fixing 'div' inside paragraph.231 */232 test_ticket_3195_3: function() {233 assert.areSame( '<p>1</p><div>2</div><p><span>3</span></p>',234 parseHtml( '<p>1<div>2</div><span>3</span></p>' ) );235 },236 test_ticket_3441: function() {237 assert.areSame( '<p><b>Test</b></p><script type="test">var a = "<A Href=xxx>Testing</ A>";\nGo();<\/script>',238 parseHtml( '<p><b>Test</b></p><script type="test">var a = "<A Href=xxx>Testing</ A>";\nGo();<\/script>' ) );239 },240 test_ticket_3585: function() {241 assert.areSame( '<p><br /></p>', parseHtml( '<p><br />\t\r\n</p>' ) );242 },243 test_ticket_3585_1: function() {244 assert.areSame( '<p><br />text</p>', parseHtml( '<p><br />text\t\r\n</p>' ) );245 },246 test_ticket_3585_2: function() {247 assert.areSame( '<p><b>inline </b></p><p>paragraph</p>', parseHtml( '<b>inline </b>\n<p>paragraph\t\r\n</p>\t\r\n' ) );248 },249 test_ticket_3744: function() {250 assert.areSame( '<div><b><font><span>A</span></font></b></div><div>X</div>',251 parseHtml( '<div><b><font><span>A</font></span></b></div><div>X</div>' ) );252 },253 // https://dev.ckeditor.com/ticket/3862254 'test not breaking on malformed close tag': function() {255 assert.areSame(256 '<p><span><a><b>test</b></a><a><b>test</b></a><a><b>test</b></a><a><b>test</b></a><a><b>test</b></a>' +257 '<a><b>test</b></a><a><b>test</b></a><a><b>test</b></a><a><b>test</b></a><a><b>test</b></a><a><b>test</b></a>' +258 '<a><b>test</b></a><a><b>test</b></a><a><b>test</b></a><a><b>test</b></a><a><b>test</b></a><a><b>test</b></a>' +259 '<a><b>test</b></a></span></p>',260 parseHtml(261 '<p><span><a><b>test</a></b><a><b>test</a></b><a><b>test</a></b><a><b>test</a></b><a><b>test</a></b>' +262 '<a><b>test</a></b><a><b>test</a></b><a><b>test</a></b><a><b>test</a></b><a><b>test</a></b><a><b>test</a></b>' +263 '<a><b>test</a></b><a><b>test</a></b><a><b>test</a></b><a><b>test</a></b><a><b>test</a></b><a><b>test</a></b>' +264 '<a><b>test</a></b></span></p>'265 )266 );267 },268 test_ticket_5788: function() {269 assert.areSame( '<p>test<br />whitespace</p>', parseHtml( '<p>test<br /> whitespace</p>' ) );270 assert.areSame( '<div><p>paragraph</p>pseudo</div>', parseHtml( '<div><p>paragraph</p> pseudo</div>' ) );271 assert.areSame( '<div>pseudo<p>paragraph</p></div>', parseHtml( '<div>pseudo <p>paragraph</p></div>' ) );272 },273 // https://dev.ckeditor.com/ticket/5626274 'test parser fix partial list items': function() {275 assert.areSame( '<table><tr><td><ul><li>item1</li><li>item2</li></ul></td></tr></table>',276 parseHtml( '<table><tr><td><li>item1</li><li>item2</li></td></tr></table>' ) );277 assert.areSame( '<body><p>text</p><ul><li>cell</li></ul></body>',278 parseHtml( '<body>text<li>cell</li></body>', 'html' ) );279 assert.areSame( '<ul><li>item1</li><li>item2</li></ul>',280 parseHtml( '<li>item1</li><li>item2</li>' ) );281 assert.areSame( '<dl><dd>test</dd><dd>test</dd></dl>',282 parseHtml( '<dd>test</dd><dd>test</dd>' ) );283 },284 // https://dev.ckeditor.com/ticket/5626285 'test parser *NOT* fixing orphan table cells': function() {286 assert.areSame( '<td>td1</td><p>text</p>',287 parseHtml( '<td>td1</td>text' ) );288 assert.areSame( '<tr><td>td1</td></tr><ul><li>li1</li></ul>',289 parseHtml( '<ul><tr><td>td1</td></tr><li>li1</li></ul>' ) );290 },291 // https://dev.ckeditor.com/ticket/5626292 'test parser fix malformed table cell/list item': function() {293 assert.areSame( '<table><tr><td>cell1</td><td>cell2</td></tr></table>',294 parseHtml( '<table><tr><td>cell1<td>cell2</td></td></tr></table>' ) );295 assert.areSame( '<ul><li>item1</li><li>item2</li></ul>',296 parseHtml( '<ul><li>item1<li>item2</li></li></ul>' ) );297 },298 // https://dev.ckeditor.com/ticket/7894299 'test parser fix malformed link': function() {300 assert.areSame( '<p>foo<a href="#2">bar</a></p><p>foo bar</p>',301 parseHtml( '<p>foo<a href="#1"><a href="#2">bar</a></p> <p>foo</a> bar</p>' ) );302 },303 'test whitespace between comments': function() {304 var source = '<i>foo<!--1--> <!--2-->bar</i>';305 assert.areSame( source, parseHtml( source, 'p' ) );306 },307 'test *NOT* removing empty inline when comment enclosed': function() {308 assert.areSame( '<p><span><!--comment--></span></p>', parseHtml( '<p><span><!--comment--></span></p>' ) );309 },310 'test fragment#writeChildrenHtml': function() {311 var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<p>A<b>B<i>C</i></b></p>' ),312 writer = new CKEDITOR.htmlParser.basicWriter(),313 filter = new CKEDITOR.htmlParser.filter();314 filter.addRules( {315 root: function( element ) {316 var div = CKEDITOR.htmlParser.fragment.fromHtml( 'X', 'div' );317 div.insertAfter( element.children[ 0 ] ); // Insert after p.318 },319 elements: {320 $: function( element ) {321 element.attributes.x = '1';322 }323 }324 } );325 fragment.writeChildrenHtml( writer );326 assert.areSame( '<p>A<b>B<i>C</i></b></p>', writer.getHtml( true ) );327 fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<p>A<b>B<i>C</i></b></p>' );328 fragment.writeChildrenHtml( writer, filter );329 assert.areSame( '<p x="1">A<b x="1">B<i x="1">C</i></b></p>', writer.getHtml( true ) );330 fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<p>A<b>B<i>C</i></b></p>' );331 fragment.writeChildrenHtml( writer, filter, true );332 assert.areSame( '<p x="1">A<b x="1">B<i x="1">C</i></b></p><div x="1">X</div>', writer.getHtml( true ) );333 }...

Full Screen

Full Screen

parseHTML.test.js

Source:parseHTML.test.js Github

copy

Full Screen

2import SpecialCharacter from "../../model/SpecialCharacter";3import parseHTML from "../parseHTML";4import tokenizeNode from "../../defaults/tokenizeNode";5import tokenizeClassName from "../../defaults/tokenizeClassName";6describe("parseHTML()", () => {7 test("table", () => {8 // ╔════════════════╦════════╗9 // ║ first ║ ║10 // ╠═══════╦════════╣ second ║11 // ║ third ║ fourth ║ ║12 // ╚═══════╩════════╩════════╝13 const actual = parseHTML(14 "<table>" +15 "<thead>" +16 "<tr>" +17 '<th colspan="2"><p>first</p></th>' +18 '<th rowspan="2"><p>second</p></th>' +19 "</tr>" +20 "</thead>" +21 "<tbody>" +22 "<tr>" +23 "<th><p>third</p></th>" +24 "<th><p>fourth</p></th>" +25 "</tr>" +26 "</tbody>" +27 "</table>",28 tokenizeNode,29 tokenizeClassName30 );31 const expected = new Delta()32 .insert(SpecialCharacter.TableStart)33 .insert(SpecialCharacter.RowStart)34 .insert(SpecialCharacter.CellStart, { colspan: 2 })35 .insert("first")36 .insert(SpecialCharacter.BlockEnd, { type: "paragraph" })37 .insert(SpecialCharacter.CellStart, { rowspan: 2 })38 .insert("second")39 .insert(SpecialCharacter.BlockEnd, { type: "paragraph" })40 .insert(SpecialCharacter.RowStart)41 .insert(SpecialCharacter.CellStart)42 .insert("third")43 .insert(SpecialCharacter.BlockEnd, { type: "paragraph" })44 .insert(SpecialCharacter.CellStart)45 .insert("fourth")46 .insert(SpecialCharacter.BlockEnd, { type: "paragraph" })47 .insert(SpecialCharacter.TableEnd);48 expect(actual).toEqual(expected);49 });50 test("unordered-list", () => {51 const actual = parseHTML(52 "<ul>" +53 "<li>first</li>" +54 "<li>second</li>" +55 "<li>third</li>" +56 "</ul>",57 tokenizeNode,58 tokenizeClassName59 );60 const expected = new Delta()61 .insert("first")62 .insert(SpecialCharacter.BlockEnd, { type: "unordered-list-item" })63 .insert("second")64 .insert(SpecialCharacter.BlockEnd, { type: "unordered-list-item" })65 .insert("third")66 .insert(SpecialCharacter.BlockEnd, { type: "unordered-list-item" });67 expect(actual).toEqual(expected);68 });69 test("ordered-list", () => {70 const actual = parseHTML(71 "<ol>" +72 "<li>first</li>" +73 "<li>second</li>" +74 "<li>third</li>" +75 "</ol>",76 tokenizeNode,77 tokenizeClassName78 );79 const expected = new Delta()80 .insert("first")81 .insert(SpecialCharacter.BlockEnd, { type: "ordered-list-item" })82 .insert("second")83 .insert(SpecialCharacter.BlockEnd, { type: "ordered-list-item" })84 .insert("third")85 .insert(SpecialCharacter.BlockEnd, { type: "ordered-list-item" });86 expect(actual).toEqual(expected);87 });88 test("code - br", () => {89 const actual = parseHTML(90 "<pre>first<br>second<br>third<br></pre>",91 tokenizeNode,92 tokenizeClassName93 );94 const expected = new Delta()95 .insert("first")96 .insert(SpecialCharacter.BlockEnd, { type: "code" })97 .insert("second")98 .insert(SpecialCharacter.BlockEnd, { type: "code" })99 .insert("third")100 .insert(SpecialCharacter.BlockEnd, { type: "code" });101 expect(actual).toEqual(expected);102 });103 test("code - div", () => {104 const actual = parseHTML(105 "<pre>" +106 "<div>first</div>" +107 "<div>second</div>" +108 "<div>third</div>" +109 "</pre>",110 tokenizeNode,111 tokenizeClassName112 );113 const expected = new Delta()114 .insert("first")115 .insert(SpecialCharacter.BlockEnd, { type: "code" })116 .insert("second")117 .insert(SpecialCharacter.BlockEnd, { type: "code" })118 .insert("third")119 .insert(SpecialCharacter.BlockEnd, { type: "code" });120 expect(actual).toEqual(expected);121 });122 test("heading-one", () => {123 const actual = parseHTML(124 "<h1>aaa</h1>",125 tokenizeNode,126 tokenizeClassName127 );128 const expected = new Delta()129 .insert("aaa")130 .insert(SpecialCharacter.BlockEnd, { type: "heading-one" });131 expect(actual).toEqual(expected);132 });133 test("heading-two", () => {134 const actual = parseHTML(135 "<h2>aaa</h2>",136 tokenizeNode,137 tokenizeClassName138 );139 const expected = new Delta()140 .insert("aaa")141 .insert(SpecialCharacter.BlockEnd, { type: "heading-two" });142 expect(actual).toEqual(expected);143 });144 test("heading-three", () => {145 const actual = parseHTML(146 "<h3>aaa</h3>",147 tokenizeNode,148 tokenizeClassName149 );150 const expected = new Delta()151 .insert("aaa")152 .insert(SpecialCharacter.BlockEnd, { type: "heading-three" });153 expect(actual).toEqual(expected);154 });155 test("heading-four", () => {156 const actual = parseHTML(157 "<h4>aaa</h4>",158 tokenizeNode,159 tokenizeClassName160 );161 const expected = new Delta()162 .insert("aaa")163 .insert(SpecialCharacter.BlockEnd, { type: "heading-four" });164 expect(actual).toEqual(expected);165 });166 test("heading-five", () => {167 const actual = parseHTML(168 "<h5>aaa</h5>",169 tokenizeNode,170 tokenizeClassName171 );172 const expected = new Delta()173 .insert("aaa")174 .insert(SpecialCharacter.BlockEnd, { type: "heading-five" });175 expect(actual).toEqual(expected);176 });177 test("heading-six", () => {178 const actual = parseHTML(179 "<h6>aaa</h6>",180 tokenizeNode,181 tokenizeClassName182 );183 const expected = new Delta()184 .insert("aaa")185 .insert(SpecialCharacter.BlockEnd, { type: "heading-six" });186 expect(actual).toEqual(expected);187 });188 test("paragraph", () => {189 const actual = parseHTML("<p>aaa</p>", tokenizeNode, tokenizeClassName);190 const expected = new Delta()191 .insert("aaa")192 .insert(SpecialCharacter.BlockEnd, { type: "paragraph" });193 expect(actual).toEqual(expected);194 });195 test("blockquote", () => {196 const actual = parseHTML(197 "<blockquote>aaa</blockquote>",198 tokenizeNode,199 tokenizeClassName200 );201 const expected = new Delta()202 .insert("aaa")203 .insert(SpecialCharacter.BlockEnd, { type: "blockquote" });204 expect(actual).toEqual(expected);205 });206 test("link", () => {207 const actual = parseHTML(208 '<a href="http://foo.bar">aaa</a>',209 tokenizeNode,210 tokenizeClassName211 );212 const expected = new Delta().insert("aaa", { link: "http://foo.bar" });213 expect(actual).toEqual(expected);214 });215 test("bold", () => {216 const actual = parseHTML("<b>aaa</b>", tokenizeNode, tokenizeClassName);217 const expected = new Delta().insert("aaa", { bold: true });218 expect(actual).toEqual(expected);219 });220 test("italic", () => {221 const actual = parseHTML("<i>aaa</i>", tokenizeNode, tokenizeClassName);222 const expected = new Delta().insert("aaa", { italic: true });223 expect(actual).toEqual(expected);224 });225 test("underline", () => {226 const actual = parseHTML("<u>aaa</u>", tokenizeNode, tokenizeClassName);227 const expected = new Delta().insert("aaa", { underline: true });228 expect(actual).toEqual(expected);229 });230 test("strikethrough", () => {231 const actual = parseHTML("<s>aaa</s>", tokenizeNode, tokenizeClassName);232 const expected = new Delta().insert("aaa", { strikethrough: true });233 expect(actual).toEqual(expected);234 });235 test("code", () => {236 const actual = parseHTML(237 "<code>aaa</code>",238 tokenizeNode,239 tokenizeClassName240 );241 const expected = new Delta().insert("aaa", { code: true });242 expect(actual).toEqual(expected);243 });244 test("color", () => {245 const actual = parseHTML(246 '<span class="SquaDocJs-color-red">aaa</span>',247 tokenizeNode,248 tokenizeClassName249 );250 const expected = new Delta().insert("aaa", { color: "red" });251 expect(actual).toEqual(expected);252 });253 test("align", () => {254 const actual = parseHTML(255 '<p class="SquaDocJs-align-left"></p>',256 tokenizeNode,257 tokenizeClassName258 );259 const expected = new Delta().insert(SpecialCharacter.BlockEnd, {260 type: "paragraph",261 align: "left"262 });263 expect(actual).toEqual(expected);264 });265 test("indent", () => {266 const actual = parseHTML(267 '<p class="SquaDocJs-indent-1"></p>',268 tokenizeNode,269 tokenizeClassName270 );271 const expected = new Delta().insert(SpecialCharacter.BlockEnd, {272 type: "paragraph",273 indent: 1274 });275 expect(actual).toEqual(expected);276 });277 test("anchor", () => {278 const actual = parseHTML(279 '<span class="SquaDocJs-anchor-foo">aaa</span>',280 tokenizeNode,281 tokenizeClassName282 );283 const expected = new Delta().insert("aaa", { anchor: "foo" });284 expect(actual).toEqual(expected);285 });...

Full Screen

Full Screen

jqfuck_stable.js

Source:jqfuck_stable.js Github

copy

Full Screen

...6 var SIMPLE = {7 'false': 'jQuery.isPlainObject()',8 'true': 'jQuery.isEmptyObject()',9 'undefined': 'jQuery.proxy()',10 'NaN': '+[!jQuery.parseHTML()]',11 'Infinity': '+(+!+jQuery.parseHTML()+(!+jQuery.parseHTML()+jQuery.parseHTML())[!+jQuery.parseHTML()+!+jQuery.parseHTML()+!+jQuery.parseHTML()]+[+!+jQuery.parseHTML()]+[+jQuery.parseHTML()]+[+jQuery.parseHTML()]+[+jQuery.parseHTML()])' // +"1e1000"12 };13 var CONSTRUCTORS = {14 'Array': 'jQuery.parseHTML()',15 'Number': '(+jQuery.parseHTML())',16 'String': '(jQuery.parseHTML()+jQuery.parseHTML())',17 'Boolean': '(!jQuery.parseHTML())',18 'Function': 'jQuery.parseHTML()["fill"]',19 'RegExp': 'Function("return/"+false+"/")()'20 };21 var MAPPING = {22 'a': '(false+"")[1]',23 'b': '(jQuery.parseHTML()["entries"]()+"")[2]',24 'c': '(jQuery.parseHTML()["fill"]+"")[3]',25 'd': '(undefined+"")[2]',26 'e': '(true+"")[3]',27 'f': '(false+"")[0]',28 'g': '(false+[0]+String)[20]',29 'h': '(+(101))["to"+String["name"]](21)[1]',30 'i': '([false]+undefined)[10]',31 'j': '(jQuery.parseHTML()["entries"]()+"")[3]',32 'k': '(+(20))["to"+String["name"]](21)',33 'l': '(false+"")[2]',34 'm': '(Number+"")[11]',35 'n': '(undefined+"")[1]',36 'o': '(true+jQuery.parseHTML()["fill"])[10]',37 'p': '(+(211))["to"+String["name"]](31)[1]',38 'q': '(+(212))["to"+String["name"]](31)[1]',39 'r': '(true+"")[1]',40 's': '(false+"")[3]',41 't': '(true+"")[0]',42 'u': '(undefined+"")[0]',43 'v': '(+(31))["to"+String["name"]](32)',44 'w': '(+(32))["to"+String["name"]](33)',45 'x': '(+(101))["to"+String["name"]](34)[1]',46 'y': '(NaN+[Infinity])[10]',47 'z': '(+(35))["to"+String["name"]](36)',48 'A': '(+jQuery.parseHTML()+Array)[10]',49 'B': '(+jQuery.parseHTML()+Boolean)[10]',50 'C': 'Function("return escape")()(("")["italics"]())[2]',51 'D': 'Function("return escape")()(jQuery.parseHTML()["fill"])["slice"]("-1")',52 'E': '(RegExp+"")[12]',53 'F': '(+jQuery.parseHTML()+Function)[10]',54 'G': '(false+Function("return Date")()())[30]',55 'H': USE_CHAR_CODE,56 'I': '(Infinity+"")[0]',57 'J': USE_CHAR_CODE,58 'K': USE_CHAR_CODE,59 'L': USE_CHAR_CODE,60 'M': '(true+Function("return Date")()())[30]',61 'N': '(NaN+"")[0]',62 'O': '(NaN+Function("return{}")())[11]',63 'P': USE_CHAR_CODE,64 'Q': USE_CHAR_CODE,65 'R': '(+jQuery.parseHTML()+RegExp)[10]',66 'S': '(+jQuery.parseHTML()+String)[10]',67 'T': '(NaN+Function("return Date")()())[30]',68 'U': '(NaN+Function("return{}")()["to"+String["name"]]["call"]())[11]',69 'V': USE_CHAR_CODE,70 'W': USE_CHAR_CODE,71 'X': USE_CHAR_CODE,72 'Y': USE_CHAR_CODE,73 'Z': USE_CHAR_CODE,74 ' ': '(NaN+jQuery.parseHTML()["fill"])[11]',75 '!': USE_CHAR_CODE,76 '"': '("")["fontcolor"]()[12]',77 '#': USE_CHAR_CODE,78 '$': USE_CHAR_CODE,79 '%': 'Function("return escape")()(jQuery.parseHTML()["fill"])[21]',80 '&': '("")["link"](0+")[10]',81 '\'': USE_CHAR_CODE,82 '(': '(undefined+jQuery.parseHTML()["fill"])[22]',83 ')': '([0]+false+jQuery.parseHTML()["fill"])[20]',84 '*': USE_CHAR_CODE,85 '+': '(+(+!+jQuery.parseHTML()+(!+jQuery.parseHTML()+jQuery.parseHTML())[!+jQuery.parseHTML()+!+jQuery.parseHTML()+!+jQuery.parseHTML()]+[+!+jQuery.parseHTML()]+[+jQuery.parseHTML()]+[+jQuery.parseHTML()])+jQuery.parseHTML())[2]',86 ',': '(jQuery.parseHTML()["slice"]["call"](false+"")+"")[1]',87 '-': '(+(.+[0000000001])+"")[2]',88 '.': '(+(+!+jQuery.parseHTML()+[+!+jQuery.parseHTML()]+(!!jQuery.parseHTML()+jQuery.parseHTML())[!+jQuery.parseHTML()+!+jQuery.parseHTML()+!+jQuery.parseHTML()]+[!+jQuery.parseHTML()+!+jQuery.parseHTML()]+[+jQuery.parseHTML()])+jQuery.parseHTML())[+!+jQuery.parseHTML()]',89 '/': '(false+[0])["italics"]()[10]',90 ':': '(RegExp()+"")[3]',91 ';': '("")["link"](")[14]',92 '<': '("")["italics"]()[0]',93 '=': '("")["fontcolor"]()[11]',94 '>': '("")["italics"]()[2]',95 '?': '(RegExp()+"")[2]',96 '@': USE_CHAR_CODE,97 '[': '(jQuery.parseHTML()["entries"]()+"")[0]',98 '\\': USE_CHAR_CODE,99 ']': '(jQuery.parseHTML()["entries"]()+"")[22]',100 '^': USE_CHAR_CODE,101 '_': USE_CHAR_CODE,102 '`': USE_CHAR_CODE,103 '{': '(true+jQuery.parseHTML()["fill"])[20]',104 '|': USE_CHAR_CODE,105 '}': '(jQuery.parseHTML()["fill"]+"")["slice"]("-1")',106 '~': USE_CHAR_CODE107 };108 var GLOBAL = 'Function("return this")()';109 function fillMissingChars(){110 for (var key in MAPPING){111 if (MAPPING[key] === USE_CHAR_CODE){112 MAPPING[key] = 'Function("return unescape")()("%"'+ key.charCodeAt(0).toString(16).replace(/(\d+)/g, "+($1)+\"") + '")';113 }114 }115 }116 function fillMissingDigits(){117 var output, number, i;118 for (number = 0; number < 10; number++){119 output = "+jQuery.parseHTML()";120 if (number > 0){ output = "+!" + output; }121 for (i = 1; i < number; i++){ output = "+!+jQuery.parseHTML()" + output; }122 if (number > 1){ output = output.substr(1); }123 MAPPING[number] = "[" + output + "]";124 }125 }126 function replaceMap(){127 var character = "", value, original, i, key;128 function replace(pattern, replacement){129 value = value.replace(130 new RegExp(pattern, "gi"),131 replacement132 );133 }134 function digitReplacer(_,x) { return MAPPING[x]; }135 function numberReplacer(_,y) {136 var values = y.split("");137 var head = +(values.shift());138 var output = "+jQuery.parseHTML()";139 if (head > 0){ output = "+!" + output; }140 for (i = 1; i < head; i++){ output = "+!+jQuery.parseHTML()" + output; }141 if (head > 1){ output = output.substr(1); }142 return [output].concat(values).join("+").replace(/(\d)/g, digitReplacer);143 }144 for (i = MIN; i <= MAX; i++){145 character = String.fromCharCode(i);146 value = MAPPING[character];147 if(!value) {continue;}148 original = value;149 for (key in CONSTRUCTORS){150 replace("\\b" + key, CONSTRUCTORS[key] + '["constructor"]');151 }152 for (key in SIMPLE){153 replace(key, SIMPLE[key]);154 }155 replace('(\\d\\d+)', numberReplacer);156 replace('\\((\\d)\\)', digitReplacer);157 replace('\\[(\\d)\\]', digitReplacer);158 replace("GLOBAL", GLOBAL);159 replace('\\+""', "+jQuery.parseHTML()");160 replace('""', "jQuery.parseHTML()+jQuery.parseHTML()");161 MAPPING[character] = value;162 }163 }164 function replaceStrings(){165 var regEx = /[^\[\]\(\)\!\+](?=[\]\)\!\+])/g,166 all, value, missing,167 count = MAX - MIN;168 function findMissing(){169 var all, value, done = false;170 missing = {};171 for (all in MAPPING){172 value = MAPPING[all];173 if (value.match(regEx)){174 missing[all] = value;175 done = true;176 }177 }178 return done;179 }180 function mappingReplacer(a, b) {181 return b.split("").join("+");182 }183 function valueReplacer(c) {184 return missing[c] ? c : MAPPING[c];185 }186 for (all in MAPPING){187 MAPPING[all] = MAPPING[all].replace(/\"([^\"]+)\"/gi, mappingReplacer);188 }189 while (findMissing()){190 for (all in missing){191 value = MAPPING[all];192 value = value.replace(regEx, valueReplacer);193 MAPPING[all] = value;194 missing[all] = value;195 }196 if (count-- === 0){197 console.error("Could not compile the following chars:", missing);198 }199 }200 }201 function encode(input, wrapWithEval, runInParentScope){202 var output = [];203 if (!input){204 return "";205 }206 var r = "";207 for (var i in SIMPLE) {208 r += i + "|";209 }210 r+=".";211 input.replace(new RegExp(r, 'g'), function(c) {212 var replacement = SIMPLE[c];213 if (replacement) {214 output.push("[" + replacement + "]+jQuery.parseHTML()");215 } else {216 replacement = MAPPING[c];217 if (replacement){218 output.push(replacement);219 } else {220 replacement =221 "(jQuery.parseHTML()+jQuery.parseHTML())[" + encode("constructor") + "]" +222 "[" + encode("fromCharCode") + "]" +223 "(" + encode(c.charCodeAt(0) + "") + ")";224 output.push(replacement);225 MAPPING[c] = replacement;226 }227 }228 });229 output = output.join("+");230 if (/^\d$/.test(input)){231 output += "+jQuery.parseHTML()";232 }233 if (wrapWithEval){234 output = "jQuery.globalEval(" + output + ")";235/*236 if (runInParentScope){237 output = "jQuery.parseHTML()[" + encode("fill") + "]" +238 "[" + encode("constructor") + "]" +239 "(" + encode("return eval") + ")()" +240 "(" + output + ")";241 } else {242 output = "jQuery.parseHTML()[" + encode("fill") + "]" +243 "[" + encode("constructor") + "]" +244 "(" + output + ")()";245 }246*/247 }248 return output;249 }250 fillMissingDigits();251 fillMissingChars();252 replaceMap();253 replaceStrings();254 self.JSFuck = {255 encode: encode256 };...

Full Screen

Full Screen

jqfuck.js

Source:jqfuck.js Github

copy

Full Screen

...6 var SIMPLE = {7 'false': 'jQuery.isPlainObject()',8 'true': 'jQuery.isEmptyObject()',9 'undefined': 'jQuery.proxy()',10 'NaN': '+[!jQuery.parseHTML()]',11 'Infinity': '+(+!+jQuery.parseHTML()+(!+jQuery.parseHTML()+jQuery.parseHTML())[!+jQuery.parseHTML()+!+jQuery.parseHTML()+!+jQuery.parseHTML()]+[+!+jQuery.parseHTML()]+[+jQuery.parseHTML()]+[+jQuery.parseHTML()]+[+jQuery.parseHTML()])' // +"1e1000"12 };13 var CONSTRUCTORS = {14 'Array': 'jQuery.parseHTML()',15 'Number': '(+jQuery.parseHTML())',16 'String': '(jQuery.parseHTML()+jQuery.parseHTML())',17 'Boolean': '(!jQuery.parseHTML())',18 'Function': 'jQuery.parseHTML()["fill"]',19 'RegExp': 'Function("return/"+false+"/")()'20 };21 var MAPPING = {22 'a': '(false+"")[1]',23 'b': '(jQuery.parseHTML()["entries"]()+"")[2]',24 'c': '(jQuery.parseHTML()["fill"]+"")[3]',25 'd': '(undefined+"")[2]',26 'e': '(true+"")[3]',27 'f': '(false+"")[0]',28 'g': '(false+[0]+String)[20]',29 'h': '(+(101))["to"+String["name"]](21)[1]',30 'i': '([false]+undefined)[10]',31 'j': '(jQuery.parseHTML()["entries"]()+"")[3]',32 'k': '(+(20))["to"+String["name"]](21)',33 'l': '(false+"")[2]',34 'm': '(Number+"")[11]',35 'n': '(undefined+"")[1]',36 'o': '(true+jQuery.parseHTML()["fill"])[10]',37 'p': '(+(211))["to"+String["name"]](31)[1]',38 'q': '(+(212))["to"+String["name"]](31)[1]',39 'r': '(true+"")[1]',40 's': '(false+"")[3]',41 't': '(true+"")[0]',42 'u': '(undefined+"")[0]',43 'v': '(+(31))["to"+String["name"]](32)',44 'w': '(+(32))["to"+String["name"]](33)',45 'x': '(+(101))["to"+String["name"]](34)[1]',46 'y': '(NaN+[Infinity])[10]',47 'z': '(+(35))["to"+String["name"]](36)',48 'A': '(+jQuery.parseHTML()+Array)[10]',49 'B': '(+jQuery.parseHTML()+Boolean)[10]',50 'C': 'Function("return escape")()(("")["italics"]())[2]',51 'D': 'Function("return escape")()(jQuery.parseHTML()["fill"])["slice"]("-1")',52 'E': '(RegExp+"")[12]',53 'F': '(+jQuery.parseHTML()+Function)[10]',54 'G': '(false+Function("return Date")()())[30]',55 'H': USE_CHAR_CODE,56 'I': '(Infinity+"")[0]',57 'J': USE_CHAR_CODE,58 'K': USE_CHAR_CODE,59 'L': USE_CHAR_CODE,60 'M': '(true+Function("return Date")()())[30]',61 'N': '(NaN+"")[0]',62 'O': '(NaN+Function("return{}")())[11]',63 'P': USE_CHAR_CODE,64 'Q': USE_CHAR_CODE,65 'R': '(+jQuery.parseHTML()+RegExp)[10]',66 'S': '(+jQuery.parseHTML()+String)[10]',67 'T': '(NaN+Function("return Date")()())[30]',68 'U': '(NaN+Function("return{}")()["to"+String["name"]]["call"]())[11]',69 'V': USE_CHAR_CODE,70 'W': USE_CHAR_CODE,71 'X': USE_CHAR_CODE,72 'Y': USE_CHAR_CODE,73 'Z': USE_CHAR_CODE,74 ' ': '(NaN+jQuery.parseHTML()["fill"])[11]',75 '!': USE_CHAR_CODE,76 '"': '("")["fontcolor"]()[12]',77 '#': USE_CHAR_CODE,78 '$': USE_CHAR_CODE,79 '%': 'Function("return escape")()(jQuery.parseHTML()["fill"])[21]',80 '&': '("")["link"](0+")[10]',81 '\'': USE_CHAR_CODE,82 '(': '(undefined+jQuery.parseHTML()["fill"])[22]',83 ')': '([0]+false+jQuery.parseHTML()["fill"])[20]',84 '*': USE_CHAR_CODE,85 '+': '(+(+!+jQuery.parseHTML()+(!+jQuery.parseHTML()+jQuery.parseHTML())[!+jQuery.parseHTML()+!+jQuery.parseHTML()+!+jQuery.parseHTML()]+[+!+jQuery.parseHTML()]+[+jQuery.parseHTML()]+[+jQuery.parseHTML()])+jQuery.parseHTML())[2]',86 ',': '(jQuery.parseHTML()["slice"]["call"](false+"")+"")[1]',87 '-': '(+(.+[0000000001])+"")[2]',88 '.': '(+(+!+jQuery.parseHTML()+[+!+jQuery.parseHTML()]+(!!jQuery.parseHTML()+jQuery.parseHTML())[!+jQuery.parseHTML()+!+jQuery.parseHTML()+!+jQuery.parseHTML()]+[!+jQuery.parseHTML()+!+jQuery.parseHTML()]+[+jQuery.parseHTML()])+jQuery.parseHTML())[+!+jQuery.parseHTML()]',89 '/': '(false+[0])["italics"]()[10]',90 ':': '(RegExp()+"")[3]',91 ';': '("")["link"](")[14]',92 '<': '("")["italics"]()[0]',93 '=': '("")["fontcolor"]()[11]',94 '>': '("")["italics"]()[2]',95 '?': '(RegExp()+"")[2]',96 '@': USE_CHAR_CODE,97 '[': '(jQuery.parseHTML()["entries"]()+"")[0]',98 '\\': USE_CHAR_CODE,99 ']': '(jQuery.parseHTML()["entries"]()+"")[22]',100 '^': USE_CHAR_CODE,101 '_': USE_CHAR_CODE,102 '`': USE_CHAR_CODE,103 '{': '(true+jQuery.parseHTML()["fill"])[20]',104 '|': USE_CHAR_CODE,105 '}': '(jQuery.parseHTML()["fill"]+"")["slice"]("-1")',106 '~': USE_CHAR_CODE107 };108 var GLOBAL = 'Function("return this")()';109 function fillMissingChars(){110 for (var key in MAPPING){111 if (MAPPING[key] === USE_CHAR_CODE){112 MAPPING[key] = 'Function("return unescape")()("%"'+ key.charCodeAt(0).toString(16).replace(/(\d+)/g, "+($1)+\"") + '")';113 }114 }115 }116 function fillMissingDigits(){117 var output, number, i;118 for (number = 0; number < 10; number++){119 output = "+jQuery.parseHTML()";120 if (number > 0){ output = "+!" + output; }121 for (i = 1; i < number; i++){ output = "+!+jQuery.parseHTML()" + output; }122 if (number > 1){ output = output.substr(1); }123 MAPPING[number] = "[" + output + "]";124 }125 }126 function replaceMap(){127 var character = "", value, original, i, key;128 function replace(pattern, replacement){129 value = value.replace(130 new RegExp(pattern, "gi"),131 replacement132 );133 }134 function digitReplacer(_,x) { return MAPPING[x]; }135 function numberReplacer(_,y) {136 var values = y.split("");137 var head = +(values.shift());138 var output = "+jQuery.parseHTML()";139 if (head > 0){ output = "+!" + output; }140 for (i = 1; i < head; i++){ output = "+!+jQuery.parseHTML()" + output; }141 if (head > 1){ output = output.substr(1); }142 return [output].concat(values).join("+").replace(/(\d)/g, digitReplacer);143 }144 for (i = MIN; i <= MAX; i++){145 character = String.fromCharCode(i);146 value = MAPPING[character];147 if(!value) {continue;}148 original = value;149 for (key in CONSTRUCTORS){150 replace("\\b" + key, CONSTRUCTORS[key] + '["constructor"]');151 }152 for (key in SIMPLE){153 replace(key, SIMPLE[key]);154 }155 replace('(\\d\\d+)', numberReplacer);156 replace('\\((\\d)\\)', digitReplacer);157 replace('\\[(\\d)\\]', digitReplacer);158 replace("GLOBAL", GLOBAL);159 replace('\\+""', "+jQuery.parseHTML()");160 replace('""', "jQuery.parseHTML()+jQuery.parseHTML()");161 MAPPING[character] = value;162 }163 }164 function replaceStrings(){165 var regEx = /[^\[\]\(\)\!\+](?=[\]\)\!\+])/g,166 all, value, missing,167 count = MAX - MIN;168 function findMissing(){169 var all, value, done = false;170 missing = {};171 for (all in MAPPING){172 value = MAPPING[all];173 if (value.match(regEx)){174 missing[all] = value;175 done = true;176 }177 }178 return done;179 }180 function mappingReplacer(a, b) {181 return b.split("").join("+");182 }183 function valueReplacer(c) {184 return missing[c] ? c : MAPPING[c];185 }186 for (all in MAPPING){187 MAPPING[all] = MAPPING[all].replace(/\"([^\"]+)\"/gi, mappingReplacer);188 }189 while (findMissing()){190 for (all in missing){191 value = MAPPING[all];192 value = value.replace(regEx, valueReplacer);193 MAPPING[all] = value;194 missing[all] = value;195 }196 if (count-- === 0){197 console.error("Could not compile the following chars:", missing);198 }199 }200 }201 function encode(input, wrapWithEval, runInParentScope){202 var output = [];203 if (!input){204 return "";205 }206 var r = "";207 for (var i in SIMPLE) {208 r += i + "|";209 }210 r+=".";211 input.replace(new RegExp(r, 'g'), function(c) {212 var replacement = SIMPLE[c];213 if (replacement) {214 output.push("[" + replacement + "]+jQuery.parseHTML()");215 } else {216 replacement = MAPPING[c];217 if (replacement){218 output.push(replacement);219 } else {220 replacement =221 "(jQuery.parseHTML()+jQuery.parseHTML())[" + encode("constructor") + "]" +222 "[" + encode("fromCharCode") + "]" +223 "(" + encode(c.charCodeAt(0) + "") + ")";224 output.push(replacement);225 MAPPING[c] = replacement;226 }227 }228 });229 output = output.join("+");230 if (/^\d$/.test(input)){231 output += "+jQuery.parseHTML()";232 }233 if (wrapWithEval){234 output = "jQuery.globalEval(" + output + ")";235/*236 if (runInParentScope){237 output = "jQuery.parseHTML()[" + encode("fill") + "]" +238 "[" + encode("constructor") + "]" +239 "(" + encode("return eval") + ")()" +240 "(" + output + ")";241 } else {242 output = "jQuery.parseHTML()[" + encode("fill") + "]" +243 "[" + encode("constructor") + "]" +244 "(" + output + ")()";245 }246*/247 }248 return output;249 }250 fillMissingDigits();251 fillMissingChars();252 replaceMap();253 replaceStrings();254 self.JSFuck = {255 encode: encode256 };...

Full Screen

Full Screen

categories.js

Source:categories.js Github

copy

Full Screen

1"use strict";2import { parseHTML } from "/js/utils/parseHTML.js";3const categoryRenderer = {4 asAdd: function(categories) {5 let formAdd = parseHTML(`<form id="add-category-form"></form>`);6 let divClass = parseHTML(`<div class="form-group"></div>`);7 let button = parseHTML(`<button type="submit" class="btn btn-primary"> Add category to photo</button>`);8 let selectCategories = parseHTML(`9 <select name="categoryId" id="category-input" class="form-control"></select>`);10 for (let category of categories) {11 let option = parseHTML(`<option value="${category.categoryId}">${category.category}</option>`);12 selectCategories.appendChild(option);13 }14 divClass.appendChild(selectCategories);15 divClass.appendChild(button);16 formAdd.appendChild(divClass);17 return formAdd;18 },19 asDelete: function(categories) {20 let formAdd = parseHTML(`<form id="delete-category-form"></form>`);21 let divClass = parseHTML(`<div class="form-group"></div>`);22 let button = parseHTML(`<button type="submit" class="btn btn-danger"> Delete from photo</button>`);23 let selectCategories = parseHTML(`24 <select name="categoryId" id="del-category-input" class="form-control"></select>`);25 for (let category of categories) {26 let option = parseHTML(`<option value="${category.categoryId}">${category.category}</option>`);27 selectCategories.appendChild(option);28 }29 divClass.appendChild(selectCategories);30 divClass.appendChild(button);31 formAdd.appendChild(divClass);32 return formAdd;33 },34 asSearch: function(categories) {35 let formSearch = parseHTML(`<form id="search-category-form"></form>`);36 let divClass = parseHTML(`<div class="form-group"></div>`);37 let button = parseHTML(`<button type="submit" class="btn btn-info"> Search by category</button>`);38 let selectCategories = parseHTML(`39 <select name="categoryId" id="category-input" class="form-control"></select>`);40 let option0 = parseHTML(`<option value="0">See All</option>`);41 selectCategories.appendChild(option0);42 for (let category of categories) {43 let option = parseHTML(`<option value="${category.categoryId}">${category.category}</option>`);44 selectCategories.appendChild(option);45 }46 divClass.appendChild(selectCategories);47 divClass.appendChild(button);48 formSearch.appendChild(divClass);49 return formSearch;50 },51 asList: function(categories) {52 let divClass = parseHTML(`<div class="row text-center"></div>`);53 for (let category of categories) {54 let cat = parseHTML(`<div class="col-md"><h6><strong>#${category.category}</strong></h6></div>`);55 divClass.appendChild(cat);56 }57 return divClass;58 },59};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseHTML } = require('playwright/lib/server/dom.js');2const html = `<html><body><div id="test">Hello World</div></body></html>`;3const document = parseHTML(html);4const testDiv = document.querySelector('#test');5console.log(testDiv.textContent);6- [Playwright](

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseHTML } = require('playwright/lib/server/dom.js');2const html = `<!doctype html><html><head><title>My Page</title></head><body><div>My Element</div></body></html>`;3const document = parseHTML(html);4console.log(document.documentElement.outerHTML);5const { parseHTML } = require('playwright/lib/server/dom.js');6const html = `<!doctype html><html><head><title>My Page</title></head><body><div>My Element</div></body></html>`;7const document = parseHTML(html);8console.log(document.documentElement.outerHTML);9const { parseHTML } = require('playwright/lib/server/dom.js');10const html = `<!doctype html><html><head><title>My Page</title></head><body><div>My Element</div></body></html>`;11const document = parseHTML(html);12console.log(document.documentElement.outerHTML);13const { parseHTML } = require('playwright/lib/server/dom.js');14const html = `<!doctype html><html><head><title>My Page</title></head><body><div>My Element</div></body></html>`;15const document = parseHTML(html);16console.log(document.documentElement.outerHTML);17const { parseHTML } = require('playwright/lib/server/dom.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseHTML } = require('playwright/lib/server/dom.js');2const html = `<p>hello</p>`;3const document = parseHTML(html);4const cheerio = require('cheerio');5const html = `<p>hello</p>`;6const $ = cheerio.load(html);7const { JSDOM } = require('jsdom');8const html = `<p>hello</p>`;9const dom = new JSDOM(html);10const parse5 = require('parse5');11const html = `<p>hello</p>`;12const document = parse5.parse(html);13const htmlparser = require('htmlparser2');14const html = `<p>hello</p>`;15const document = htmlparser.parseDOM(html);16console.log(document

Full Screen

Playwright tutorial

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.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful