Bug ID 1169673: The MouseEvent() constructor throws an error in portal access

Last Modified: Apr 28, 2025

Affected Product(s):
BIG-IP APM(all modules)

Known Affected Versions:
15.1.5, 15.1.5.1, 15.1.6, 15.1.6.1, 15.1.7, 15.1.8, 15.1.8.1, 15.1.8.2, 15.1.9, 15.1.9.1, 15.1.10, 15.1.10.2, 15.1.10.3, 15.1.10.4, 15.1.10.5, 15.1.10.6

Opened: Oct 11, 2022

Severity: 3-Major

Symptoms

The MouseEvent() constructor throws an error: Uncaught TypeError: Failed to construct 'MouseEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function

Impact

Applications may break when accessed via portal access

Conditions

When below javascript is accessed via portal access: new MouseEvent('Click')

Workaround

Use a custom iRule to add polyfill to MouseEvent when REWRITE_REQUEST_DONE { if { [HTTP::path] contains "file" //htmlfile name } { set flgx 1 REWRITE::post_process 1 } } when REWRITE_RESPONSE_DONE { if {[info exists flgx]} { unset flgx set str {if(typeof(F5_flush)} set strt [string first $str [REWRITE::payload]] if {$strt > 0} { REWRITE::payload replace $strt 0 { (function (window) { // Polyfills DOM4 MouseEvent const MouseEventPolyfill = function (eventType, params) { params = params || { bubbles: false, cancelable: false }; const mouseEvent = document.createEvent('MouseEvent'); mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, window, 0, params.screenX || 0, params.screenY || 0, params.clientX || 0, params.clientY || 0, params.ctrlKey || false, params.altKey || false, params.shiftKey || false, params.metaKey || false, params.button || 0, params.relatedTarget || null ); return mouseEvent; } MouseEventPolyfill.prototype = Event.prototype; window.MouseEvent = MouseEventPolyfill; })(window); } } } }

Fix Information

None

Behavior Change

Guides & references

K10134038: F5 Bug Tracker Filter Names and Tips