@@ -424,6 +424,15 @@ as_widget <- function(x, ...) {
424424 ),
425425 preRenderHook = plotly_build ,
426426 dependencies = c(
427+ # phantomjs doesn't support Object.setPrototypeOf() and a
428+ # plotly.js dependency (buffer) uses it to detect TypedArray support.
429+ # Thus, we add a polyfill if this is running in shinytest, but otherwise
430+ # we shouldn't need it because Object.setPrototypeOf() is pretty widely supported
431+ # https://github.com/plotly/plotly.js/issues/4556#issuecomment-583061419
432+ # https://caniuse.com/#search=setPrototypeOf
433+ if (isTRUE(getOption(" shiny.testmode" ))) {
434+ list (setPrototypeOfPolyfill())
435+ },
427436 list (typedArrayPolyfill()),
428437 crosstalk :: crosstalkLibs(),
429438 list (plotlyHtmlwidgetsCSS()),
@@ -432,6 +441,17 @@ as_widget <- function(x, ...) {
432441 )
433442}
434443
444+ setPrototypeOfPolyfill <- function () {
445+ htmltools :: htmlDependency(
446+ name = " setprototypeof" ,
447+ version = " 0.1" ,
448+ package = " plotly" ,
449+ src = dependency_dir(" setprototypeof" ),
450+ script = " setprototypeof.js" ,
451+ all_files = FALSE
452+ )
453+ }
454+
435455typedArrayPolyfill <- function () {
436456 htmltools :: htmlDependency(
437457 name = " typedarray" ,
0 commit comments