From ee02aec4dee50a0dfbcb5fcc7d0d99b298bceef4 Mon Sep 17 00:00:00 2001 From: Michael Roytman Date: Mon, 11 Feb 2019 16:03:01 -0500 Subject: [PATCH] add createWorkers function to handle Workers with urls across origins --- edx_proctoring/__init__.py | 2 +- edx_proctoring/static/proctoring/js/exam_action_handler.js | 7 ++++++- package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/edx_proctoring/__init__.py b/edx_proctoring/__init__.py index 2cd023286e2..828e316cd21 100644 --- a/edx_proctoring/__init__.py +++ b/edx_proctoring/__init__.py @@ -5,6 +5,6 @@ from __future__ import absolute_import # Be sure to update the version number in edx_proctoring/package.json -__version__ = '1.5.10' +__version__ = '1.5.11' default_app_config = 'edx_proctoring.apps.EdxProctoringConfig' # pylint: disable=invalid-name diff --git a/edx_proctoring/static/proctoring/js/exam_action_handler.js b/edx_proctoring/static/proctoring/js/exam_action_handler.js index a30bc231b70..6df53a76bfe 100644 --- a/edx_proctoring/static/proctoring/js/exam_action_handler.js +++ b/edx_proctoring/static/proctoring/js/exam_action_handler.js @@ -49,10 +49,15 @@ var edx = edx || {}; }); }; + function createWorker(url) { + var blob = new Blob(["importScripts('" + location.origin + url + "');"], { "type": 'application/javascript' }); + var blobUrl = window.URL.createObjectURL(blob); + return new Worker(blobUrl); + } function workerPromiseForEventNames(eventNames) { return function() { - var proctoringBackendWorker = new Worker(edx.courseware.proctored_exam.configuredWorkerURL); + var proctoringBackendWorker = createWorker(edx.courseware.proctored_exam.configuredWorkerURL); return new Promise(function(resolve, reject) { var responseHandler = function(e) { if (e.data.type === eventNames.successEventName) { diff --git a/package.json b/package.json index bf284dc50b9..8f9891bc9c2 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@edx/edx-proctoring", "//": "Be sure to update the version number in edx_proctoring/__init__.py", "//": "Note that the version format is slightly different than that of the Python version when using prereleases.", - "version": "1.5.10", + "version": "1.5.11", "main": "edx_proctoring/static/index.js", "repository": { "type": "git",