@@ -1683,7 +1683,41 @@ describe('angular', function() {
16831683 dealoc ( appElement ) ;
16841684 } ) ;
16851685
1686+ it ( 'should bootstrap from an extension into an extension document for same-origin documents only' , function ( ) {
1687+ if ( msie ) return ; // IE does not support document.currentScript (nor extensions with protocol), so skip test.
1688+
1689+ // Extension URLs are browser-specific, so we must choose a scheme that is supported by the browser to make
1690+ // sure that the URL is properly parsed.
1691+ var extensionScheme ;
1692+ var userAgent = window . navigator . userAgent ;
1693+ if ( / F i r e f o x \/ / . test ( userAgent ) ) {
1694+ extensionScheme = 'moz-extension' ;
1695+ } else if ( / E d g e \/ / . test ( userAgent ) ) {
1696+ extensionScheme = 'ms-browser-extension' ;
1697+ } else if ( / C h r o m e \/ / . test ( userAgent ) ) {
1698+ extensionScheme = 'chrome-extension' ;
1699+ } else if ( / S a f a r i \/ / . test ( userAgent ) ) {
1700+ extensionScheme = 'safari-extension' ;
1701+ } else {
1702+ extensionScheme = 'browserext' ; // Upcoming standard scheme.
1703+ }
1704+
1705+ var src = extensionScheme + '://something' ;
1706+ // Fake a minimal document object (the actual document.currentScript is readonly).
1707+ var fakeDoc = {
1708+ currentScript : { getAttribute : function ( ) { return src ; } } ,
1709+ location : { protocol : extensionScheme + ':' , origin : extensionScheme + '://something' } ,
1710+ createElement : document . createElement . bind ( document )
1711+ } ;
1712+ expect ( allowAutoBootstrap ( fakeDoc ) ) . toBe ( true ) ;
1713+
1714+ src = extensionScheme + '://something-else' ;
1715+ expect ( allowAutoBootstrap ( fakeDoc ) ) . toBe ( false ) ;
1716+ } ) ;
1717+
16861718 it ( 'should not bootstrap from an extension into a non-extension document' , function ( ) {
1719+ if ( msie ) return ; // IE does not support document.currentScript (nor extensions with protocol), so skip test.
1720+
16871721 var src = 'resource://something' ;
16881722 // Fake a minimal document object (the actual document.currentScript is readonly).
16891723 var fakeDoc = {
0 commit comments