toolkit/devtools/server/tests/mochitest/test_inspector_getImageData.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=932937
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <meta charset="utf-8">
michael@0 8 <title>Test for Bug 932937</title>
michael@0 9
michael@0 10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 11 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
michael@0 12 <script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
michael@0 13 <script type="application/javascript;version=1.8">
michael@0 14 Components.utils.import("resource://gre/modules/devtools/Loader.jsm");
michael@0 15 const {Promise: promise} = Components.utils.import("resource://gre/modules/Promise.jsm", {});
michael@0 16
michael@0 17 const inspector = devtools.require("devtools/server/actors/inspector");
michael@0 18
michael@0 19 window.onload = function() {
michael@0 20 SimpleTest.waitForExplicitFinish();
michael@0 21 runNextTest();
michael@0 22 }
michael@0 23
michael@0 24 var gWalker = null;
michael@0 25
michael@0 26 addTest(function setup() {
michael@0 27 let url = document.getElementById("inspectorContent").href;
michael@0 28 attachURL(url, function(err, client, tab, doc) {
michael@0 29 let {InspectorFront} = devtools.require("devtools/server/actors/inspector");
michael@0 30 let inspector = InspectorFront(client, tab);
michael@0 31
michael@0 32 promiseDone(inspector.getWalker().then(walker => {
michael@0 33 gWalker = walker;
michael@0 34 }).then(runNextTest));
michael@0 35 });
michael@0 36 });
michael@0 37
michael@0 38 addTest(function testLargeImage() {
michael@0 39 // Select the image node from the test page
michael@0 40 gWalker.querySelector(gWalker.rootNode, ".big-horizontal").then(img => {
michael@0 41 ok(img, "Image node found in the test page");
michael@0 42 ok(img.getImageData, "Image node has the getImageData function");
michael@0 43
michael@0 44 img.getImageData(100).then(imageData => {
michael@0 45 ok(imageData.data, "Image data actor was sent back");
michael@0 46 ok(imageData.size, "Image size info was sent back too");
michael@0 47 is(imageData.size.naturalWidth, 5333, "Natural width of the image correct");
michael@0 48 is(imageData.size.naturalHeight, 3000, "Natural width of the image correct");
michael@0 49 ok(imageData.size.resized, "Image was resized");
michael@0 50
michael@0 51 imageData.data.string().then(str => {
michael@0 52 ok(str, "We have an image data string!");
michael@0 53 runNextTest();
michael@0 54 });
michael@0 55 });
michael@0 56 });
michael@0 57 });
michael@0 58
michael@0 59 addTest(function testLargeCanvas() {
michael@0 60 // Select the canvas node from the test page
michael@0 61 gWalker.querySelector(gWalker.rootNode, ".big-vertical").then(canvas => {
michael@0 62 ok(canvas, "Image node found in the test page");
michael@0 63 ok(canvas.getImageData, "Image node has the getImageData function");
michael@0 64
michael@0 65 canvas.getImageData(350).then(imageData => {
michael@0 66 ok(imageData.data, "Image data actor was sent back");
michael@0 67 ok(imageData.size, "Image size info was sent back too");
michael@0 68 is(imageData.size.naturalWidth, 1000, "Natural width of the image correct");
michael@0 69 is(imageData.size.naturalHeight, 2000, "Natural width of the image correct");
michael@0 70 ok(imageData.size.resized, "Image was resized");
michael@0 71
michael@0 72 imageData.data.string().then(str => {
michael@0 73 ok(str, "We have an image data string!");
michael@0 74 runNextTest();
michael@0 75 });
michael@0 76 });
michael@0 77 });
michael@0 78 });
michael@0 79
michael@0 80 addTest(function testSmallImage() {
michael@0 81 // Select the small image node from the test page
michael@0 82 gWalker.querySelector(gWalker.rootNode, ".small").then(img => {
michael@0 83 ok(img, "Image node found in the test page");
michael@0 84 ok(img.getImageData, "Image node has the getImageData function");
michael@0 85
michael@0 86 img.getImageData().then(imageData => {
michael@0 87 ok(imageData.data, "Image data actor was sent back");
michael@0 88 ok(imageData.size, "Image size info was sent back too");
michael@0 89 is(imageData.size.naturalWidth, 245, "Natural width of the image correct");
michael@0 90 is(imageData.size.naturalHeight, 240, "Natural width of the image correct");
michael@0 91 ok(!imageData.size.resized, "Image was NOT resized");
michael@0 92
michael@0 93 imageData.data.string().then(str => {
michael@0 94 ok(str, "We have an image data string!");
michael@0 95 runNextTest();
michael@0 96 });
michael@0 97 });
michael@0 98 });
michael@0 99 });
michael@0 100
michael@0 101 addTest(function cleanup() {
michael@0 102 delete gWalker;
michael@0 103 runNextTest();
michael@0 104 });
michael@0 105 </script>
michael@0 106 </head>
michael@0 107 <body>
michael@0 108 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=932937">Mozilla Bug 932937</a>
michael@0 109 <a id="inspectorContent" target="_blank" href="inspector_getImageData.html">Test Document</a>
michael@0 110 <p id="display"></p>
michael@0 111 <div id="content" style="display: none">
michael@0 112
michael@0 113 </div>
michael@0 114 <pre id="test">
michael@0 115 </pre>
michael@0 116 </body>
michael@0 117 </html>

mercurial