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