{"id":7085,"date":"2014-05-19T04:13:09","date_gmt":"2014-05-19T04:13:09","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/19\/window-requestanimationframe-silently-fails-to-invoke-callback-but-generates-a-valid-requestid-when-invoked-inside-of-a-cross-domain-iframe-collection-of-common-programming-errors\/"},"modified":"2014-05-19T04:13:09","modified_gmt":"2014-05-19T04:13:09","slug":"window-requestanimationframe-silently-fails-to-invoke-callback-but-generates-a-valid-requestid-when-invoked-inside-of-a-cross-domain-iframe-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/19\/window-requestanimationframe-silently-fails-to-invoke-callback-but-generates-a-valid-requestid-when-invoked-inside-of-a-cross-domain-iframe-collection-of-common-programming-errors\/","title":{"rendered":"window.requestAnimationFrame silently fails to invoke callback, but generates a valid requestID, when invoked inside of a cross-domain iframe-Collection of common programming errors"},"content":{"rendered":"<p>I am developing inside of a Google Chrome Extension. In this environment, I have the ability to inject JavaScript into third-party websites after requesting the appropriate permissions. As such, I am injecting code into an iframe referencing a cross-domain resource, but am not bound by the same cross-origin security policies as would be expected in a &#8216;normal&#8217; environment.<\/p>\n<p>The code I am executing inside of this iframe is:<\/p>\n<pre><code>var requestId = window.requestAnimationFrame(function(){\n    console.log(\"Success\");\n});\nconsole.log(\"Request Id:\", requestId);\n<\/code><\/pre>\n<p>After this code is executed, my output looks like:<\/p>\n<blockquote>\n<p>Request Id: 1<\/p>\n<\/blockquote>\n<p>The callback of requestAnimationFrame is never executed. requestAnimationFrame is defined. The callback works fine if I use a non-optimized call such as setInterval.<\/p>\n<p>The callback <strong>is executed properly outside of the iframe<\/strong> but no security errors are shown in my console when it fails inside of the iframe. This is only for the latest version of Google Chrome &#8212; do not worry about other implementations of requestAnimationFrame.<\/p>\n<p>Are there any steps I can take to debug this issue? window.requestAnimationFrame trails off into native code and my requestId is valid&#8230; so I&#8217;m at a bit of a loss.<\/p>\n<p><strong>EDIT:<\/strong><\/p>\n<p>Here is the full source code for reproducing the issue as a small Google Chrome extension: https:\/\/gist.github.com\/MeoMix\/37b4dbdbb3bd48f3c9e2<\/p>\n<p>Here is a downloadable zip of the source above: https:\/\/mega.co.nz\/#!2BFA1agY!JSZC1BFBza3rU4LnqlZqcR9neZQRJn0yh1U6tu2GWo4<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am developing inside of a Google Chrome Extension. In this environment, I have the ability to inject JavaScript into third-party websites after requesting the appropriate permissions. As such, I am injecting code into an iframe referencing a cross-domain resource, but am not bound by the same cross-origin security policies as would be expected in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7085","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7085"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7085\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}