OLD | NEW |
1 <script> | 1 <script> |
2 function testUnsuccessfulAccess() { | 2 function testUnsuccessfulAccess() { |
3 try { | 3 try { |
4 chrome.app.getDetailsForFrame(frames[0]); | 4 chrome.app.getDetailsForFrame(frames[0]); |
5 } catch (e) { | 5 } catch (e) { |
6 if (e.indexOf("Access denied") == 0) | 6 if (e.indexOf("Access denied") == 0) |
7 return true; | 7 return true; |
8 else | 8 else |
9 throw e; | 9 throw e; |
10 } | 10 } |
11 return false; | 11 return false; |
12 } | 12 } |
13 | 13 |
14 function getFrameURL(host) { | 14 function getFrameURL(host) { |
15 var result = "http://" + host; | 15 var result = "http://" + host; |
16 if (location.port) { | 16 if (location.port) { |
17 result += ":"; | 17 result += ":"; |
18 result += location.port; | 18 result += location.port; |
19 } | 19 } |
20 result += location.pathname; | 20 result += location.pathname; |
21 return result; | 21 return result; |
22 } | 22 } |
23 | 23 |
24 var iframe = document.createElement("iframe"); | 24 function newFrame(host) { |
25 iframe.src = getFrameURL("app.com"); | 25 if (frames.length > 0) |
26 document.documentElement.appendChild(iframe); | 26 document.documentElement.removeChild(document.querySelector('iframe')); |
| 27 var iframe = document.createElement("iframe"); |
| 28 iframe.src = getFrameURL(host); |
| 29 document.documentElement.appendChild(iframe); |
| 30 } |
| 31 |
| 32 newFrame('app.com'); |
| 33 |
27 </script> | 34 </script> |
OLD | NEW |