@@ -1050,11 +1050,54 @@ test( "redefine", function() {
1050
1050
}
1051
1051
} ) ;
1052
1052
1053
- var instance = new $ . ui . testWidget ( ) ;
1053
+ var instance = new $ . ui . testWidget ( { } ) ;
1054
1054
instance . method ( "foo" ) ;
1055
1055
equal ( $ . ui . testWidget . foo , "bar" , "static properties remain" ) ;
1056
1056
} ) ;
1057
1057
1058
+ test ( "redefine deep prototype chain" , function ( ) {
1059
+ expect ( 8 ) ;
1060
+ $ . widget ( "ui.testWidget" , {
1061
+ method : function ( str ) {
1062
+ strictEqual ( this , instance , "original invoked with correct this" ) ;
1063
+ equal ( str , "level 4" , "original invoked with correct parameter" ) ;
1064
+ }
1065
+ } ) ;
1066
+ $ . widget ( "ui.testWidget2" , $ . ui . testWidget , {
1067
+ method : function ( str ) {
1068
+ strictEqual ( this , instance , "testWidget2 invoked with correct this" ) ;
1069
+ equal ( str , "level 2" , "testWidget2 invoked with correct parameter" ) ;
1070
+ this . _super ( "level 3" ) ;
1071
+ }
1072
+ } ) ;
1073
+ $ . widget ( "ui.testWidget3" , $ . ui . testWidget2 , {
1074
+ method : function ( str ) {
1075
+ strictEqual ( this , instance , "testWidget3 invoked with correct this" ) ;
1076
+ equal ( str , "level 1" , "testWidget3 invoked with correct parameter" ) ;
1077
+ this . _super ( "level 2" ) ;
1078
+ }
1079
+ } ) ;
1080
+ // redefine testWidget after other widgets have inherited from it
1081
+ // this tests whether the inheriting widgets get updated prototype chains
1082
+ $ . widget ( "ui.testWidget" , $ . ui . testWidget , {
1083
+ method : function ( str ) {
1084
+ strictEqual ( this , instance , "new invoked with correct this" ) ;
1085
+ equal ( str , "level 3" , "new invoked with correct parameter" ) ;
1086
+ this . _super ( "level 4" ) ;
1087
+ }
1088
+ } ) ;
1089
+ // redefine testWidget3 after it has been automatically redefined
1090
+ // this tests whether we properly handle _super() when the topmost prototype
1091
+ // doesn't have the method defined
1092
+ $ . widget ( "ui.testWidget3" , $ . ui . testWidget3 , { } ) ;
1093
+
1094
+ var instance = new $ . ui . testWidget3 ( { } ) ;
1095
+ instance . method ( "level 1" ) ;
1096
+
1097
+ delete $ . ui . testWidget3 ;
1098
+ delete $ . ui . testWidget2 ;
1099
+ } ) ;
1100
+
1058
1101
asyncTest ( "_delay" , function ( ) {
1059
1102
expect ( 6 ) ;
1060
1103
var order = 0 ,
0 commit comments