Skip to content

Commit

Permalink
[FIX] web: prevent traceback in edit mode with embedded video
Browse files Browse the repository at this point in the history
Since [this other commit], initializing the color picker could trigger a
traceback. The traceback was due to the fact that for users to be able
to drag/move the color picker as they wished across different frames, we
needed access to the document of all the frames on the page.
Unfortunately, if one of these frames was not of the same origin, a
traceback was displayed. This commit corrects how we collect documents
from frames on the page, by only taking those whose document we have the
right to see (which do not raise a cross origin error). I didn't succeed
to reproduce the bug locally, but I got it on the runbot with theme
Nursery / Kiddo by dropping the block banner on the page, the error
appears because the block contains a vimeo video. In fact, you just need
to have embedded content (youtube / vimeo / ... video for example) start
edit mode, click on the block containing the video and the error is
displayed.

[this other commit]: odoo@63bf363

runbot-22573

closes odoo#126240

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
  • Loading branch information
Guillaume-gdi committed Jun 23, 2023
1 parent 6c5b702 commit 8ff33c7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion addons/web/static/src/legacy/js/widgets/colorpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ var ColorpickerWidget = Widget.extend({
// anywhere on the screen, crossing iframes).
// TODO adapt in master: these events should probably be bound in
// `start` instead of `init` (at least to be more conventional).
this.$documents = $([window.top, ...Array.from(window.top.frames)].map(w => w.document));
this.$documents = $([window.top, ...Array.from(window.top.frames).filter(frame => {
try {
const document = frame.document;
return !!document;
} catch (error) {
// We cannot access the document (cross origin).
return false;
}
})].map(w => w.document));
this.$documents.on(`mousemove.${this.uniqueId}`, _.throttle((ev) => {
this._onMouseMovePicker(ev);
this._onMouseMoveSlider(ev);
Expand Down

0 comments on commit 8ff33c7

Please sign in to comment.