How to use with_iframe method in wpt

Best JavaScript code snippet using wpt

mathjax-mock.js

Source:mathjax-mock.js Github

copy

Full Screen

1/* bender-tags: editor,widget */2/* bender-ckeditor-plugins: mathjax,dialog,toolbar,preview,clipboard,basicstyles,sourcearea */3/* global widgetTestsTools */4( function() {5 'use strict';6 CKEDITOR.disableAutoInline = true;7 var mathJaxLib = CKEDITOR.config.mathJaxLib = bender.config.mathJaxLibPath;8 if ( !mathJaxLib ) {9 throw new Error( 'bender.config.mathJaxLibPath should be defined with the path to MathJax lib (MathJax.js?config=TeX-AMS_HTML).' );10 }11 bender.editors = {12 classic: {13 name: 'classic'14 },15 integration_with_preview_plugin: {16 name: 'integration_with_preview_plugin',17 config: {18 mathJaxLib: 'http://mathJaxLib-mock'19 }20 },21 with_iframe: {22 name: 'with_iframe',23 config: {24 extraPlugins: 'iframe'25 }26 },27 only_one_widget: {28 name: 'only_one_widget',29 config: {30 extraPlugins: 'iframe'31 }32 }33 };34 var tools = widgetTestsTools,35 tcs = {36 init: function() {37 // frameWrapper mock38 CKEDITOR.plugins.mathjax.frameWrapper = function() {39 return {40 setValue: function() {}41 };42 };43 },44 'test dialog trim MathJax tags': function() {45 var editor = this.editors.classic;46 editor.openDialog( 'mathjax', function( dialog ) {47 var widgetMock = { data: { math: ' \\( X \\(1 + 1 = 2\\) Y \\) ' } };48 dialog.on( 'show', function() {49 dialog.setupContent( widgetMock );50 setTimeout( function() {51 resume( function() {52 assert.areSame( ' X \\(1 + 1 = 2\\) Y ', dialog.getValueOf( 'info', 'equation' ),53 'Dialog should leave sub string from first \\( to last \\).' );54 dialog.getButton( 'cancel' ).click();55 } );56 }, 50 );57 } );58 } );59 wait();60 },61 'test integration with preview plugin': function() {62 var editor = this.editors.integration_with_preview_plugin;63 editor.once( 'contentPreview', function( evt ) {64 evt.cancel();65 resume( function() {66 assert.isTrue( !!evt.data.dataValue.match(67 new RegExp( '<script src="' + bender.tools.escapeRegExp( 'http://mathJaxLib-mock' ) + '([^"]+)?">' )68 ) );69 } );70 } );71 editor.execCommand( 'preview' );72 wait();73 },74 'test conflict with iframe plugin': function() {75 var editor = this.editors.with_iframe;76 editor.on( 'afterPaste', function() {77 resume( function() {78 assert.areSame( 2, editor.document.getElementsByTag( 'iframe' ).count(), 'There should be two iFrames.' );79 } );80 } );81 editor.focus();82 bender.tools.emulatePaste( editor, editor.document.getElementsByTag( 'p' ).getItem( 0 ).$.innerHTML );83 wait();84 },85 'test not a widget': function() {86 var editor = this.editors.only_one_widget;87 assert.areSame( 1, editor.document.getElementsByTag( 'iframe' ).count(), 'There should be only one widget.' );88 },89 // http://dev.ckeditor.com/ticket/1177790 'test &amp; encoding': function() {91 var editor = this.editors.classic,92 bot = this.editorBots.classic;93 // Create an empty mathjax widget and set the content later, in WYSIWYG mode.94 bot.setData( '<p><span class="math-tex">\\(\\)</span></p>', function() {95 var widget = tools.obj2Array( editor.widgets.instances )[ 0 ],96 data;97 widget.setData( 'math', '\\(&\\)' );98 data = editor.getData();99 // Check if it is not possible to create a text node with not encoded ampersand.100 assert.areSame( '<p><span class="math-tex">\\(&amp;\\)</span></p>', data );101 bot.setData( data, function() {102 assert.areSame( '<p><span class="math-tex">\\(&amp;\\)</span></p>', editor.getData(), '& should not change after loading data.' );103 widget = tools.obj2Array( editor.widgets.instances )[ 0 ];104 assert.areSame( '\\(&\\)', widget.data.math, 'data.math was loaded correctly' );105 } );106 } );107 },108 // http://dev.ckeditor.com/ticket/11777109 'test &amp;amp; encoding': function() {110 var editor = this.editors.classic,111 bot = this.editorBots.classic;112 // Create an empty mathjax widget and set the content later, in WYSIWYG mode.113 bot.setData( '<p><span class="math-tex">\\(\\)</span></p>', function() {114 var widget = tools.obj2Array( editor.widgets.instances )[ 0 ],115 data;116 widget.setData( 'math', '\\(&amp;\\)' );117 data = editor.getData();118 assert.areSame( '<p><span class="math-tex">\\(&amp;amp;\\)</span></p>', data, '&amp; should be encoded properly.' );119 bot.setData( data, function() {120 assert.areSame( '<p><span class="math-tex">\\(&amp;amp;\\)</span></p>', editor.getData(), '&amp; should not change after loading data.' );121 widget = tools.obj2Array( editor.widgets.instances )[ 0 ];122 assert.areSame( '\\(&amp;\\)', widget.data.math, 'data.math was loaded correctly' );123 } );124 } );125 }126 };127 tools.addTests( tcs, {128 name: 'default',129 widgetName: 'mathjax',130 extraPlugins: 'mathjax',131 extraAllowedContent: 'span{padding}',132 initialInstancesNumber: 2,133 dialog: 'mathjax',134 newData: [135 [ 'info', 'equation', '2 + 2 = 4' ]136 ],137 newWidgetPattern: /<span class="math-tex">\\\(2 \+ 2 = 4\\\)<\/span>/,138 ignoreStyle: ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) ? true : false139 } );140 tools.addTests( tcs, {141 name: 'customClass',142 widgetName: 'mathjax',143 extraPlugins: 'mathjax',144 extraAllowedContent: 'span{padding}',145 editorConfig: {146 mathJaxClass: 'mjx'147 },148 initialInstancesNumber: 2,149 dialog: 'mathjax',150 newData: [151 [ 'info', 'equation', '2 + 2 = 4' ]152 ],153 newWidgetPattern: /<span class="mjx">\\\(2 \+ 2 = 4\\\)<\/span>/,154 ignoreStyle: ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) ? true : false155 } );156 tools.addTests( tcs, {157 name: 'inline',158 creator: 'inline',159 widgetName: 'mathjax',160 extraPlugins: 'mathjax',161 extraAllowedContent: 'span{padding}',162 initialInstancesNumber: 2,163 dialog: 'mathjax',164 newData: [165 [ 'info', 'equation', '2 + 2 = 4' ]166 ],167 newWidgetPattern: /<span class="math-tex">\\\(2 \+ 2 = 4\\\)<\/span>/,168 ignoreStyle: ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) ? true : false169 } );170 bender.test( tcs );...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wptdriver');2var driver = new wpt.WebDriver();3driver.with_iframe(0, function() {4 driver.findElement(wpt.By.css('#test')).then(function(element) {5 element.click();6 });7});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt 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