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 autoswitching to ES5 supported browsers. | 16 * @fileoverview Test autoswitching to ES5 supported browsers. |
17 * Relies on requesting always achievable NEW_SYMPTOM level of security | 17 * Relies on requesting always achievable NEW_SYMPTOM level of security |
18 * to gurantee support on modern browsers. | 18 * to gurantee support 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 disableSecurityForDebugger: true, | 33 disableSecurityForDebugger: true, |
33 es5Mode: undefined, | 34 es5Mode: undefined, |
34 // Guaranteed achievable level of insecurity - should cause es5 to run | 35 // Guaranteed achievable level of insecurity - should cause es5 to run |
35 maxAcceptableSeverity: 'NEW_SYMPTOM' | 36 maxAcceptableSeverity: 'NEW_SYMPTOM' |
36 },· | 37 },· |
37 function(details) { assertTrue("Ran wrong mode", details['es5Mode']); }, | 38 function(details) { |
| 39 inES5Mode = details['es5Mode']; |
| 40 assertTrue("Ran wrong mode", inES5Mode); |
| 41 }, |
38 function() { fail('Unexpectedly failed to switch to run es5'); }); | 42 function() { fail('Unexpectedly failed to switch to run es5'); }); |
39 | 43 |
40 registerTest('testES5Autodetected', function testES5Autodetected() { | 44 registerTest('testES5Autodetected', function testES5Autodetected() { |
41 caja.load(undefined, uriPolicy, function (frame) { | 45 caja.load(undefined, uriPolicy, function (frame) { |
42 var extraImports = createExtraImportsForTesting(caja, frame); | 46 var extraImports = createExtraImportsForTesting(caja, frame); |
| 47 extraImports.inES5Mode = inES5Mode; |
43 frame.code('es53-test-assert-es5mode.js', 'text/javascript') | 48 frame.code('es53-test-assert-es5mode.js', 'text/javascript') |
44 .api(extraImports) | 49 .api(extraImports) |
45 .run(function(result) { | 50 .run(function(result) { |
46 jsunitPass('testES5Autodetected'); | 51 jsunitPass('testES5Autodetected'); |
47 }); | 52 }); |
48 }); | 53 }); |
49 }); | 54 }); |
50 | 55 |
51 readyToTest(); | 56 readyToTest(); |
52 jsunitRun(); | 57 jsunitRun(); |
53 | 58 |
54 })(); | 59 })(); |
LEFT | RIGHT |