@@ -1697,7 +1697,41 @@ describe('angular', function() {
1697
1697
dealoc ( appElement ) ;
1698
1698
} ) ;
1699
1699
1700
+ it ( 'should bootstrap from an extension into an extension document for same-origin documents only' , function ( ) {
1701
+ if ( msie ) return ; // IE does not support document.currentScript (nor extensions with protocol), so skip test.
1702
+
1703
+ // Extension URLs are browser-specific, so we must choose a scheme that is supported by the browser to make
1704
+ // sure that the URL is properly parsed.
1705
+ var extensionScheme ;
1706
+ var userAgent = window . navigator . userAgent ;
1707
+ if ( / F i r e f o x \/ / . test ( userAgent ) ) {
1708
+ extensionScheme = 'moz-extension' ;
1709
+ } else if ( / E d g e \/ / . test ( userAgent ) ) {
1710
+ extensionScheme = 'ms-browser-extension' ;
1711
+ } else if ( / C h r o m e \/ / . test ( userAgent ) ) {
1712
+ extensionScheme = 'chrome-extension' ;
1713
+ } else if ( / S a f a r i \/ / . test ( userAgent ) ) {
1714
+ extensionScheme = 'safari-extension' ;
1715
+ } else {
1716
+ extensionScheme = 'browserext' ; // Upcoming standard scheme.
1717
+ }
1718
+
1719
+ var src = extensionScheme + '://something' ;
1720
+ // Fake a minimal document object (the actual document.currentScript is readonly).
1721
+ var fakeDoc = {
1722
+ currentScript : { getAttribute : function ( ) { return src ; } } ,
1723
+ location : { protocol : extensionScheme + ':' , origin : extensionScheme + '://something' } ,
1724
+ createElement : document . createElement . bind ( document )
1725
+ } ;
1726
+ expect ( allowAutoBootstrap ( fakeDoc ) ) . toBe ( true ) ;
1727
+
1728
+ src = extensionScheme + '://something-else' ;
1729
+ expect ( allowAutoBootstrap ( fakeDoc ) ) . toBe ( false ) ;
1730
+ } ) ;
1731
+
1700
1732
it ( 'should not bootstrap from an extension into a non-extension document' , function ( ) {
1733
+ if ( msie ) return ; // IE does not support document.currentScript (nor extensions with protocol), so skip test.
1734
+
1701
1735
var src = 'resource://something' ;
1702
1736
// Fake a minimal document object (the actual document.currentScript is readonly).
1703
1737
var fakeDoc = {
0 commit comments