2011-09-07 08:35:18 +02:00
|
|
|
// Copyright 2009 the Sputnik authors. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
2014-07-22 01:09:02 +02:00
|
|
|
/*---
|
|
|
|
info: Operator use ToString
|
2017-06-29 21:42:01 +02:00
|
|
|
esid: sec-decodeuricomponent-encodeduricomponent
|
2014-07-22 01:09:02 +02:00
|
|
|
description: If Type(value) is Object, evaluate ToPrimitive(value, String)
|
|
|
|
---*/
|
2011-09-07 08:35:18 +02:00
|
|
|
|
|
|
|
//CHECK#1
|
2018-02-15 21:50:18 +01:00
|
|
|
var object = {
|
|
|
|
valueOf: function() {
|
|
|
|
return "%5E"
|
|
|
|
}
|
|
|
|
};
|
2011-09-07 08:35:18 +02:00
|
|
|
if (decodeURIComponent(object) !== "[object Object]") {
|
|
|
|
$ERROR('#1: var object = {valueOf: function() {return "%5E"}}; decodeURIComponent(object) === [object Object]. Actual: ' + (decodeURIComponent(object)));
|
|
|
|
}
|
|
|
|
|
|
|
|
//CHECK#2
|
2018-02-15 21:50:18 +01:00
|
|
|
var object = {
|
|
|
|
valueOf: function() {
|
|
|
|
return ""
|
|
|
|
},
|
|
|
|
toString: function() {
|
|
|
|
return "%5E"
|
|
|
|
}
|
|
|
|
};
|
2011-09-07 08:35:18 +02:00
|
|
|
if (decodeURIComponent(object) !== "^") {
|
|
|
|
$ERROR('#2: var object = {valueOf: function() {return ""}, toString: function() {return "%5E"}}; decodeURIComponent(object) === "^". Actual: ' + (decodeURIComponent(object)));
|
2017-06-29 21:42:11 +02:00
|
|
|
}
|
2011-09-07 08:35:18 +02:00
|
|
|
|
|
|
|
//CHECK#3
|
2018-02-15 21:50:18 +01:00
|
|
|
var object = {
|
|
|
|
valueOf: function() {
|
|
|
|
return "%5E"
|
|
|
|
},
|
|
|
|
toString: function() {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
};
|
2011-09-07 08:35:18 +02:00
|
|
|
if (decodeURIComponent(object) !== "^") {
|
|
|
|
$ERROR('#3: var object = {valueOf: function() {return "%5E"}, toString: function() {return {}}}; decodeURIComponent(object) === "^". Actual: ' + (decodeURIComponent(object)));
|
|
|
|
}
|
|
|
|
|
|
|
|
//CHECK#4
|
|
|
|
try {
|
2018-02-15 21:50:18 +01:00
|
|
|
var object = {
|
|
|
|
valueOf: function() {
|
|
|
|
throw "error"
|
|
|
|
},
|
|
|
|
toString: function() {
|
|
|
|
return "%5E"
|
|
|
|
}
|
|
|
|
};
|
2011-09-07 08:35:18 +02:00
|
|
|
if (decodeURIComponent(object) !== "^") {
|
|
|
|
$ERROR('#4.1: var object = {valueOf: function() {throw "error"}, toString: function() {return "%5E"}}; decodeURIComponent(object) === "^". Actual: ' + (decodeURIComponent(object)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
if (e === "error") {
|
|
|
|
$ERROR('#4.2: var object = {valueOf: function() {throw "error"}, toString: function() {return "%5E"}}; decodeURIComponent(object) not throw "error"');
|
|
|
|
} else {
|
|
|
|
$ERROR('#4.3: var object = {valueOf: function() {throw "error"}, toString: function() {return "%5E"}}; decodeURIComponent(object) not throw Error. Actual: ' + (e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//CHECK#5
|
2018-02-15 21:50:18 +01:00
|
|
|
var object = {
|
|
|
|
toString: function() {
|
|
|
|
return "%5E"
|
|
|
|
}
|
|
|
|
};
|
2011-09-07 08:35:18 +02:00
|
|
|
if (decodeURIComponent(object) !== "^") {
|
|
|
|
$ERROR('#5: var object = {toString: function() {return "%5E"}}; decodeURIComponent(object) === "^". Actual: ' + (decodeURIComponent(object)));
|
|
|
|
}
|
|
|
|
|
|
|
|
//CHECK#6
|
2018-02-15 21:50:18 +01:00
|
|
|
var object = {
|
|
|
|
valueOf: function() {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
toString: function() {
|
|
|
|
return "%5E"
|
|
|
|
}
|
|
|
|
}
|
2011-09-07 08:35:18 +02:00
|
|
|
if (decodeURIComponent(object) !== "^") {
|
|
|
|
$ERROR('#6: var object = {valueOf: function() {return {}}, toString: function() {return "%5E"}}; decodeURIComponent(object) === "^". Actual: ' + (decodeURIComponent(object)));
|
|
|
|
}
|
|
|
|
|
|
|
|
//CHECK#7
|
|
|
|
try {
|
2018-02-15 21:50:18 +01:00
|
|
|
var object = {
|
|
|
|
valueOf: function() {
|
|
|
|
return "%5E"
|
|
|
|
},
|
|
|
|
toString: function() {
|
|
|
|
throw "error"
|
|
|
|
}
|
|
|
|
};
|
2011-09-07 08:35:18 +02:00
|
|
|
decodeURIComponent(object);
|
|
|
|
$ERROR('#7.1: var object = {valueOf: function() {return "%5E"}, toString: function() {throw "error"}}; decodeURIComponent(object) throw "error". Actual: ' + (decodeURIComponent(object)));
|
2017-06-29 21:42:11 +02:00
|
|
|
}
|
2011-09-07 08:35:18 +02:00
|
|
|
catch (e) {
|
|
|
|
if (e !== "error") {
|
|
|
|
$ERROR('#7.2: var object = {valueOf: function() {return "%5E"}, toString: function() {throw "error"}}; decodeURIComponent(object) throw "error". Actual: ' + (e));
|
2017-06-29 21:42:11 +02:00
|
|
|
}
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//CHECK#8
|
|
|
|
try {
|
2018-02-15 21:50:18 +01:00
|
|
|
var object = {
|
|
|
|
valueOf: function() {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
toString: function() {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
};
|
2011-09-07 08:35:18 +02:00
|
|
|
decodeURIComponent(object);
|
|
|
|
$ERROR('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; decodeURIComponent(object) throw TypeError. Actual: ' + (decodeURIComponent(object)));
|
2017-06-29 21:42:11 +02:00
|
|
|
}
|
2011-09-07 08:35:18 +02:00
|
|
|
catch (e) {
|
|
|
|
if ((e instanceof TypeError) !== true) {
|
|
|
|
$ERROR('#8.2: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; decodeURIComponent(object) throw TypeError. Actual: ' + (e));
|
2017-06-29 21:42:11 +02:00
|
|
|
}
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|