@@ -189,6 +189,8 @@ const PDFViewerApplication = {
189
189
externalServices : DefaultExternalServices ,
190
190
_boundEvents : { } ,
191
191
contentDispositionFilename : null ,
192
+ _hasInteracted : false ,
193
+ _delayedFallbackFeatureIds : [ ] ,
192
194
193
195
// Called once when the document is loaded.
194
196
async initialize ( appConfig ) {
@@ -867,11 +869,20 @@ const PDFViewerApplication = {
867
869
typeof PDFJSDev === "undefined" ||
868
870
PDFJSDev . test ( "MOZCENTRAL || GENERIC" )
869
871
) {
872
+ // For PDFs that contain script and form errors, we should only trigger
873
+ // the fallback once the user has interacted with the page.
874
+ if ( this . _delayedFallbackFeatureIds . length === 2 && this . _hasInteracted ) {
875
+ featureId = this . _delayedFallbackFeatureIds [ 0 ] ;
876
+ // Reset to prevent all click events from showing fallback bar.
877
+ this . _delayedFallbackFeatureIds = [ ] ;
878
+ }
879
+
870
880
// Only trigger the fallback once so we don't spam the user with messages
871
881
// for one PDF.
872
882
if ( this . fellback ) {
873
883
return ;
874
884
}
885
+
875
886
this . fellback = true ;
876
887
this . externalServices . fallback (
877
888
{
@@ -1235,7 +1246,7 @@ const PDFViewerApplication = {
1235
1246
return false ;
1236
1247
}
1237
1248
console . warn ( "Warning: JavaScript is not supported" ) ;
1238
- this . fallback ( UNSUPPORTED_FEATURES . javaScript ) ;
1249
+ this . _delayedFallbackFeatureIds . push ( UNSUPPORTED_FEATURES . javaScript ) ;
1239
1250
return true ;
1240
1251
} ) ;
1241
1252
@@ -1317,7 +1328,7 @@ const PDFViewerApplication = {
1317
1328
1318
1329
if ( info . IsAcroFormPresent ) {
1319
1330
console . warn ( "Warning: AcroForm/XFA is not supported" ) ;
1320
- this . fallback ( UNSUPPORTED_FEATURES . forms ) ;
1331
+ this . _delayedFallbackFeatureIds . push ( UNSUPPORTED_FEATURES . forms ) ;
1321
1332
}
1322
1333
1323
1334
if (
@@ -2473,6 +2484,17 @@ function webViewerWheel(evt) {
2473
2484
}
2474
2485
2475
2486
function webViewerClick ( evt ) {
2487
+ PDFViewerApplication . _hasInteracted = true ;
2488
+
2489
+ // Avoid triggering the fallback bar when the user clicks on the
2490
+ // toolbar or sidebar.
2491
+ if (
2492
+ PDFViewerApplication . _delayedFallbackFeatureIds . length === 2 &&
2493
+ PDFViewerApplication . pdfViewer . containsElement ( evt . target )
2494
+ ) {
2495
+ PDFViewerApplication . fallback ( ) ;
2496
+ }
2497
+
2476
2498
if ( ! PDFViewerApplication . secondaryToolbar . isOpen ) {
2477
2499
return ;
2478
2500
}
0 commit comments