js/xpconnect/tests/mochitest/file_bug802557.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/tests/mochitest/file_bug802557.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +<head>
     1.7 +<script>
     1.8 +var gTS = window.location.toString;
     1.9 +var gGHR = Object.__lookupGetter__.call(window.location, 'href');
    1.10 +function getTests(fromOuter) {
    1.11 +
    1.12 +  function loc() fromOuter ? window.location : location;
    1.13 +  return {
    1.14 +    getLocationImplicit: function() {
    1.15 +      return loc() + "";
    1.16 +    },
    1.17 +    getLocationExplicit: function() {
    1.18 +      return loc().toString();
    1.19 +    },
    1.20 +    getLocationApply1: function() {
    1.21 +      return gTS.call(loc());
    1.22 +    },
    1.23 +    getLocationApply2: function() {
    1.24 +      return gTS.apply(loc(), []);
    1.25 +    },
    1.26 +    getLocationApply3: function() {
    1.27 +      return Function.call.apply(gTS, [loc()]);
    1.28 +    },
    1.29 +    getLocationViaPrototype: function() {
    1.30 +      return Location.prototype.toString.call(loc());
    1.31 +    },
    1.32 +    getHref: function() {
    1.33 +      return loc().href;
    1.34 +    },
    1.35 +    getHrefViaApply: function() {
    1.36 +      return Function.call.apply(gGHR, [loc()]);
    1.37 +    },
    1.38 +    getHrefViaPrototype: function() {
    1.39 +      return Object.getOwnPropertyDescriptor(Location.prototype, 'href').get.call(loc());
    1.40 +    }
    1.41 +  }
    1.42 +};
    1.43 +
    1.44 +function mungeNames(obj, suffix) {
    1.45 +  var rv = {};
    1.46 +  Object.getOwnPropertyNames(obj)
    1.47 +        .forEach(function (name) rv[name + suffix] = obj[name]);
    1.48 +  return rv;
    1.49 +}
    1.50 +
    1.51 +function mergeObjects(a, b) {
    1.52 +  var rv = {};
    1.53 +  Object.getOwnPropertyNames(a).forEach(function(name) rv[name] = a[name]);
    1.54 +  Object.getOwnPropertyNames(b).forEach(function(name) rv[name] = b[name]);
    1.55 +  return rv;
    1.56 +}
    1.57 +
    1.58 +function getAllTests() {
    1.59 +  var innerTests = getTests(false);
    1.60 +  var outerTests = getTests(true);
    1.61 +  return mergeObjects(mungeNames(innerTests, '_inner'),
    1.62 +                      mungeNames(outerTests, '_outer'));
    1.63 +}
    1.64 +
    1.65 +</script>
    1.66 +</head>
    1.67 +<body>
    1.68 +</body>
    1.69 +</html>

mercurial