| OLD | NEW | 
| (Empty) |  | 
 |   1 <!DOCTYPE HTML> | 
 |   2 <html> | 
 |   3 <head> | 
 |   4     <title>Objects loaded using src attribute of <embed> tag are blocked u
    nless their host is listed as an allowed source in the object-src directive</tit
    le> | 
 |   5     <meta name=timeout content=long> | 
 |   6     <script src='/resources/testharness.js'></script> | 
 |   7     <script src='/resources/testharnessreport.js'></script> | 
 |   8 </head> | 
 |   9 <body onLoad="object_loaded()"> | 
 |  10     <h1>Objects loaded using src attribute of <embed> tag are blocked unle
    ss their host is listed as an allowed source in the object-src directive</h1> | 
 |  11     <div id="log"></div> | 
 |  12  | 
 |  13     <script> | 
 |  14       var relativeMediaURL = "/support/media/flash.swf"; | 
 |  15       var pageURL = window.location.toString(); | 
 |  16       var temp1 = pageURL.split("//"); | 
 |  17       var temp2 = temp1[1].substring (0, temp1[1].lastIndexOf("/object-src/")); | 
 |  18       var mediaURL = "http://www2." + temp2 + relativeMediaURL; | 
 |  19       var htmlStr = "<embed id='flashObject' type='application/x-shockwave-flash
    ' src='" + mediaURL + "' width='200' height='200'></object>"; | 
 |  20       document.write (htmlStr); | 
 |  21     </script> | 
 |  22  | 
 |  23     <script> | 
 |  24       var len = navigator.mimeTypes.length; | 
 |  25       var allTypes = ""; | 
 |  26       var flashMimeType = "application/x-shockwave-flash"; | 
 |  27       for ( var i=0;i<len;i++ ) { | 
 |  28         allTypes+=navigator.mimeTypes[i].type; | 
 |  29       } | 
 |  30  | 
 |  31       var hasMimeType = allTypes.indexOf(flashMimeType) != -1; | 
 |  32  | 
 |  33       <!-- The actual test. --> | 
 |  34       var test1 = async_test("Async SWF load test") | 
 |  35  | 
 |  36       function object_loaded() { | 
 |  37         var elem = document.getElementById("flashObject"); | 
 |  38         var is_loaded = false; | 
 |  39         try { | 
 |  40           <!-- The Flash Player exposes values to JavaScript if a SWF has succes
    sfully been loaded. --> | 
 |  41           var pct_loaded = elem.PercentLoaded(); | 
 |  42           is_loaded = true; | 
 |  43         } catch (e) {} | 
 |  44  | 
 |  45         if (hasMimeType) { | 
 |  46           test1.step(function() {assert_false(is_loaded, "External object loaded
    .")}); | 
 |  47           var s = document.createElement('script'); | 
 |  48               s.async = true; | 
 |  49               s.defer = true; | 
 |  50               s.src = "../support/checkReport.sub.js?reportField=violated-direct
    ive&reportValue=object-src%20%27self%27" | 
 |  51           document.lastChild.appendChild(s); | 
 |  52         } else { | 
 |  53           //test1.step(function() {}); | 
 |  54           test1.set_status(test1.NOTRUN, "No Flash Player, cannot run test."); | 
 |  55           test1.phase = test1.phases.HAS_RESULT; | 
 |  56         } | 
 |  57         test1.done(); | 
 |  58       } | 
 |  59     </script> | 
 |  60 </body> | 
 |  61 </html> | 
| OLD | NEW |