Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Caja.js unittests should fail on multiple evaluation #13

Closed
kpreid opened this issue Apr 16, 2015 · 4 comments
Closed

Caja.js unittests should fail on multiple evaluation #13

kpreid opened this issue Apr 16, 2015 · 4 comments

Comments

@kpreid
Copy link
Contributor

kpreid commented Apr 16, 2015

Original issue 13 created by mikesamuel on 2007-12-05T04:22:32.000Z:

Jeff Walden reports that
var o =
{
toString: function()
{
if (firstTime)
{
firstTime = false;
return "toString"; // guessing this is readable on functions
}
return "constructor";
}
};
triggered a bug in readPub__ causing it to return the constructor.

We should use a similar trick to define an object

function singleUseFunction(x) {
var called = false;
return function () {
if (called) { throw new Error('Called multiple times'); }
called = true;
return x;
};
}

var o = {
toString: singleUseFunction('x'),
valueOf: singleUseFunction('x')
};

and pass o as a key to readPub et al.

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

Please use labels and text to provide additional information.

@kpreid
Copy link
Contributor Author

kpreid commented Apr 16, 2015

Comment #1 originally posted by anil262646 on 2008-01-23T12:03:35.000Z:

<empty>

@kpreid
Copy link
Contributor Author

kpreid commented Apr 16, 2015

Comment #2 originally posted by mikesamuel on 2008-05-28T01:48:40.000Z:

<empty>

@kpreid
Copy link
Contributor Author

kpreid commented Apr 16, 2015

Comment #3 originally posted by metaweta on 2008-05-28T19:36:07.000Z:

<empty>

@kpreid
Copy link
Contributor Author

kpreid commented Apr 16, 2015

Comment #4 originally posted by metaweta on 2008-05-28T21:56:26.000Z:

Refiling this as issue323, highlighting it as a bug in Caja rather than in our unit
tests.

@kpreid kpreid closed this as completed Apr 16, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant