file_bug802557.html (1418B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script> 5 var gTS = window.location.toString; 6 var gGHR = Object.getOwnPropertyDescriptor(window.location, 'href').get; 7 function getTests(fromOuter) { 8 9 function loc() { 10 return fromOuter ? window.location : location; 11 } 12 return { 13 getLocationImplicit: function() { 14 return loc() + ""; 15 }, 16 getLocationExplicit: function() { 17 return loc().toString(); 18 }, 19 getLocationApply1: function() { 20 return gTS.call(loc()); 21 }, 22 getLocationApply2: function() { 23 return gTS.apply(loc(), []); 24 }, 25 getLocationApply3: function() { 26 return Function.call.apply(gTS, [loc()]); 27 }, 28 getHref: function() { 29 return loc().href; 30 }, 31 getHrefViaApply: function() { 32 return Function.call.apply(gGHR, [loc()]); 33 }, 34 } 35 }; 36 37 function mungeNames(obj, suffix) { 38 var rv = {}; 39 Object.getOwnPropertyNames(obj) 40 .forEach(name => rv[name + suffix] = obj[name]); 41 return rv; 42 } 43 44 function mergeObjects(a, b) { 45 var rv = {}; 46 Object.getOwnPropertyNames(a).forEach(name => rv[name] = a[name]); 47 Object.getOwnPropertyNames(b).forEach(name => rv[name] = b[name]); 48 return rv; 49 } 50 51 function getAllTests() { 52 var innerTests = getTests(false); 53 var outerTests = getTests(true); 54 return mergeObjects(mungeNames(innerTests, '_inner'), 55 mungeNames(outerTests, '_outer')); 56 } 57 58 </script> 59 </head> 60 <body> 61 </body> 62 </html>