Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test for multiple calls to mozCameras.getCamera()</title>
5 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
6 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
8 </head>
9 <body>
10 <video id="viewfinder" width="200" height="200" autoplay></video>
11 <img src="#" alt="This image is going to load" id="testimage"/>
12 <script class="testbody" type="text/javascript;version=1.7">
14 var whichCamera = navigator.mozCameras.getListOfCameras()[0];
15 var options = {
16 mode: 'picture',
17 recorderProfile: 'cif',
18 previewSize: {
19 width: 352,
20 height: 288
21 }
22 };
24 function onError(e) {
25 ok(false, "Error" + JSON.stringify(e));
26 }
28 var Camera = {
29 cameraObj: null,
30 get viewfinder() {
31 return document.getElementById('viewfinder');
32 },
33 onReady: function take_two() {
34 function onSuccess(camera, config) {
35 ok(false, "Unexpectedly got second camera instance: " + config.toSource);
36 }
37 function onFailure(error) {
38 ok(true, "Correctly failed to get camera again");
39 SimpleTest.finish();
40 }
41 navigator.mozCameras.getCamera(whichCamera, options, onSuccess, onFailure);
42 },
43 release: function release() {
44 cameraObj = null;
45 },
46 start: function run_test() {
47 function onSuccess(camera, config) {
48 Camera.cameraObj = camera;
49 Camera.viewfinder.mozSrcObject = camera;
50 Camera.viewfinder.play();
51 Camera.cameraObj.onPreviewStateChange = function(state) {
52 if (state === 'started') {
53 ok(true, "viewfinder is ready and playing");
54 Camera.cameraObj.onPreviewStateChange = null;
55 Camera.onReady();
56 }
57 };
58 };
59 navigator.mozCameras.getCamera(whichCamera, options, onSuccess, onError);
60 }
61 }
63 SimpleTest.waitForExplicitFinish();
65 window.addEventListener('beforeunload', function() {
66 Camera.viewfinder.mozSrcObject = null;
67 Camera.cameraObj.release();
68 Camera.cameraObj = null;
69 });
71 Camera.start();
73 </script>
74 </body>
76 </html>