From 651231fbc136ad2574c18d837151aa4dd6c2306e Mon Sep 17 00:00:00 2001 From: ispedals Date: Sat, 18 Jun 2016 18:35:41 -0400 Subject: Use iFrame srcdoc attribute to set the content of the popup Previously the contentdocument of the iFrame was opened and document.write() was being used set the contents of the popup. In Gecko, content scripts do not have the same security context as of the embedded page, so the call to document.open() results in a SecurityError. --- ext/fg/js/popup.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 78106319..4c2b18f7 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -62,10 +62,8 @@ class Popup { return; } - const doc = this.popup.contentDocument; - doc.open(); - doc.write(content); - doc.close(); + const doc = this.popup; + doc.srcdoc=content; } sendMessage(action, params, callback) { -- cgit v1.2.3 From 099d48ef48a065001a6b4a0ab29c567935af1f25 Mon Sep 17 00:00:00 2001 From: ispedals Date: Sat, 18 Jun 2016 18:52:02 -0400 Subject: Polyfill caretRangeFromPoint() Gecko did not implment the older caretRangeFromPoint() and instead implemented the newer caretPositionFromPoint() --- ext/fg/js/range.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ext/fg/js') diff --git a/ext/fg/js/range.js b/ext/fg/js/range.js index 182e242c..0befe279 100644 --- a/ext/fg/js/range.js +++ b/ext/fg/js/range.js @@ -16,6 +16,19 @@ * along with this program. If not, see . */ +// Polyfill caretRangeFromPoint() using the newer caretPositionFromPoint() +if (!document.caretRangeFromPoint){ + document.caretRangeFromPoint = function polyfillcaretRangeFromPoint(x,y){ + let range = document.createRange(); + let position = document.caretPositionFromPoint(x,y); + if (!position) { + return null; + } + range.setStart(position.offsetNode, position.offset); + range.setEnd(position.offsetNode, position.offset); + return range; + }; +} class Range { constructor(range) { -- cgit v1.2.3