Skip to content

Commit 7ffa87f

Browse files
committed
Add Object.setPrototypeOf polyfill for shinytest and update shinytest json baseline
1 parent 397e289 commit 7ffa87f

File tree

16 files changed

+110
-1920
lines changed

16 files changed

+110
-1920
lines changed

R/plotly.R

+20
Original file line numberDiff line numberDiff line change
@@ -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+
435455
typedArrayPolyfill <- function() {
436456
htmltools::htmlDependency(
437457
name = "typedarray",

inst/docker/Dockerfile.vtest

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ RUN R -e "install.packages('assertthat')"
9494
RUN R -e "install.packages('testthat')"
9595
ARG CRANCACHE=1
9696
RUN R -e "update.packages(ask=FALSE)"
97+
RUN R -e "remotes::install_github('r-lib/vdiffr')"
9798

9899
# install any new dependencies, then either manage cases (the default) or run tests
99100
# note the workaround to get docker to run a proper exit status when there are testthat errors

0 commit comments

Comments
 (0)