file_bug802557.html 1.4 KB

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