LEFT | RIGHT |
(no file at all) | |
1 // Copyright (C) 2011 Google Inc. | 1 // Copyright (C) 2011 Google Inc. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 /** | 15 /** |
16 * @fileoverview Test failover from ES5 to ES53 on unsupported browsers. | 16 * @fileoverview Test failover from ES5 to ES53 on unsupported browsers. |
17 * Relies on requesting unachievable MAGICAL_UNICORN level of security | 17 * Relies on requesting unachievable MAGICAL_UNICORN level of security |
18 * to force failover on modern browsers. | 18 * to force failover on modern browsers. |
19 * | 19 * |
20 * @author jasvir@gmail.com | 20 * @author jasvir@gmail.com |
21 * @requires caja, jsunitRun, readyToTest | 21 * @requires caja, jsunitRun, readyToTest |
22 */ | 22 */ |
23 | 23 |
24 (function () { | 24 (function () { |
25 document.title += ' {closured=' + !caja.closureCanary + '}'; | 25 document.title += ' {closured=' + !caja.closureCanary + '}'; |
26 | 26 |
27 var uriPolicy = caja.policy.net.ALL; | 27 var uriPolicy = caja.policy.net.ALL; |
| 28 var inES5Mode = false; |
28 | 29 |
29 caja.initialize({ | 30 caja.initialize({ |
30 cajaServer: '/caja', | 31 cajaServer: '/caja', |
31 debug: true, | 32 debug: true, |
32 es5Mode: undefined, | 33 es5Mode: undefined, |
33 // Unachievable level of security - should cause es5 => es53 failover | 34 // Unachievable level of security - should cause es5 => es53 failover |
34 maxAcceptableSeverity: 'MAGICAL_UNICORN' | 35 maxAcceptableSeverity: 'MAGICAL_UNICORN' |
35 },· | 36 },· |
36 function(details) { assertFalse("Ran wrong mode", details['es5Mode']); }, | 37 function(details) { |
| 38 inES5Mode = details['es5Mode']; |
| 39 assertFalse("Ran wrong mode", inES5Mode); |
| 40 }, |
37 function() { fail('Unexpectedly failed to switch to es53'); }); | 41 function() { fail('Unexpectedly failed to switch to es53'); }); |
38 | 42 |
39 registerTest('testES5FailsoverToES53', function testES5FailsoverToES53() { | 43 registerTest('testES5FailsoverToES53', function testES5FailsoverToES53() { |
40 caja.load(undefined, uriPolicy, function (frame) { | 44 caja.load(undefined, uriPolicy, function (frame) { |
| 45 var extraImports = createExtraImportsForTesting(caja, frame); |
| 46 extraImports.inES5Mode = inES5Mode; |
41 frame.code('es53-test-assert-es53mode.js', 'text/javascript') | 47 frame.code('es53-test-assert-es53mode.js', 'text/javascript') |
42 .api(createExtraImportsForTesting(caja, frame)) | 48 .api(extraImports) |
43 .run(function(result) { | 49 .run(function(result) { |
44 jsunitPass('testES5FailsoverToES53'); | 50 jsunitPass('testES5FailsoverToES53'); |
45 }); | 51 }); |
46 }); | 52 }); |
47 }); | 53 }); |
48 | 54 |
49 readyToTest(); | 55 readyToTest(); |
50 jsunitRun(); | 56 jsunitRun(); |
51 | 57 |
52 })(); | 58 })(); |
LEFT | RIGHT |