File: iframe.js

package info (click to toggle)
ckeditor 4.19.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 290,372 kB
  • sloc: javascript: 242,409; sh: 202; makefile: 64; python: 37; php: 15; xml: 5
file content (142 lines) | stat: -rw-r--r-- 4,763 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* bender-tags: editor */
/* bender-ckeditor-plugins: iframe,dialogadvtab,toolbar */

( function() {
	bender.editor = {
		config: {
			autoParagraph: false
		}
	};

	bender.test( {
		setUp: function() {
			// Cleanup editor content and set selection inside the editor
			// to make sure that iframe dialog has correct insertion range.
			this.editorBot.setHtmlWithSelection( '^' );
		},
		tearDown: function() {
			var dialog = CKEDITOR.dialog.getCurrent();

			if ( dialog ) {
				dialog.hide();
			}
		},

		'test load iframe': function() {
			var editor = this.editor,
				expected = '<iframe frameborder="0" height="500" scrolling="no" src="http://ckeditor.com"></iframe>';

			this.editorBot.setData( expected, function() {
				assertHtml( expected, editor.getData() );
			} );
		},

		'test load iframe with content': function() {
			var editor = this.editor;

			this.editorBot.setData( '<iframe frameborder="0" height="500" scrolling="no" src="http://ckeditor.com">foobar</iframe>', function() {
				assertHtml( '<iframe frameborder="0" height="500" scrolling="no" src="http://ckeditor.com"></iframe>' , editor.getData() );
			} );
		},

		'test create iframe': function() {
			var bot = this.editorBot;
			bot.dialog( 'iframe', function( dialog ) {
				dialog.setValueOf( 'info', 'src', 'http://ckeditor.com' );
				dialog.setValueOf( 'info', 'width', '100%' );
				dialog.setValueOf( 'info', 'height', '500' );
				dialog.setValueOf( 'advanced', 'advStyles', 'height:100px; width:100px;' );

				dialog.getButton( 'ok' ).click();

				assert.areEqual( '<iframe frameborder="0" height="500" scrolling="no" src="http://ckeditor.com" ' +
					'style="height:100px;width:100px;" width="100%"></iframe>', bot.getData( true ) );
			} );
		},

		'test update iframe': function() {
			var bot = this.editorBot, editor = this.editor;

			bot.setHtmlWithSelection( editor.dataProcessor.toHtml( '[<iframe frameborder="0" scrolling="no" src="http://ckeditor.com" width="100%"></iframe>]' ) );

			bot.dialog( 'iframe', function( dialog ) {
				assert.areSame( 'http://ckeditor.com', dialog.getValueOf( 'info', 'src' ) );
				assert.areSame( '100%', dialog.getValueOf( 'info', 'width' ) );

				dialog.setValueOf( 'info', 'src', 'http://cksource.com' );
				dialog.setValueOf( 'info', 'width', '400' );

				dialog.getButton( 'ok' ).click();

				assert.areEqual( '<iframe frameborder="0" scrolling="no" src="http://cksource.com" width="400"></iframe>', bot.getData( true ) );
			} );
		},

		// (#2423)
		'test dialog model during iframe creation': function() {
			var bot = this.editorBot,
				editor = this.editor;

			bot.setData( '', function() {
				bot.dialog( 'iframe', function( dialog ) {
					assert.isNull( dialog.getModel( editor ) );
					assert.areEqual( CKEDITOR.dialog.CREATION_MODE, dialog.getMode( editor ) );
				} );
			} );
		},

		// (#2423)
		'test dialog model with existing iframe': function() {
			var bot = this.editorBot,
				editor = this.editor,
				iframeHtml = '<iframe frameborder="0" scrolling="no" src="http://ckeditor.com" width="100%"></iframe>';

			bot.setData( iframeHtml, function() {
				bot.dialog( 'iframe', function( dialog ) {
					var iframe = editor.editable().findOne( '.cke_iframe' );

					editor.getSelection().selectElement( iframe );

					assert.areEqual( iframe, dialog.getModel( editor ) );
					assert.areEqual( CKEDITOR.dialog.EDITING_MODE, dialog.getMode( editor ) );
				} );
			} );
		},

		// (#4388)
		'test disabling iframe from tabindex': function() {
			var bot = this.editorBot,
				editor = this.editor;

			bot.setHtmlWithSelection( editor.dataProcessor.toHtml( '[<iframe frameborder="0" scrolling="no" src="http://ckeditor.com" width="100%"></iframe>]' ) );

			bot.dialog( 'iframe', function( dialog ) {
				dialog.setValueOf( 'info', 'tabindex', true );

				dialog.getButton( 'ok' ).click();

				assert.areEqual( '<iframe frameborder="0" scrolling="no" src="http://ckeditor.com" tabindex="-1" width="100%"></iframe>', bot.getData( true ) );
			} );
		},

		// (#4388)
		'test adding iframe back to tabindex': function() {
			var bot = this.editorBot,
				editor = this.editor;

			bot.setHtmlWithSelection( editor.dataProcessor.toHtml( '[<iframe frameborder="0" scrolling="no" src="http://ckeditor.com" tabindex="-1" width="100%"></iframe>]' ) );

			bot.dialog( 'iframe', function( dialog ) {
				dialog.setValueOf( 'info', 'tabindex', false );

				dialog.getButton( 'ok' ).click();

				assert.areEqual( '<iframe frameborder="0" scrolling="no" src="http://ckeditor.com" width="100%"></iframe>', bot.getData( true ) );
			} );
		}
	} );

	function assertHtml( expected, actual, msg ) {
		assert.areEqual( bender.tools.fixHtml( expected ), bender.tools.fixHtml( actual ), msg );
	}
} )();