diff --git a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js index 0f34691..029bc9e 100644 --- a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js @@ -305,7 +305,7 @@ // @see Drupal.Ajax.prototype.beforeSerialize ajaxObject.beforeSerialize = function (element_settings, options) { formData.append('files[fid]', file); - $.each(this.$form.serializeArray(), function (k, v) { + this.$form.serializeArray().forEach(function (v) { formData[v.name] = v.value; formData.append(v.name, v.value); }); @@ -448,10 +448,10 @@ */ function getAjaxObject(id) { var ajaxInstance = null; - $.each(Drupal.ajax.instances, function (k, v) { + Drupal.ajax.instances.forEach(function (v, k) { if (v !== null && v.selector === id) { ajaxInstance = Drupal.ajax.instances[k]; - return ajaxInstance; + return false; } }); return ajaxInstance; diff --git a/core/modules/ckeditor/tests/src/FunctionalJavascript/DrupalImageDragAndDropTest.php b/core/modules/ckeditor/tests/src/FunctionalJavascript/DrupalImageDragAndDropTest.php new file mode 100644 index 0000000..f11d806 --- /dev/null +++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/DrupalImageDragAndDropTest.php @@ -0,0 +1,107 @@ + 'filtered_html', + 'name' => 'Filtered HTML', + 'weight' => 0, + 'filters' => [], + ]); + $filtered_html_format->save(); + $editor = Editor::create([ + 'format' => 'filtered_html', + 'editor' => 'ckeditor', + ]); + $editor->save(); + + // Create node type. + $this->drupalCreateContentType(array( + 'type' => 'article', + 'name' => 'Article', + )); + + $admin_user = $this->drupalCreateUser([ + 'create article content', + 'edit any article content', + 'use text format filtered_html', + ]); + $this->drupalLogin($admin_user); + } + + /** + * Tests if an image can be uploaded via drag-and-drop in a CKEditor instance. + */ + public function testDragAndDrop() { + + $this->drupalGet('node/add/article'); + $session = $this->getSession(); + $page = $session->getPage(); + + $content = $page->find('css', '.cke_contents'); + $this->assertTrue($content->isVisible(), 'CKEditor content area is visible.'); + + $javascript = <<assertSession(); +// $asserted_session->assertWaitOnAjaxRequest(); + $session->executeScript($javascript); + // Click the submit button on the dialog + $session->executeScript("jQuery('.editor-image-dialog .js-form-submit').trigger('click');"); + // Assert that the dialog has been closed. + $this->assertJsCondition("jQuery('.editor-drupal-dialog').length === 0", 5000); + // The dropped image should be visible inside the CKEditor instance. + $this->createScreenshot('public://screenshot.jpg'); + $this->assertFileExists('public://screenshot.jpg'); + } + +}