@@ -1824,6 +1824,104 @@ describe('$uibModal', function() {
18241824 expect ( modal3Index ) . toEqual ( 2 ) ;
18251825 expect ( modal2Index ) . toBeLessThan ( modal3Index ) ;
18261826 } ) ;
1827+
1828+ it ( 'should have top modal with highest z-index' , function ( ) {
1829+ var modal2zIndex = null ;
1830+ var modal3zIndex = null ;
1831+
1832+ var modal1Instance = {
1833+ result : $q . defer ( ) ,
1834+ opened : $q . defer ( ) ,
1835+ closed : $q . defer ( ) ,
1836+ rendered : $q . defer ( ) ,
1837+ close : function ( result ) {
1838+ return $uibModalStack . close ( modal1Instance , result ) ;
1839+ } ,
1840+ dismiss : function ( reason ) {
1841+ return $uibModalStack . dismiss ( modal1Instance , reason ) ;
1842+ }
1843+ } ;
1844+ var modal2Instance = {
1845+ result : $q . defer ( ) ,
1846+ opened : $q . defer ( ) ,
1847+ closed : $q . defer ( ) ,
1848+ rendered : $q . defer ( ) ,
1849+ close : function ( result ) {
1850+ return $uibModalStack . close ( modal2Instance , result ) ;
1851+ } ,
1852+ dismiss : function ( reason ) {
1853+ return $uibModalStack . dismiss ( modal2Instance , reason ) ;
1854+ }
1855+ } ;
1856+ var modal3Instance = {
1857+ result : $q . defer ( ) ,
1858+ opened : $q . defer ( ) ,
1859+ closed : $q . defer ( ) ,
1860+ rendered : $q . defer ( ) ,
1861+ close : function ( result ) {
1862+ return $uibModalStack . close ( modal3Instance , result ) ;
1863+ } ,
1864+ dismiss : function ( reason ) {
1865+ return $uibModalStack . dismiss ( modal3Instance , reason ) ;
1866+ }
1867+ } ;
1868+
1869+ var modal1 = $uibModalStack . open ( modal1Instance , {
1870+ appendTo : angular . element ( document . body ) ,
1871+ scope : $rootScope . $new ( ) ,
1872+ deferred : modal1Instance . result ,
1873+ renderDeferred : modal1Instance . rendered ,
1874+ closedDeferred : modal1Instance . closed ,
1875+ content : '<div>Modal1</div>'
1876+ } ) ;
1877+
1878+ $rootScope . $digest ( ) ;
1879+ $animate . flush ( ) ;
1880+ expect ( $document ) . toHaveModalsOpen ( 1 ) ;
1881+
1882+ expect ( + $uibModalStack . getTop ( ) . value . modalDomEl [ 0 ] . style . zIndex ) . toBe ( 1050 ) ;
1883+
1884+ var modal2 = $uibModalStack . open ( modal2Instance , {
1885+ appendTo : angular . element ( document . body ) ,
1886+ scope : $rootScope . $new ( ) ,
1887+ deferred : modal2Instance . result ,
1888+ renderDeferred : modal2Instance . rendered ,
1889+ closedDeferred : modal2Instance . closed ,
1890+ content : '<div>Modal2</div>'
1891+ } ) ;
1892+
1893+ modal2Instance . rendered . promise . then ( function ( ) {
1894+ modal2zIndex = + $uibModalStack . getTop ( ) . value . modalDomEl [ 0 ] . style . zIndex ;
1895+ } ) ;
1896+
1897+ $rootScope . $digest ( ) ;
1898+ $animate . flush ( ) ;
1899+ expect ( $document ) . toHaveModalsOpen ( 2 ) ;
1900+
1901+ expect ( modal2zIndex ) . toBe ( 1060 ) ;
1902+ close ( modal1Instance ) ;
1903+ expect ( $document ) . toHaveModalsOpen ( 1 ) ;
1904+
1905+ var modal3 = $uibModalStack . open ( modal3Instance , {
1906+ appendTo : angular . element ( document . body ) ,
1907+ scope : $rootScope . $new ( ) ,
1908+ deferred : modal3Instance . result ,
1909+ renderDeferred : modal3Instance . rendered ,
1910+ closedDeferred : modal3Instance . closed ,
1911+ content : '<div>Modal3</div>'
1912+ } ) ;
1913+
1914+ modal3Instance . rendered . promise . then ( function ( ) {
1915+ modal3zIndex = + $uibModalStack . getTop ( ) . value . modalDomEl [ 0 ] . style . zIndex ;
1916+ } ) ;
1917+
1918+ $rootScope . $digest ( ) ;
1919+ $animate . flush ( ) ;
1920+ expect ( $document ) . toHaveModalsOpen ( 2 ) ;
1921+
1922+ expect ( modal3zIndex ) . toBe ( 1070 ) ;
1923+ expect ( modal2zIndex ) . toBeLessThan ( modal3zIndex ) ;
1924+ } ) ;
18271925 } ) ;
18281926
18291927 describe ( 'modal.closing event' , function ( ) {
0 commit comments