Opened 8 years ago

Closed 6 years ago

#6497 closed Bug (expired)

insertHtml method JS error on Webkit browsers, failing

Reported by: George Vilches Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Safari Cc:

Description

Steps to replicate:

  1. Go to http://ckeditor.com/demo
  2. Open your browser's debug console of choice.
  3. Do not focus on the editor.
  4. Execute this JS in your console: CKEDITOR.instanceseditor1?.insertHtml("test");

Results on Safari 5.0.2 (no insert occurs): TypeError: Result of expression 'H' [null] is not an object.

Results on Chrome 7.0.517.41 (no insert occurs): TypeError: Cannot call method 'scrollIntoView' of null

Firefox 3.6 works fine.

If you focus the window first, Chrome also works fine. Safari is still finicky about it, the dev console tends to take focus away, but if you can run that snippet in a way that doesn't lose focus, it inserts fine.

Attachments (1)

webkit_focus_switch.html (1.0 KB) - added by Garry Yao 8 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 8 years ago by George Vilches

I screwed up the WikiFormatting.

Step 4:

CKEDITOR.instances['editor1'].insertHtml("test");

comment:2 Changed 8 years ago by Garry Yao

Keywords: Safari added
Milestone: CKEditor 3.4.2
Status: newconfirmed

comment:3 Changed 8 years ago by Garry Yao

Resolution: invalid
Status: confirmedclosed

the dev console tends to take focus away...

You're right, WFM with the following executed in address bar: javascript:void(CKEDITOR.instances['editor1'].insertHtml("test"))

comment:4 Changed 8 years ago by George Vilches

Are you absolutely sure of this? I have run that on both Safari 5.0.2 and Chrome (on Mac OSX if it makes any difference), and I get the same problem still on demo.ckeditor.com as described in the core of the ticket. I have tried on multiple computers to make sure:

javascript:void(CKEDITOR.instances['editor1'].insertHtml("test"))

Just like that. I have not tested this problem on Windows browsers. Would a screenshot help demonstrate that I am demoing this correctly on the expressed versions?

comment:5 Changed 8 years ago by George Vilches

More information that hopefully will help:

I tested against the nightly: http://nightly.ckeditor.com/5987/_samples/replacebyclass.html

In Chrome (OSX), this now works fine, even without the focus. Gives me the correct response.

In Safari 5.0.2 (OSX), this still errors, but now the error is: TypeError: Result of expression 'I' [null] is not an object.

In Safari 5.0.2 (Windows), this works fine.

So this error ONLY exists on Safari 5.0.2 for Mac (Snow Leopard), as of the nightlies. Does that help isolate the problem for you?

Thanks, George

comment:6 Changed 8 years ago by Garry Yao

Milestone: CKEditor 3.4.2
Resolution: invalid
Status: closedreopened

comment:7 Changed 8 years ago by Garry Yao

Status: reopenedpending

WFM with the following executed in address bar: >javascript:void(CKEDITOR.instances['editor1'].insertHtml("test"))

Ok, thanks for the confirmation, I got a prerequisite for this to work as well - the page must gaining focus at first, e.g. click on the page.

comment:8 Changed 8 years ago by George Vilches

I can confirm that is definitely still a problem I even went so far as to try:

javascript:void(CKEDITOR.instances['editor1'].focus()); javascript:void(CKEDITOR.instances['editor1'].insertHtml("test"));

and I still get the:

TypeError: Result of expression 'I' [null] is not an object.

As an aside, and this might be a separate bug, the .focus() method doesn't seem to be working very well on Safari 5.0.2 on Mac OSX. Whereas in Firefox's Firebug mode, the editor gets the focus, it's not in Safari. Could these be related problems?

Thanks, George

comment:9 Changed 8 years ago by George Vilches

Also, just on the off chance that I misunderstood you, I also tried clicking on the page in Safari several times before running the Javascript above (both yours and mine with the extra .focus() call), in the editor and just anywhere else on the page, and it made no difference.

comment:10 Changed 8 years ago by Garry Yao

Ok, George, I got the culprit that webkit, unlike any other browser, doesn't allow explicit focus switch from within a none-UI-thread (threads that started from a page event, including user interaction, page load, timeout), I suspect this originate from some of their security consideration or so, in this case the paste doesn't work properly because the editor is not focused at all. (identified by the focus outline around editor chrome)

I've uploaded a normalized test page for webkit, so you can confirm of it on Mac also, another important point to understand the severity of this bug is whether you can really reproduce in application, otherwise it would be enough to report Webkit a bug.

Changed 8 years ago by Garry Yao

Attachment: webkit_focus_switch.html added

comment:11 Changed 8 years ago by Garry Yao

The above theory is purely my own supposition, I did also some research ends in nothing, so it would be great to get a confirmation from webkit team.

comment:12 Changed 8 years ago by George Vilches

There's one exception to your Safari test page: Try running javascript:window.focusLoop() in the location bar. That actually works fine. (Safari seems to have more scope neediness than other browsers).

So I've created a demo page here: http://ckeditor.fcstudios.com/safari_insert.html

Doing it from a button does work on the nightlies in Safari 5.0.2, EXCEPT: the cursor position is jumping down a line on every insert. This does not happen in Firefox. Do you want me to file a separate bug for this, or are these related problems?

comment:13 in reply to:  12 Changed 8 years ago by Garry Yao

Doing it from a button does work on the nightlies in Safari 5.0.2, EXCEPT: the cursor position is jumping down a line on every insert. This does not happen in Firefox. Do you want me to file a separate bug for this, or are these related problems?

Nice catch, this bug is now at #6545.

comment:14 Changed 6 years ago by Piotrek Koszuliński

Resolution: expired
Status: pendingclosed
Note: See TracTickets for help on using tickets.
© 2003 – 2017 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy