Moodle
  1. Moodle
  2. MDL-34590

Quiz secure popup not working in Chrome

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.4, 2.3.1, 2.4
    • Fix Version/s: 2.2.5, 2.3.2
    • Component/s: Quiz
    • Labels:
    • Testing Instructions:
      Hide

      Please test as many browser / OS combinations as possible. Ensure all caches are purged.

      I was only able to test Windows here.

      1. Create a quiz with 'Browser security' set to 'Full screen pop-up with some JavaScript security'.

      2. Start an attempt as a student. Ensure the attempt window opens full-screen.

      Show
      Please test as many browser / OS combinations as possible. Ensure all caches are purged. I was only able to test Windows here. 1. Create a quiz with 'Browser security' set to 'Full screen pop-up with some JavaScript security'. 2. Start an attempt as a student. Ensure the attempt window opens full-screen.
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      43024

      Description

      When using Chrome, the secure popup for the quiz seems to load at size 0 so the user can't see it, but it still opens an attempt.

        Issue Links

          Activity

          Hide
          Jeff Rader added a comment - - edited

          I created a demo test. Does the same for me on qa site. Windows 7/Chrome. When it fails, if I mouse over the taskbar and manually maximize the window, it can appear. Testing on Mac now.

          Show
          Jeff Rader added a comment - - edited I created a demo test. Does the same for me on qa site. Windows 7/Chrome. When it fails, if I mouse over the taskbar and manually maximize the window, it can appear. Testing on Mac now.
          Hide
          Jeff Rader added a comment -

          Chrome on the Mac opens a very small window, but does allow it to be resized.

          Show
          Jeff Rader added a comment - Chrome on the Mac opens a very small window, but does allow it to be resized.
          Hide
          Jeff Rader added a comment -

          As a temporary fix I added this js for just the quiz-secure-window pages:
          chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
          if (chrome)

          { window.moveTo(0, 0); window.resizeTo(800, 600); }

          I'm using jquery for some other functions for my site so this wasn't too hard to implement. I hope there is a more permanent fix we can find.

          Show
          Jeff Rader added a comment - As a temporary fix I added this js for just the quiz-secure-window pages: chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; if (chrome) { window.moveTo(0, 0); window.resizeTo(800, 600); } I'm using jquery for some other functions for my site so this wasn't too hard to implement. I hope there is a more permanent fix we can find.
          Hide
          Dan Marsden added a comment -

          HI Tim - Jeff posted about this in the forums - I had issues with resizeto and SCORM code - more info on MDL-32388 if that's helpful.

          Show
          Dan Marsden added a comment - HI Tim - Jeff posted about this in the forums - I had issues with resizeto and SCORM code - more info on MDL-32388 if that's helpful.
          Hide
          Tim Hunt added a comment -

          Note that the quiz is using the Moodle core JS function openpopup, rather than re-implementing it.

          https://github.com/timhunt/moodle/compare/master...MDL-34590 is my best guess on how to fix things, based on Dan's hint.

          It works fine in FF and IE. On chrome it works better than before, but it is not quite right. The window that opens is too big. It looks like the web page area is the size of the screen, and then you ahve the windows re-size bars around that, so actually the window does not fit, and you can't see the bottom or right edges. I am not sure what to do about that.

          Show
          Tim Hunt added a comment - Note that the quiz is using the Moodle core JS function openpopup, rather than re-implementing it. https://github.com/timhunt/moodle/compare/master...MDL-34590 is my best guess on how to fix things, based on Dan's hint. It works fine in FF and IE. On chrome it works better than before, but it is not quite right. The window that opens is too big. It looks like the web page area is the size of the screen, and then you ahve the windows re-size bars around that, so actually the window does not fit, and you can't see the bottom or right edges. I am not sure what to do about that.
          Hide
          Jeff Rader added a comment -

          I'll work on it later, but I think if we set it to window.innerWidth and window.innerHeight instead of screen.availWidth and Height, it might work better. Or, do a test for 0 in screen.availWidth and Height and use those as fall back. I'll try to integrate that later (possibly Monday) and prepare a patch.

          Show
          Jeff Rader added a comment - I'll work on it later, but I think if we set it to window.innerWidth and window.innerHeight instead of screen.availWidth and Height, it might work better. Or, do a test for 0 in screen.availWidth and Height and use those as fall back. I'll try to integrate that later (possibly Monday) and prepare a patch.
          Hide
          Tim Hunt added a comment -

          Great. Thanks.

          Show
          Tim Hunt added a comment - Great. Thanks.
          Hide
          Jeff Rader added a comment -

          Well, your approach looks to be a better one, but here seems be the problem
          http://code.google.com/p/chromium/issues/detail?id=2091

          Chrome doesn't support resizeTo (and probably not moveTo if I keep looking). I'll see if there is another work around besides browser sniffing things.

          Show
          Jeff Rader added a comment - Well, your approach looks to be a better one, but here seems be the problem http://code.google.com/p/chromium/issues/detail?id=2091 Chrome doesn't support resizeTo (and probably not moveTo if I keep looking). I'll see if there is another work around besides browser sniffing things.
          Hide
          David Monllaó added a comment -

          Looks great and works fine

          Show
          David Monllaó added a comment - Looks great and works fine
          Hide
          Tim Hunt added a comment -

          I would not describe my solution as a work-around. I think it is a better way to do things (open the pop-up at the right size to start with, rather than opening at a random size and then re-sizing it later).

          But, despite what David says, it does not work fine. The new window is too big, at least on Windows.

          Show
          Tim Hunt added a comment - I would not describe my solution as a work-around. I think it is a better way to do things (open the pop-up at the right size to start with, rather than opening at a random size and then re-sizing it later). But, despite what David says, it does not work fine. The new window is too big, at least on Windows.
          Hide
          Jeff Rader added a comment -

          I think I figured it out, but the branch got moved over to 2.4 and I wasn't going to update to 2.4 yet. So anyway, if you can figure out how to get this into the code I think it will work. Chrome can resize if you wrap them in a setTimeout. The other browsers don't seem to complain.
          line 1189
          if (!windowobj)

          { return true; }

          if (args.fullscreen) {
          setTimeout(function()

          { windowobj.moveTo(0,0); windowobj.resizeTo(screen.availWidth,screen.availHeight) }

          , 0);
          }

          Show
          Jeff Rader added a comment - I think I figured it out, but the branch got moved over to 2.4 and I wasn't going to update to 2.4 yet. So anyway, if you can figure out how to get this into the code I think it will work. Chrome can resize if you wrap them in a setTimeout. The other browsers don't seem to complain. line 1189 if (!windowobj) { return true; } if (args.fullscreen) { setTimeout(function() { windowobj.moveTo(0,0); windowobj.resizeTo(screen.availWidth,screen.availHeight) } , 0); }
          Hide
          Tim Hunt added a comment -

          Thanks, I will try to test that tomorrow.

          Show
          Tim Hunt added a comment - Thanks, I will try to test that tomorrow.
          Hide
          David Monllaó added a comment -

          Hi,

          Sorry Tim, I didn't realize that, in Windows, the new window height is adjusted to the screen size, not the available space in the screen. It seems that availHeight doesn't return the real available space that's why it's bigger than it should be, but after the resizeTo with setTimeout() it's reduced to the real available space (with Windows 7 and a 1280x960 screen the height is reduced from the availHeight = 920 to 914)

          I haven't tried it in mac nor Windows XP.

          Show
          David Monllaó added a comment - Hi, Sorry Tim, I didn't realize that, in Windows, the new window height is adjusted to the screen size, not the available space in the screen. It seems that availHeight doesn't return the real available space that's why it's bigger than it should be, but after the resizeTo with setTimeout() it's reduced to the real available space (with Windows 7 and a 1280x960 screen the height is reduced from the availHeight = 920 to 914) I haven't tried it in mac nor Windows XP.
          Hide
          Tim Hunt added a comment -

          Thanks all for your help. Submitting for integration now.

          Show
          Tim Hunt added a comment - Thanks all for your help. Submitting for integration now.
          Hide
          Jeff Rader added a comment -

          Seems to test out well
          Windows 7
          Chrome OK
          Firefox 14 OK
          IE 8 OK
          Safari OK
          XP
          IE 6 OK
          OS 10.7
          Firefox 14 OK
          Chrome OK
          Safari 6 OK

          When I try to checkout the MDL-34590_23 or MDL-34590_22 they are both based on 2.4 still. Maybe user error

          Show
          Jeff Rader added a comment - Seems to test out well Windows 7 Chrome OK Firefox 14 OK IE 8 OK Safari OK XP IE 6 OK OS 10.7 Firefox 14 OK Chrome OK Safari 6 OK When I try to checkout the MDL-34590 _23 or MDL-34590 _22 they are both based on 2.4 still. Maybe user error
          Hide
          Tim Hunt added a comment -

          Thanks for the testing!

          The _22 and _23 branches are fine. E.g. on https://github.com/timhunt/moodle/commit/MDL-34590_22 click the 1 parent f2ddce97bd link to see all is well.

          Show
          Tim Hunt added a comment - Thanks for the testing! The _22 and _23 branches are fine. E.g. on https://github.com/timhunt/moodle/commit/MDL-34590_22 click the 1 parent f2ddce97bd link to see all is well.
          Hide
          Dan Poltawski added a comment -

          Integrated to 22, 23 and master, thanks everyone.

          Show
          Dan Poltawski added a comment - Integrated to 22, 23 and master, thanks everyone.
          Hide
          Andrew Davis added a comment - - edited

          Doesn't seem to work as expected for me. This is in master.

          Ubuntu 11.04
          Chrome 21.0.1180.57

          The popup window opens up unusably small at the top left of the screen. I'm attaching a screen shot.

          I can resize the window and then it seems to work fine. I'm using the theme "formal white" just in case that is relevant.

          Show
          Andrew Davis added a comment - - edited Doesn't seem to work as expected for me. This is in master. Ubuntu 11.04 Chrome 21.0.1180.57 The popup window opens up unusably small at the top left of the screen. I'm attaching a screen shot. I can resize the window and then it seems to work fine. I'm using the theme "formal white" just in case that is relevant.
          Hide
          Dan Poltawski added a comment -

          Just to confirm you've tried to purge your caches completely Andrew?

          Show
          Dan Poltawski added a comment - Just to confirm you've tried to purge your caches completely Andrew?
          Hide
          Dan Poltawski added a comment -

          (browser as well as moodle - i'm not sure if this file is served by our auto url changing scripts)

          Show
          Dan Poltawski added a comment - (browser as well as moodle - i'm not sure if this file is served by our auto url changing scripts)
          Hide
          Dan Poltawski added a comment -

          I've tested this with Chrome on OSX and its working ok. My suspicion is that its chrome overagressively caching.

          Show
          Dan Poltawski added a comment - I've tested this with Chrome on OSX and its working ok. My suspicion is that its chrome overagressively caching.
          Hide
          Tim Hunt added a comment -

          Just to note I was developing on Windows 7, and I tested Chrome, FF and IE there.

          I am just testing on MacOS, and the new code works fine in FF, Chrome and Safari.

          Andrew, to test your browser is seeing the latest version of the code, you need to use Firebug (or the equivalent tool in other browsers) and look at the code the browser is using for the openpopup function in javascript-static.js, to make sure it matches the code in integration/master.

          Show
          Tim Hunt added a comment - Just to note I was developing on Windows 7, and I tested Chrome, FF and IE there. I am just testing on MacOS, and the new code works fine in FF, Chrome and Safari. Andrew, to test your browser is seeing the latest version of the code, you need to use Firebug (or the equivalent tool in other browsers) and look at the code the browser is using for the openpopup function in javascript-static.js, to make sure it matches the code in integration/master.
          Hide
          Tim Hunt added a comment -

          The question is, do we wait for Andrew to re-test, or do I create a Ubuntu VM?

          Show
          Tim Hunt added a comment - The question is, do we wait for Andrew to re-test, or do I create a Ubuntu VM?
          Hide
          Andrew Davis added a comment -

          I've cleared my cache (browser and Moodle), disabled caching in Chrome and restarted Chrome. Im still getting the problem unfortunately. The openpopup() function seems to match the version in integration/master. Here it is copied out of the browser.

          function openpopup(event, args) {
          
              if (event) {
                  if (event.preventDefault) {
                      event.preventDefault();
                  } else {
                      event.returnValue = false;
                  }
              }
          
              var fullurl = args.url;
              if (!args.url.match(/https?:\/\//)) {
                  fullurl = M.cfg.wwwroot + args.url;
              }
              if (args.fullscreen) {
                  args.options = args.options.
                          replace(/top=\d+/, 'top=0').
                          replace(/left=\d+/, 'left=0').
                          replace(/width=\d+/, 'width=' + screen.availWidth).
                          replace(/height=\d+/, 'height=' + screen.availHeight);
              }
              var windowobj = window.open(fullurl,args.name,args.options);
              if (!windowobj) {
                  return true;
              }
          
              if (args.fullscreen) {
                  setTimeout(function() {
                      windowobj.moveTo(0, 0);
                      windowobj.resizeTo(screen.availWidth, screen.availHeight)
                  }, 0);
              }
              windowobj.focus();
          
              return false;
          }
          
          Show
          Andrew Davis added a comment - I've cleared my cache (browser and Moodle), disabled caching in Chrome and restarted Chrome. Im still getting the problem unfortunately. The openpopup() function seems to match the version in integration/master. Here it is copied out of the browser. function openpopup(event, args) { if (event) { if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false ; } } var fullurl = args.url; if (!args.url.match(/https?:\/\ //)) { fullurl = M.cfg.wwwroot + args.url; } if (args.fullscreen) { args.options = args.options. replace(/top=\d+/, 'top=0'). replace(/left=\d+/, 'left=0'). replace(/width=\d+/, 'width=' + screen.availWidth). replace(/height=\d+/, 'height=' + screen.availHeight); } var windowobj = window.open(fullurl,args.name,args.options); if (!windowobj) { return true ; } if (args.fullscreen) { setTimeout(function() { windowobj.moveTo(0, 0); windowobj.resizeTo(screen.availWidth, screen.availHeight) }, 0); } windowobj.focus(); return false ; }
          Hide
          Dan Poltawski added a comment - - edited

          Thanks Andrew. Are you able to test moodle/master and see what the behaviour is there?

          I'm just wondering if this has made the situation worse or just not resolved the problem on ubuntu (in which case i'll vote for leaving this is as we are making a step forward on major platforms, at least).

          Show
          Dan Poltawski added a comment - - edited Thanks Andrew. Are you able to test moodle/master and see what the behaviour is there? I'm just wondering if this has made the situation worse or just not resolved the problem on ubuntu (in which case i'll vote for leaving this is as we are making a step forward on major platforms, at least).
          Hide
          Andrew Davis added a comment -

          I'm afraid we have made the situation worse. I just tried this in master and the window opens in the top left but its a decent size.

          Show
          Andrew Davis added a comment - I'm afraid we have made the situation worse. I just tried this in master and the window opens in the top left but its a decent size.
          Hide
          Dan Poltawski added a comment -

          Ankit tried this out and confirmed it.

          Show
          Dan Poltawski added a comment - Ankit tried this out and confirmed it.
          Hide
          Tim Hunt added a comment -

          Grrr! web browsers.

          Show
          Tim Hunt added a comment - Grrr! web browsers.
          Hide
          Tim Hunt added a comment -

          Did MDL-32388 get tested as thoroughly? Would be nice to know if Dan M's JS works.

          Show
          Tim Hunt added a comment - Did MDL-32388 get tested as thoroughly? Would be nice to know if Dan M's JS works.
          Hide
          Dan Marsden added a comment -

          yeah - my main machine runs Xubuntu and I tested Chrome with SCORM on mine and it worked last time I checked.... but I don't use any resize code anymore - SCORM just opens the new window and passes the height/width when opening the window.

          Show
          Dan Marsden added a comment - yeah - my main machine runs Xubuntu and I tested Chrome with SCORM on mine and it worked last time I checked.... but I don't use any resize code anymore - SCORM just opens the new window and passes the height/width when opening the window.
          Hide
          Dan Marsden added a comment -

          I wondered if it was the move in your code that was causing the issues? - I tested this yesterday on my machine and I think I saw a flash of it opened large screen before it was moved.

          Show
          Dan Marsden added a comment - I wondered if it was the move in your code that was causing the issues? - I tested this yesterday on my machine and I think I saw a flash of it opened large screen before it was moved.
          Hide
          Tim Hunt added a comment -

          So, actually, it is probably the resizeTo, not the moveTo, that is breaking things. Perhaps screen.availWidth and screen.availHeight return the wrong thing on Chrome / Ubuntu?

          Show
          Tim Hunt added a comment - So, actually, it is probably the resizeTo, not the moveTo, that is breaking things. Perhaps screen.availWidth and screen.availHeight return the wrong thing on Chrome / Ubuntu?
          Hide
          Tim Hunt added a comment -

          Thanks do Dan's testing, I think we have finally got it:

          https://github.com/timhunt/moodle/compare/master...MDL-34590_grr

          Dan has tested Chrome on Ubuntu.

          I have tested FF, Chrome and IE8 on Windows 7.

          Show
          Tim Hunt added a comment - Thanks do Dan's testing, I think we have finally got it: https://github.com/timhunt/moodle/compare/master...MDL-34590_grr Dan has tested Chrome on Ubuntu. I have tested FF, Chrome and IE8 on Windows 7.
          Hide
          Tim Hunt added a comment -

          Crap! I got an un-realated bug fix into the same commit. Will fix.

          Show
          Tim Hunt added a comment - Crap! I got an un-realated bug fix into the same commit. Will fix.
          Hide
          Tim Hunt added a comment -

          OK, should really be ready for integration now.

          Show
          Tim Hunt added a comment - OK, should really be ready for integration now.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Tested on FF, Chrome and Safari, Mac. All ok too apparently. Proceeding with integration of the extra commit...

          Show
          Eloy Lafuente (stronk7) added a comment - Tested on FF, Chrome and Safari, Mac. All ok too apparently. Proceeding with integration of the extra commit...
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated (22, 23 & master), thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated (22, 23 & master), thanks!
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Test passed too (based on previous comments on Ubuntu, Win and Mac).

          Show
          Eloy Lafuente (stronk7) added a comment - Test passed too (based on previous comments on Ubuntu, Win and Mac).
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Fixed STOP Closed STOP Thanks STOP

          Yay, imagination! Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Fixed STOP Closed STOP Thanks STOP Yay, imagination! Ciao
          Hide
          Timothy Takemoto added a comment -

          Alas, secure quizzes stopped working on Chrome this term.
          In my 1.6.x the function is in javascript.php

          function openpopup(url,name,options,fullscreen) {
          fullurl = "<?php echo $CFG->httpswwwroot ?>" + url;
          windowobj = window.open(fullurl,name,options);
          if (fullscreen)

          { windowobj.moveTo(0,0); windowobj.resizeTo(screen.availWidth,screen.availHeight); }

          windowobj.focus();
          return false;
          }

          The bit I think I need is from
          https://github.com/moodle/moodle/blob/master/lib/javascript-static.js
          (I have deleted the comments)

          if (args.fullscreen) {
          var hackcount = 100;
          var get_size_exactly_right = function() {
          windowobj.moveTo(0, 0);
          windowobj.resizeTo(screen.availWidth, screen.availHeight);
          if (hackcount > 0 && (windowobj.innerHeight < 10 || windowobj.innerWidth < 10))

          { hackcount -= 1; setTimeout(get_size_exactly_right, 10); }

          }
          setTimeout(get_size_exactly_right, 0);
          }

          Which I think should work in place of my "if(fullscreen)

          {......}

          " (and remove "args." of course)
          Yes. Chrome on windows seems to work with the above but then it seems my issue is elsewhere.

          The links to github for the diffs do not seem to work for me so I am posting this just in case
          anyone wants to patch a legacy Moodle.

          Tim

          Show
          Timothy Takemoto added a comment - Alas, secure quizzes stopped working on Chrome this term. In my 1.6.x the function is in javascript.php function openpopup(url,name,options,fullscreen) { fullurl = "<?php echo $CFG->httpswwwroot ?>" + url; windowobj = window.open(fullurl,name,options); if (fullscreen) { windowobj.moveTo(0,0); windowobj.resizeTo(screen.availWidth,screen.availHeight); } windowobj.focus(); return false; } The bit I think I need is from https://github.com/moodle/moodle/blob/master/lib/javascript-static.js (I have deleted the comments) if (args.fullscreen) { var hackcount = 100; var get_size_exactly_right = function() { windowobj.moveTo(0, 0); windowobj.resizeTo(screen.availWidth, screen.availHeight); if (hackcount > 0 && (windowobj.innerHeight < 10 || windowobj.innerWidth < 10)) { hackcount -= 1; setTimeout(get_size_exactly_right, 10); } } setTimeout(get_size_exactly_right, 0); } Which I think should work in place of my "if(fullscreen) {......} " (and remove "args." of course) Yes. Chrome on windows seems to work with the above but then it seems my issue is elsewhere. The links to github for the diffs do not seem to work for me so I am posting this just in case anyone wants to patch a legacy Moodle. Tim

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: