setTimeout and setInterval silently fails in extensions on csp-restricted websites

Fixed Issue #8241022

Details

Created
Jul 21, 2016
Privacy
This issue is public.
Fixed in build #
17.17608
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

  1. Create an extension with the following content script:

 

setTimeout(function() { alert(“setTimeout”); }, 33);

 

  1. Enable the extension

  2. Go to github.com

 

Expected: the message shows up

Actual: it doesn’t

 

Workaround:

// this is a polyfill for setTimeout and setInterval, for when the csp policy blocks eval/setTimeout/setInterval

void function() {

 var stm = window.setTimeout;

 var sti = window.setInterval;

 var clm = window.clearTimeout;

 var cli = window.clearInterval;

 setTimeout(function() {

  // restoring proper timeouts

  window.setTimeout = stm;

  window.setInterval = sti;

  window.clearTimeout = clm;

  window.clearInterval = cli;

 }, 0);

}();

window.setTimeout = function(x,t?,…args) {

 var time = performance.now() + t|0;

 function runIfTimeHasCome() {

  if(performance.now() > time) {

   x.apply(window, args);

  } else {

   handle = requestAnimationFrame(runIfTimeHasCome);

  }

 }

 var handle = requestAnimationFrame(runIfTimeHasCome);

 return (function() { cancelAnimationFrame(handle); }) as any;

}

window.setInterval = function(x,t?,…args) {

 var time = performance.now() + t|0;

 function runIfTimeHasCome() {

  handle = requestAnimationFrame(runIfTimeHasCome)

  if(performance.now() > time) {

   time = time + t|0;

   x.apply(window, args);

  }

 }

 var handle = requestAnimationFrame(runIfTimeHasCome);

 return (function() { cancelAnimationFrame(handle); }) as any;

}

window.clearInterval = window.clearTimeout = function(t) {

 (t as any).call();

}

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Sermet I.”

      Changed Assigned To from “Sermet I.” to “Scott S.”

      Changed Status to “Confirmed”

      Changed Assigned To from “Scott S.” to “Scott L.”

      Changed Assigned To from “Scott L.” to “Sermet I.”

      Changed Assigned To from “Sermet I.” to “Scott S.”

    • Almost 2 years, still not fixed.

    • Microsoft Edge Team

      Changed Assigned To from “Scott S.” to “Francois R.”

      Changed Status from “Confirmed” to “Fixed”

    • Hello,

      Thank you for providing this information about the issue. We are pleased to report this feature is fixed in Edge and will be available in an upcoming insider build.

      Best Wishes,
      The MS Edge Team

    You need to sign in to your Microsoft account to add a comment.

    Sign in