From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Sat, 24 Mar 2018 05:18:03 +0100
Subject: Canvas: fingerprinting mitigations via IDL

Disable toDataURL, toBlob, getImageData and webGL renderering info
---
 third_party/blink/renderer/core/html/canvas/html_canvas_element.idl   | 4 ++--
 .../renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.idl  | 4 ++--
 third_party/blink/renderer/modules/webgl/webgl_debug_renderer_info.cc | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/third_party/blink/renderer/core/html/canvas/html_canvas_element.idl b/third_party/blink/renderer/core/html/canvas/html_canvas_element.idl
--- a/third_party/blink/renderer/core/html/canvas/html_canvas_element.idl
+++ b/third_party/blink/renderer/core/html/canvas/html_canvas_element.idl
@@ -37,9 +37,9 @@ interface HTMLCanvasElement : HTMLElement
     // Note: The arguments argument is variadic in the spec, but not here as
     // only one extra argument is actually used.
     // FIXME: type should not have a default value.
-    [MeasureAs=CanvasToDataURL, RaisesException] DOMString toDataURL(optional DOMString type = null, optional any arguments);
+    //[MeasureAs=CanvasToDataURL, RaisesException] DOMString toDataURL(optional DOMString type = null, optional any arguments);
 
-    [MeasureAs=CanvasToBlob, RaisesException] void toBlob(BlobCallback _callback, optional DOMString type = null, optional any arguments);
+    //[MeasureAs=CanvasToBlob, RaisesException] void toBlob(BlobCallback _callback, optional DOMString type = null, optional any arguments);
 };
 
 // https://html.spec.whatwg.org/multipage/canvas.html#blobcallback
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.idl b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.idl
--- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.idl
+++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.idl
@@ -110,7 +110,7 @@ interface CanvasRenderingContext2D {
     // text (see also the CanvasDrawingStyles interface)
     void fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
     void strokeText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
-    TextMetrics measureText(DOMString text);
+    //TextMetrics measureText(DOMString text);
 
     // drawing images
     [CallWith=ScriptState, RaisesException] void drawImage(CanvasImageSource image, unrestricted double x, unrestricted double y);
@@ -125,7 +125,7 @@ interface CanvasRenderingContext2D {
     // pixel manipulation
     [RaisesException] ImageData createImageData(ImageData imagedata);
     [RaisesException] ImageData createImageData(long sw, long sh);
-    [RaisesException] ImageData getImageData(long sx, long sy, long sw, long sh);
+    //[RaisesException] ImageData getImageData(long sx, long sy, long sw, long sh);
     [RaisesException] void putImageData(ImageData imagedata, long dx, long dy);
     [RaisesException] void putImageData(ImageData imagedata, long dx, long dy, long dirtyX, long dirtyY, long dirtyWidth, long dirtyHeight);
     
diff --git a/third_party/blink/renderer/modules/webgl/webgl_debug_renderer_info.cc b/third_party/blink/renderer/modules/webgl/webgl_debug_renderer_info.cc
--- a/third_party/blink/renderer/modules/webgl/webgl_debug_renderer_info.cc
+++ b/third_party/blink/renderer/modules/webgl/webgl_debug_renderer_info.cc
@@ -37,11 +37,11 @@ WebGLExtensionName WebGLDebugRendererInfo::GetName() const {
 
 WebGLDebugRendererInfo* WebGLDebugRendererInfo::Create(
     WebGLRenderingContextBase* context) {
-  return new WebGLDebugRendererInfo(context);
+  return nullptr;
 }
 
 bool WebGLDebugRendererInfo::Supported(WebGLRenderingContextBase*) {
-  return true;
+  return false;
 }
 
 const char* WebGLDebugRendererInfo::ExtensionName() {
-- 
2.7.4

