PDFJS is incompatible with PhantomJS

Currently, I am developing an angular application that incorporates Mozilla's PDFJS library. However, during the unit testing phase of the project, it appears that PhantomJS is unable to locate certain components of the PDFJS library.

This is the specific error message being displayed:

PhantomJS 1.9.8 (Linux 0.0.0) ERROR
TypeError: 'undefined' is not a function (near '...}.bind(this), REJECTION_TI...')
at /home/[...]/bower_components/pdfjs-dist/build/pdf.js:1222

It is crucial for me to utilize PhantomJS due to my continuous integration infrastructure requirements.

Answer №1

It appears that the issue lies within the 'bind' function in your code.

PhantomJS versions older than 2.0 do not have native support for bind, which results in the error message 'undefined is not a function.' To fix this, you can use a polyfill solution. Check out these resources:

GitHub Issue: https://github.com/ariya/phantomjs/issues/10522

NPM Polyfill: https://www.npmjs.com/package/phantomjs-polyfill

If you prefer not to use NPM, there is also a polyfill available on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Polyfill

It seems that PhantomJS version 2.* now handles bind correctly, but I have not personally tested it yet.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing margins in CSS for various div elements

Update: I have included Javascript and Masonry tags in my project. Despite having modules of the same size, I am exploring how masonry can assist me. However, I find it a bit puzzling at the moment as I am not aiming to align elements of different sizes. I ...

GWT: The setInnerHTML method decodes attribute values before setting them

Upon receiving this specific string from the server-side: <a onclick="doit('&#39;')">...</a>, my goal is to set it as the inner HTML of an element. However, when attempting to use Element#setInnerHTML, the string ends up converti ...

Connect the <div> element to the Angular controller's element

We are faced with a rather intricate model within an AngularJS controller: function controller($scope) { $scope.model = { childmodel1: { childmodel2: { property1: 'abc', property2: 3, ...

The animation feature on the slideshow is dysfunctional

For this Vue component, I attempted to create a slideshow. The process is as follows: 1) Creating an array of all image sources to be included (array: pictures) 2) Initializing a variable(Count) to 0, starting from the beginning. 3) Adding v-bind:src=" ...

Main navigation category as parent and secondary category as a child menu in WordPress

Hello there, I am looking to create a navigation menu with parent categories displayed horizontally and child categories as corresponding submenus. For example, The parent categories would be Apple, Orange, and Mango Under Apple, we would have apple1, ...

Identify the opening of the console for the background page of a Chrome

Is it possible to detect when I click on the "Background Page" for my test plugin on the "chrome://extensions/" page? This question has been boggling my mind. Currently, whenever I open the background page, the console remains undocked. After reading a po ...

What is the procedure for invoking various functions upon the completion and loading of an iframe?

Is there a way to call different methods using JavaScript instead of the onload method, which calls the same method on loading and after loaded? I need to execute different functions - any suggestions? ...

What is causing some keyup values to not stay in the input field even when they are passed as parameters?

Currently facing an unusual issue related to processing time. The problem seems to be with a PIN input that consists of 4 inputs. You can observe the behavior in action on this stackblitz code snippet I have set up: https://stackblitz.com/edit/vue-fezgmd?f ...

Working with nested objects in a React functional component's state using TypeScript

In my React functional component state, I have a nested object that I can only access the first level of if I use the any type. export default function Detail() { const [user, setUser] = useState<any>({}); const { id } = useParams(); us ...

Nextjs is throwing an error saying that there is a TypeError with products.map not being a

When attempting to iterate through products in a json file, I encountered the error TypeError: products.map is not a function Below is the code snippet: import React from "react"; import Link from "next/link"; function shop({ products ...

Extract objects from a nested array using a specific identifier

In order to obtain data from a nested array of objects using a specific ID, I am facing challenges. My goal is to retrieve this data so that I can utilize it in Angular Gridster 2. Although I have attempted using array.filter, I have struggled to achieve t ...

What is the best way to incorporate React hooks into a for loop?

I am looking to dynamically append a container with a specified number of div elements based on the data in a JSON file. I attempted to include the logic within a for loop, but encountered errors in the process. If you're interested in checking out t ...

Elevate state in React to modify classNames of child elements

I have a structured set of data divided into 6 columns representing each level of the hierarchy. When a user makes selections, their chosen location is highlighted with a dynamic CSS class name and displays the relevant data list. I've managed to impl ...

The latest images are now visible in the table alongside the existing images that were previously added

When inserting images here, previously added images are displaying. Any solutions? Here is my view page <div class="col-md-2"> <form enctype="multipart/form-data" method="post" action="<?php echo base_url();?>admin_control/upl ...

Stop images from flipping while CSS animation is in progress

I've been developing a rock paper scissors game where two images shake to mimic the hand motions of the game when a button is clicked. However, I'm facing an issue where one of the images flips horizontally during the animation and then flips bac ...

Angular-UI keypress event allows users to interact with components and

I am facing challenges while using the keypress feature in the following code snippet- <div ng-controller="GBNController"> ... <input id="search-field" type="text" placeholder="JSON Query" ng-model="queryText" ui-keypress="{enter: foo()}"/> .. ...

Tips for converting JSON or an object into an array for iteration:

I have a JavaScript application that makes an API call and receives JSON data in return. From this JSON data, I need to select a specific object and iterate through it. The flow of my code is as follows: Service call -> GetResults Loop through Results ...

Fetching JSON data from an external URL using AngularJS

Check out this URL that shows JSON data in the browser: I attempted to store the data in a variable with the following code: $http.get('http://api.geosvc.com/rest/US/84606/nearby?apikey=4ff687893a7b468cb520b3c4e967c4da&d=20&pt=PostalCode& ...

What is the best way to randomly display an image from a JavaScript array within an HTML document?

I currently have this code in my HTML and JavaScript files, but I am having trouble with displaying images without using a URL in the JavaScript file. The images are located in my project folder. However, when I open the HTML file, the images do not appear ...

Executing a for-in loop that iterates through MongoDB operations

I am facing an issue with a function that looks like this... for(key in object){ db.collection.findOne(criteria, function(err, doc){ // ... db.collection.update(...); }) }; The problem is that the value of key keeps changing befor ...