Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-68896

SCORM error in Chrome because of "XHR in page dismissal" policy change

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      The following test should be repeated with these specific browsers:
      Chrome latest
      Firefox latest
      Safari latest
      Edge latest
      Make sure you use a different user in each browser, or clear all this users SCORM data prior to starting each test.

      1. Create a SCORM activity using the same package from the behat test ([^RuntimeBasicCalls_SCORM20043rdEdition.zip]).
      2. As a learner start an attempt and progress a couple of pages in. Note the title of the SCORM page you are on.
      3. Follow another link on the site, the navbar for instance. It must redirect the tab out of the SCORM activity.
      4. Navigate back to the course, and the SCORM activity and resume your attempt.
      5. You should be taken back to the last page that you were on.
      6. Progress one page and note the title
      7. Log out
      8. Log back in (this is to generate a new session cookie)
      9. Return to the SCORM activity, resume your attempt
      10. Confirm you get back to the last title
      Show
      The following test should be repeated with these specific browsers: Chrome latest Firefox latest Safari latest Edge latest Make sure you use a different user in each browser, or clear all this users SCORM data prior to starting each test. Create a SCORM activity using the same package from the behat test ( [^RuntimeBasicCalls_SCORM20043rdEdition.zip] ). As a learner start an attempt and progress a couple of pages in. Note the title of the SCORM page you are on. Follow another link on the site, the navbar for instance. It must redirect the tab out of the SCORM activity. Navigate back to the course, and the SCORM activity and resume your attempt. You should be taken back to the last page that you were on. Progress one page and note the title Log out Log back in (this is to generate a new session cookie) Return to the SCORM activity, resume your attempt Confirm you get back to the last title
    • Affected Branches:
      MOODLE_38_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE, MOODLE_35_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Pull 3.9 Branch:
    • Pull 3.10 Branch:
      310_MDL-68896
    • Pull Master Branch:

      Description

      After recent update of Chrome, tracking of course pages in SCORM is not been saved.

      I added a comment on MDL-67175 , because the solution made there is not working properly with last chromiun browsers, but as it's closed, I've created a new one.

      I think it could be solved editing mod/scorm/request.js, moving the new added block inside the catch, and removing the if clause, because the initializacion of the global var "window.mod_scorm_is_window_closing" is not working.

      And I've tested that if I remove the IF and let the block as is before the try/catch, other features stop working. So it should be in the catch and act only if the sync xhr fails.

      I also add some code to exclude not chromiun browsers, just in case.

          try {
              httpReq.send(param);
          } catch (e) {
       
              var pieces = navigator.userAgent.match(/Chrom(?:e|ium)\/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/);
              if (pieces != null && pieces.length == 5) {
                      pieces = pieces.map(piece => parseInt(piece, 10));
                      ChromeVersion = pieces[1];
                      if (ChromeVersion > 80 && FormData) {
       
                              var vars = param.split('&'),
                              i = 0,
                              pair,
                              key,
                              value,
                              formData = new FormData();
       
                              for (i = 0; i < vars.length; i++) {
                                  pair = vars[i].split('=');
                                  key = decodeURIComponent(pair[0]);
                                  value = decodeURIComponent(pair[1]);
                                  formData.append(key, value);
                              }
                              // We'll also inform it that we are unloading, potentially useful in the future.
                              formData.append('unloading', '1');
       
                              // The results is true or false, we don't get the response from the server. Make it look like it was a success.
                              navigator.sendBeacon(url, formData);
                              // This is what a success looks like when it comes back from the server.
                              return "true\n0";
                      }
              }
              return false;
      }
       

       

        Attachments

        1. image-2020-11-18-12-42-53-033.png
          image-2020-11-18-12-42-53-033.png
          459 kB
        2. module.js
          39 kB
        3. request.js
          5 kB
        4. test.zip
          7.43 MB

          Issue Links

            Activity

              People

              Assignee:
              samhemelryk Sam Hemelryk
              Reporter:
              virgiliorey Virgilio Rey Lorenzana
              Peer reviewer:
              Dan Marsden Dan Marsden
              Integrator:
              Andrew Lyons Andrew Lyons
              Tester:
              Janelle Barcega Janelle Barcega
              Participants:
              Component watchers:
              Dan Marsden, Matteo Scaramuccia, Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              10 Vote for this issue
              Watchers:
              19 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                18/Jan/21

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours, 30 minutes
                  3h 30m