From a17ef11404442924b9886ccdecc0732f5fc00dd2 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Wed, 24 Feb 2021 09:56:16 +0000 Subject: [PATCH] Bug 1690845. Don't ask Windows for the icon of an empty file extension because it returns the c: drive icon, which is not what we want. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D105736 --- image/decoders/icon/win/nsIconChannel.cpp | 6 ++++++ image/test/reftest/generic/moz-icon-blank-1-almostref.html | 2 ++ image/test/reftest/generic/moz-icon-blank-1-antiref.html | 2 ++ image/test/reftest/generic/moz-icon-blank-1-antiref2.html | 2 ++ image/test/reftest/generic/moz-icon-blank-1-ref.html | 2 ++ image/test/reftest/generic/moz-icon-blank-1.html | 2 ++ image/test/reftest/generic/reftest.list | 4 ++++ 7 files changed, 20 insertions(+) create mode 100644 image/test/reftest/generic/moz-icon-blank-1-almostref.html create mode 100644 image/test/reftest/generic/moz-icon-blank-1-antiref.html create mode 100644 image/test/reftest/generic/moz-icon-blank-1-antiref2.html create mode 100644 image/test/reftest/generic/moz-icon-blank-1-ref.html create mode 100644 image/test/reftest/generic/moz-icon-blank-1.html diff --git a/image/decoders/icon/win/nsIconChannel.cpp b/image/decoders/icon/win/nsIconChannel.cpp index 28d2ccc87374..3eaf9561f56f 100644 --- a/image/decoders/icon/win/nsIconChannel.cpp +++ b/image/decoders/icon/win/nsIconChannel.cpp @@ -503,6 +503,12 @@ nsresult nsIconChannel::GetHIconFromFile(bool aNonBlocking, HICON* hIcon) { filePath = u"."_ns + NS_ConvertUTF8toUTF16(defFileExt); } + if (!localFile && !fileExists && + ((filePath.Length() == 1 && filePath.Last() == '.') || + filePath.Length() == 0)) { + filePath = u".MozBogusExtensionMoz"_ns; + } + if (aNonBlocking) { RefPtr target = DecodePool::Singleton()->GetIOEventTarget(); RefPtr task = new IconAsyncOpenTask( diff --git a/image/test/reftest/generic/moz-icon-blank-1-almostref.html b/image/test/reftest/generic/moz-icon-blank-1-almostref.html new file mode 100644 index 000000000000..38d5e1ec86f8 --- /dev/null +++ b/image/test/reftest/generic/moz-icon-blank-1-almostref.html @@ -0,0 +1,2 @@ + + diff --git a/image/test/reftest/generic/moz-icon-blank-1-antiref.html b/image/test/reftest/generic/moz-icon-blank-1-antiref.html new file mode 100644 index 000000000000..2631ff40180c --- /dev/null +++ b/image/test/reftest/generic/moz-icon-blank-1-antiref.html @@ -0,0 +1,2 @@ + + diff --git a/image/test/reftest/generic/moz-icon-blank-1-antiref2.html b/image/test/reftest/generic/moz-icon-blank-1-antiref2.html new file mode 100644 index 000000000000..8553c81be0eb --- /dev/null +++ b/image/test/reftest/generic/moz-icon-blank-1-antiref2.html @@ -0,0 +1,2 @@ + + diff --git a/image/test/reftest/generic/moz-icon-blank-1-ref.html b/image/test/reftest/generic/moz-icon-blank-1-ref.html new file mode 100644 index 000000000000..086d5af837e1 --- /dev/null +++ b/image/test/reftest/generic/moz-icon-blank-1-ref.html @@ -0,0 +1,2 @@ + + diff --git a/image/test/reftest/generic/moz-icon-blank-1.html b/image/test/reftest/generic/moz-icon-blank-1.html new file mode 100644 index 000000000000..2b52c96297b2 --- /dev/null +++ b/image/test/reftest/generic/moz-icon-blank-1.html @@ -0,0 +1,2 @@ + + diff --git a/image/test/reftest/generic/reftest.list b/image/test/reftest/generic/reftest.list index bfc59b07c414..77d9c800635a 100644 --- a/image/test/reftest/generic/reftest.list +++ b/image/test/reftest/generic/reftest.list @@ -1,2 +1,6 @@ HTTP == accept-image-catchall.html accept-image-catchall-ref.html skip-if(Android) != moz-icon-1.html about:blank +== moz-icon-blank-1.html moz-icon-blank-1-ref.html +skip-if(Android) != moz-icon-blank-1-ref.html moz-icon-blank-1-antiref.html +skip-if(Android) != moz-icon-blank-1-ref.html moz-icon-blank-1-antiref2.html +fuzzy-if(OSX,44,335) fuzzy-if(winWidget,64-78,45-68) == moz-icon-blank-1-almostref.html moz-icon-blank-1-ref.html