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.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for bug 975472</title> |
michael@0 | 5 | <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> |
michael@0 | 6 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 7 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 8 | </head> |
michael@0 | 9 | <body> |
michael@0 | 10 | <video id="viewfinder" width="200" height="200" autoplay></video> |
michael@0 | 11 | <img src="#" alt="This image is going to load" id="testimage"/> |
michael@0 | 12 | <script class="testbody" type="text/javascript;version=1.7"> |
michael@0 | 13 | |
michael@0 | 14 | var whichCamera = navigator.mozCameras.getListOfCameras()[0]; |
michael@0 | 15 | var config = { |
michael@0 | 16 | mode: 'picture', |
michael@0 | 17 | recorderProfile: 'cif', |
michael@0 | 18 | previewSize: { |
michael@0 | 19 | width: 352, |
michael@0 | 20 | height: 288 |
michael@0 | 21 | } |
michael@0 | 22 | }; |
michael@0 | 23 | var options = { |
michael@0 | 24 | rotation: 0, |
michael@0 | 25 | position: { |
michael@0 | 26 | latitude: 43.645687, |
michael@0 | 27 | longitude: -79.393661 |
michael@0 | 28 | }, |
michael@0 | 29 | dateTime: Date.now() |
michael@0 | 30 | }; |
michael@0 | 31 | |
michael@0 | 32 | function onError(e) { |
michael@0 | 33 | ok(false, "Error" + JSON.stringify(e)); |
michael@0 | 34 | } |
michael@0 | 35 | function next() { |
michael@0 | 36 | Camera.nextTest(); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | // The array of tests |
michael@0 | 40 | var tests = [ |
michael@0 | 41 | { |
michael@0 | 42 | key: "release-after-release", |
michael@0 | 43 | func: function testAutoFocus(camera) { |
michael@0 | 44 | function onSuccess(success) { |
michael@0 | 45 | ok(true, "release() succeeded"); |
michael@0 | 46 | next(); |
michael@0 | 47 | } |
michael@0 | 48 | function onError(error) { |
michael@0 | 49 | ok(false, "release() failed with: " + error); |
michael@0 | 50 | } |
michael@0 | 51 | camera.release(onSuccess, onError); |
michael@0 | 52 | } |
michael@0 | 53 | }, |
michael@0 | 54 | { |
michael@0 | 55 | key: "set-picture-size-after-release", |
michael@0 | 56 | func: function testSetPictureSize(camera) { |
michael@0 | 57 | camera.pictureSize = { width: 0, height: 0 }; |
michael@0 | 58 | next(); |
michael@0 | 59 | } |
michael@0 | 60 | }, |
michael@0 | 61 | { |
michael@0 | 62 | key: "set-thumbnail-size-after-release", |
michael@0 | 63 | func: function testSetThumbnailSize(camera) { |
michael@0 | 64 | camera.thumbnailSize = { width: 0, height: 0 }; |
michael@0 | 65 | next(); |
michael@0 | 66 | } |
michael@0 | 67 | }, |
michael@0 | 68 | { |
michael@0 | 69 | key: "get-sensor-angle-after-release", |
michael@0 | 70 | func: function testGetSensorAngle(camera) { |
michael@0 | 71 | ok(camera.sensorAngle == 0, "camera.sensorAngle = " + camera.sensorAngle); |
michael@0 | 72 | next(); |
michael@0 | 73 | } |
michael@0 | 74 | }, |
michael@0 | 75 | { |
michael@0 | 76 | key: "resume-preview-after-release", |
michael@0 | 77 | func: function testResumePreview(camera) { |
michael@0 | 78 | camera.resumePreview(); |
michael@0 | 79 | next(); |
michael@0 | 80 | } |
michael@0 | 81 | }, |
michael@0 | 82 | { |
michael@0 | 83 | key: "auto-focus-after-release", |
michael@0 | 84 | func: function testAutoFocus(camera) { |
michael@0 | 85 | function onSuccess(success) { |
michael@0 | 86 | ok(false, "autoFocus() succeeded incorrectly"); |
michael@0 | 87 | } |
michael@0 | 88 | function onError(error) { |
michael@0 | 89 | ok(true, "autoFocus() failed correctly with: " + error); |
michael@0 | 90 | next(); |
michael@0 | 91 | } |
michael@0 | 92 | camera.autoFocus(onSuccess, onError); |
michael@0 | 93 | } |
michael@0 | 94 | }, |
michael@0 | 95 | { |
michael@0 | 96 | key: "take-picture-after-release", |
michael@0 | 97 | func: function testTakePicture(camera) { |
michael@0 | 98 | function onSuccess(picture) { |
michael@0 | 99 | ok(false, "takePicture() succeeded incorrectly"); |
michael@0 | 100 | } |
michael@0 | 101 | function onError(error) { |
michael@0 | 102 | ok(true, "takePicture() failed correctly with: " + error); |
michael@0 | 103 | next(); |
michael@0 | 104 | } |
michael@0 | 105 | camera.takePicture(null, onSuccess, onError); |
michael@0 | 106 | } |
michael@0 | 107 | }, |
michael@0 | 108 | { |
michael@0 | 109 | key: "start-recording-after-release", |
michael@0 | 110 | func: function testStartRecording(camera) { |
michael@0 | 111 | function onSuccess(picture) { |
michael@0 | 112 | ok(false, "startRecording() process succeeded incorrectly"); |
michael@0 | 113 | } |
michael@0 | 114 | function onError(error) { |
michael@0 | 115 | ok(true, "startRecording() process failed correctly with: " + error); |
michael@0 | 116 | next(); |
michael@0 | 117 | } |
michael@0 | 118 | var recordingOptions = { |
michael@0 | 119 | profile: 'cif', |
michael@0 | 120 | rotation: 0 |
michael@0 | 121 | }; |
michael@0 | 122 | camera.startRecording(recordingOptions, |
michael@0 | 123 | navigator.getDeviceStorage('videos'), |
michael@0 | 124 | 'bug975472.mp4', |
michael@0 | 125 | onSuccess, onError); |
michael@0 | 126 | } |
michael@0 | 127 | }, |
michael@0 | 128 | { |
michael@0 | 129 | key: "stop-recording-after-release", |
michael@0 | 130 | func: function testStopRecording(camera) { |
michael@0 | 131 | camera.stopRecording(); |
michael@0 | 132 | next(); |
michael@0 | 133 | } |
michael@0 | 134 | }, |
michael@0 | 135 | { |
michael@0 | 136 | key: "set-configuration-after-release", |
michael@0 | 137 | func: function testSetConfiguration(camera) { |
michael@0 | 138 | function onSuccess(picture) { |
michael@0 | 139 | ok(false, "setConfiguration() process succeeded incorrectly"); |
michael@0 | 140 | } |
michael@0 | 141 | function onError(error) { |
michael@0 | 142 | ok(true, "setConfiguration() process failed correctly with: " + error); |
michael@0 | 143 | next(); |
michael@0 | 144 | } |
michael@0 | 145 | camera.setConfiguration(config, onSuccess, onError); |
michael@0 | 146 | } |
michael@0 | 147 | }, |
michael@0 | 148 | ]; |
michael@0 | 149 | |
michael@0 | 150 | var testGenerator = function() { |
michael@0 | 151 | for (var i = 0; i < tests.length; ++i ) { |
michael@0 | 152 | yield tests[i]; |
michael@0 | 153 | } |
michael@0 | 154 | }(); |
michael@0 | 155 | |
michael@0 | 156 | var Camera = { |
michael@0 | 157 | cameraObj: null, |
michael@0 | 158 | _otherPictureSize: null, |
michael@0 | 159 | get viewfinder() { |
michael@0 | 160 | return document.getElementById('viewfinder'); |
michael@0 | 161 | }, |
michael@0 | 162 | onCameraReady: function () { |
michael@0 | 163 | Camera.nextTest = function() { |
michael@0 | 164 | try { |
michael@0 | 165 | var t = testGenerator.next(); |
michael@0 | 166 | info("test: " + t.key); |
michael@0 | 167 | t.func(Camera.cameraObj); |
michael@0 | 168 | } catch(e) { |
michael@0 | 169 | if (e instanceof StopIteration) { |
michael@0 | 170 | SimpleTest.finish(); |
michael@0 | 171 | } else { |
michael@0 | 172 | throw e; |
michael@0 | 173 | } |
michael@0 | 174 | } |
michael@0 | 175 | }; |
michael@0 | 176 | // Release the camera hardware, and call all of the asynchronous methods |
michael@0 | 177 | // to make sure they properly handle being in this state. |
michael@0 | 178 | Camera.cameraObj.release(); |
michael@0 | 179 | next(); |
michael@0 | 180 | }, |
michael@0 | 181 | release: function release() { |
michael@0 | 182 | cameraObj = null; |
michael@0 | 183 | }, |
michael@0 | 184 | start: function run_test() { |
michael@0 | 185 | function onSuccess(camera, config) { |
michael@0 | 186 | Camera.cameraObj = camera; |
michael@0 | 187 | Camera.viewfinder.mozSrcObject = camera; |
michael@0 | 188 | Camera.viewfinder.play(); |
michael@0 | 189 | ok(camera.capabilities.pictureSizes.length > 0, |
michael@0 | 190 | "capabilities.pictureSizes.length = " + |
michael@0 | 191 | camera.capabilities.pictureSizes.length); |
michael@0 | 192 | Camera._otherPictureSize = camera.capabilities.pictureSizes.slice(-1)[0]; |
michael@0 | 193 | camera.pictureSize = camera.capabilities.pictureSizes[0]; |
michael@0 | 194 | options.pictureSize = Camera._otherPictureSize; |
michael@0 | 195 | options.fileFormat = camera.capabilities.fileFormats[0]; |
michael@0 | 196 | info("getCamera callback, setting pictureSize = " + options.pictureSize.toSource()); |
michael@0 | 197 | Camera.cameraObj.onPreviewStateChange = function(state) { |
michael@0 | 198 | if (state === 'started') { |
michael@0 | 199 | info("viewfinder is ready and playing"); |
michael@0 | 200 | Camera.cameraObj.onPreviewStateChange = null; |
michael@0 | 201 | Camera.onCameraReady(); |
michael@0 | 202 | } |
michael@0 | 203 | }; |
michael@0 | 204 | }; |
michael@0 | 205 | navigator.mozCameras.getCamera(whichCamera, config, onSuccess, onError); |
michael@0 | 206 | } |
michael@0 | 207 | } |
michael@0 | 208 | |
michael@0 | 209 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 210 | |
michael@0 | 211 | window.addEventListener('beforeunload', function() { |
michael@0 | 212 | Camera.viewfinder.mozSrcObject = null; |
michael@0 | 213 | Camera.cameraObj.release(); |
michael@0 | 214 | Camera.cameraObj = null; |
michael@0 | 215 | }); |
michael@0 | 216 | |
michael@0 | 217 | Camera.start(); |
michael@0 | 218 | |
michael@0 | 219 | </script> |
michael@0 | 220 | </body> |
michael@0 | 221 | |
michael@0 | 222 | </html> |