From 0ddd00f1959c78ce37c14fef3c83401408fca3bf Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Tue, 25 Feb 2020 15:07:00 -0500 Subject: Issue #439 - Remove tests from toolkit/ --- toolkit/components/mediasniffer/moz.build | 9 +- .../components/mediasniffer/test/unit/.eslintrc.js | 7 -- .../mediasniffer/test/unit/data/bug1079747.mp4 | Bin 512 -> 0 bytes .../mediasniffer/test/unit/data/detodos.mp3 | Bin 512 -> 0 bytes .../mediasniffer/test/unit/data/ff-inst.exe | Bin 512 -> 0 bytes .../mediasniffer/test/unit/data/file.mkv | Bin 512 -> 0 bytes .../mediasniffer/test/unit/data/file.webm | Bin 512 -> 0 bytes .../mediasniffer/test/unit/data/fl10.mp2 | Bin 512 -> 0 bytes .../mediasniffer/test/unit/data/he_free.mp3 | Bin 512 -> 0 bytes .../mediasniffer/test/unit/data/id3tags.mp3 | Bin 512 -> 0 bytes .../mediasniffer/test/unit/data/notags-bad.mp3 | Bin 512 -> 0 bytes .../mediasniffer/test/unit/data/notags-scan.mp3 | Bin 512 -> 0 bytes .../mediasniffer/test/unit/data/notags.mp3 | Bin 512 -> 0 bytes .../mediasniffer/test/unit/test_mediasniffer.js | 105 ------------------ .../test/unit/test_mediasniffer_ext.js | 122 --------------------- .../components/mediasniffer/test/unit/xpcshell.ini | 19 ---- 16 files changed, 1 insertion(+), 261 deletions(-) delete mode 100644 toolkit/components/mediasniffer/test/unit/.eslintrc.js delete mode 100644 toolkit/components/mediasniffer/test/unit/data/bug1079747.mp4 delete mode 100644 toolkit/components/mediasniffer/test/unit/data/detodos.mp3 delete mode 100644 toolkit/components/mediasniffer/test/unit/data/ff-inst.exe delete mode 100644 toolkit/components/mediasniffer/test/unit/data/file.mkv delete mode 100644 toolkit/components/mediasniffer/test/unit/data/file.webm delete mode 100644 toolkit/components/mediasniffer/test/unit/data/fl10.mp2 delete mode 100644 toolkit/components/mediasniffer/test/unit/data/he_free.mp3 delete mode 100644 toolkit/components/mediasniffer/test/unit/data/id3tags.mp3 delete mode 100644 toolkit/components/mediasniffer/test/unit/data/notags-bad.mp3 delete mode 100644 toolkit/components/mediasniffer/test/unit/data/notags-scan.mp3 delete mode 100644 toolkit/components/mediasniffer/test/unit/data/notags.mp3 delete mode 100644 toolkit/components/mediasniffer/test/unit/test_mediasniffer.js delete mode 100644 toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js delete mode 100644 toolkit/components/mediasniffer/test/unit/xpcshell.ini (limited to 'toolkit/components/mediasniffer') diff --git a/toolkit/components/mediasniffer/moz.build b/toolkit/components/mediasniffer/moz.build index d4f935f56..21be451dd 100644 --- a/toolkit/components/mediasniffer/moz.build +++ b/toolkit/components/mediasniffer/moz.build @@ -4,11 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] - -EXPORTS += [ - 'nsMediaSniffer.h', -] +EXPORTS += ['nsMediaSniffer.h'] UNIFIED_SOURCES += [ 'mp3sniff.c', @@ -17,6 +13,3 @@ UNIFIED_SOURCES += [ ] FINAL_LIBRARY = 'xul' - -with Files('**'): - BUG_COMPONENT = ('Core', 'Video/Audio') diff --git a/toolkit/components/mediasniffer/test/unit/.eslintrc.js b/toolkit/components/mediasniffer/test/unit/.eslintrc.js deleted file mode 100644 index d35787cd2..000000000 --- a/toolkit/components/mediasniffer/test/unit/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; - -module.exports = { - "extends": [ - "../../../../../testing/xpcshell/xpcshell.eslintrc.js" - ] -}; diff --git a/toolkit/components/mediasniffer/test/unit/data/bug1079747.mp4 b/toolkit/components/mediasniffer/test/unit/data/bug1079747.mp4 deleted file mode 100644 index f00731d7e..000000000 Binary files a/toolkit/components/mediasniffer/test/unit/data/bug1079747.mp4 and /dev/null differ diff --git a/toolkit/components/mediasniffer/test/unit/data/detodos.mp3 b/toolkit/components/mediasniffer/test/unit/data/detodos.mp3 deleted file mode 100644 index 12e3f89c2..000000000 Binary files a/toolkit/components/mediasniffer/test/unit/data/detodos.mp3 and /dev/null differ diff --git a/toolkit/components/mediasniffer/test/unit/data/ff-inst.exe b/toolkit/components/mediasniffer/test/unit/data/ff-inst.exe deleted file mode 100644 index 0f02f36e1..000000000 Binary files a/toolkit/components/mediasniffer/test/unit/data/ff-inst.exe and /dev/null differ diff --git a/toolkit/components/mediasniffer/test/unit/data/file.mkv b/toolkit/components/mediasniffer/test/unit/data/file.mkv deleted file mode 100644 index 4618cda03..000000000 Binary files a/toolkit/components/mediasniffer/test/unit/data/file.mkv and /dev/null differ diff --git a/toolkit/components/mediasniffer/test/unit/data/file.webm b/toolkit/components/mediasniffer/test/unit/data/file.webm deleted file mode 100644 index 7bc738b8b..000000000 Binary files a/toolkit/components/mediasniffer/test/unit/data/file.webm and /dev/null differ diff --git a/toolkit/components/mediasniffer/test/unit/data/fl10.mp2 b/toolkit/components/mediasniffer/test/unit/data/fl10.mp2 deleted file mode 100644 index bf84d7367..000000000 Binary files a/toolkit/components/mediasniffer/test/unit/data/fl10.mp2 and /dev/null differ diff --git a/toolkit/components/mediasniffer/test/unit/data/he_free.mp3 b/toolkit/components/mediasniffer/test/unit/data/he_free.mp3 deleted file mode 100644 index e3da8e6a7..000000000 Binary files a/toolkit/components/mediasniffer/test/unit/data/he_free.mp3 and /dev/null differ diff --git a/toolkit/components/mediasniffer/test/unit/data/id3tags.mp3 b/toolkit/components/mediasniffer/test/unit/data/id3tags.mp3 deleted file mode 100644 index 23091e666..000000000 Binary files a/toolkit/components/mediasniffer/test/unit/data/id3tags.mp3 and /dev/null differ diff --git a/toolkit/components/mediasniffer/test/unit/data/notags-bad.mp3 b/toolkit/components/mediasniffer/test/unit/data/notags-bad.mp3 deleted file mode 100644 index 5ad89786f..000000000 Binary files a/toolkit/components/mediasniffer/test/unit/data/notags-bad.mp3 and /dev/null differ diff --git a/toolkit/components/mediasniffer/test/unit/data/notags-scan.mp3 b/toolkit/components/mediasniffer/test/unit/data/notags-scan.mp3 deleted file mode 100644 index 949b7c468..000000000 Binary files a/toolkit/components/mediasniffer/test/unit/data/notags-scan.mp3 and /dev/null differ diff --git a/toolkit/components/mediasniffer/test/unit/data/notags.mp3 b/toolkit/components/mediasniffer/test/unit/data/notags.mp3 deleted file mode 100644 index c7db94361..000000000 Binary files a/toolkit/components/mediasniffer/test/unit/data/notags.mp3 and /dev/null differ diff --git a/toolkit/components/mediasniffer/test/unit/test_mediasniffer.js b/toolkit/components/mediasniffer/test/unit/test_mediasniffer.js deleted file mode 100644 index b26d554a8..000000000 --- a/toolkit/components/mediasniffer/test/unit/test_mediasniffer.js +++ /dev/null @@ -1,105 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Ci = Components.interfaces; -var Cu = Components.utils; - -Cu.import("resource://testing-common/httpd.js"); -Cu.import("resource://gre/modules/NetUtil.jsm"); - -const PATH = "/file.meh"; -var httpserver = new HttpServer(); - -// Each time, the data consist in a string that should be sniffed as Ogg. -const data = "OggS\0meeeh."; -var testRan = 0; - -// If the content-type is not present, or if it's application/octet-stream, it -// should be sniffed to application/ogg by the media sniffer. Otherwise, it -// should not be changed. -const tests = [ - // Those three first case are the case of a media loaded in a media element. - // All three should be sniffed. - { contentType: "", - expectedContentType: "application/ogg", - flags: Ci.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS | Ci.nsIChannel.LOAD_MEDIA_SNIFFER_OVERRIDES_CONTENT_TYPE }, - { contentType: "application/octet-stream", - expectedContentType: "application/ogg", - flags: Ci.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS | Ci.nsIChannel.LOAD_MEDIA_SNIFFER_OVERRIDES_CONTENT_TYPE }, - { contentType: "application/something", - expectedContentType: "application/ogg", - flags: Ci.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS | Ci.nsIChannel.LOAD_MEDIA_SNIFFER_OVERRIDES_CONTENT_TYPE }, - // This last cases test the case of a channel opened while allowing content - // sniffers to override the content-type, like in the docshell. - { contentType: "application/octet-stream", - expectedContentType: "application/ogg", - flags: Ci.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS }, - { contentType: "", - expectedContentType: "application/ogg", - flags: Ci.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS }, - { contentType: "application/something", - expectedContentType: "application/something", - flags: Ci.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS }, -]; - -// A basic listener that reads checks the if we sniffed properly. -var listener = { - onStartRequest: function(request, context) { - do_check_eq(request.QueryInterface(Ci.nsIChannel).contentType, - tests[testRan].expectedContentType); - }, - - onDataAvailable: function(request, context, stream, offset, count) { - try { - var bis = Components.classes["@mozilla.org/binaryinputstream;1"] - .createInstance(Components.interfaces.nsIBinaryInputStream); - bis.setInputStream(stream); - bis.readByteArray(bis.available()); - } catch (ex) { - do_throw("Error in onDataAvailable: " + ex); - } - }, - - onStopRequest: function(request, context, status) { - testRan++; - runNext(); - } -}; - -function setupChannel(url, flags) -{ - let uri = "http://localhost:" + - httpserver.identity.primaryPort + url; - var chan = NetUtil.newChannel({ - uri: uri, - loadUsingSystemPrincipal: true, - contentPolicyType: Ci.nsIContentPolicy.TYPE_MEDIA - }); - chan.loadFlags |= flags; - var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel); - return httpChan; -} - -function runNext() { - if (testRan == tests.length) { - do_test_finished(); - return; - } - var channel = setupChannel(PATH, tests[testRan].flags); - httpserver.registerPathHandler(PATH, function(request, response) { - response.setHeader("Content-Type", tests[testRan].contentType, false); - response.bodyOutputStream.write(data, data.length); - }); - channel.asyncOpen2(listener); -} - -function run_test() { - httpserver.start(-1); - do_test_pending(); - try { - runNext(); - } catch (e) { - print("ERROR - " + e + "\n"); - } -} diff --git a/toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js b/toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js deleted file mode 100644 index ce30a5c1b..000000000 --- a/toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js +++ /dev/null @@ -1,122 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Ci = Components.interfaces; -var Cu = Components.utils; -var Cc = Components.classes; -var CC = Components.Constructor; - -var BinaryOutputStream = CC("@mozilla.org/binaryoutputstream;1", - "nsIBinaryOutputStream", - "setOutputStream"); - -Cu.import("resource://testing-common/httpd.js"); -Cu.import("resource://gre/modules/NetUtil.jsm"); - -var httpserver = new HttpServer(); - -var testRan = 0; - -// The tests files we want to test, and the type we should have after sniffing. -const tests = [ - // Real webm and mkv files truncated to 512 bytes. - { path: "data/file.webm", expected: "video/webm" }, - { path: "data/file.mkv", expected: "application/octet-stream" }, - // MP3 files with and without id3 headers truncated to 512 bytes. - // NB these have 208/209 byte frames, but mp3 can require up to - // 1445 bytes to detect with our method. - { path: "data/id3tags.mp3", expected: "audio/mpeg" }, - { path: "data/notags.mp3", expected: "audio/mpeg" }, - // MPEG-2 mp3 files. - { path: "data/detodos.mp3", expected: "audio/mpeg" }, - // Padding bit flipped in the first header: sniffing should fail. - { path: "data/notags-bad.mp3", expected: "application/octet-stream" }, - // Garbage before header: sniffing should fail. - { path: "data/notags-scan.mp3", expected: "application/octet-stream" }, - // VBR from the layer III test patterns. We can't sniff this. - { path: "data/he_free.mp3", expected: "application/octet-stream" }, - // Make sure we reject mp2, which has a similar header. - { path: "data/fl10.mp2", expected: "application/octet-stream" }, - // Truncated ff installer regression test for bug 875769. - { path: "data/ff-inst.exe", expected: "application/octet-stream" }, - // MP4 with invalid box size (0) for "ftyp". - { path: "data/bug1079747.mp4", expected: "application/octet-stream" }, -]; - -// A basic listener that reads checks the if we sniffed properly. -var listener = { - onStartRequest: function(request, context) { - do_print("Sniffing " + tests[testRan].path); - do_check_eq(request.QueryInterface(Ci.nsIChannel).contentType, tests[testRan].expected); - }, - - onDataAvailable: function(request, context, stream, offset, count) { - try { - var bis = Components.classes["@mozilla.org/binaryinputstream;1"] - .createInstance(Components.interfaces.nsIBinaryInputStream); - bis.setInputStream(stream); - bis.readByteArray(bis.available()); - } catch (ex) { - do_throw("Error in onDataAvailable: " + ex); - } - }, - - onStopRequest: function(request, context, status) { - testRan++; - runNext(); - } -}; - -function setupChannel(url) { - var chan = NetUtil.newChannel({ - uri: "http://localhost:" + httpserver.identity.primaryPort + url, - loadUsingSystemPrincipal: true, - contentPolicyType: Ci.nsIContentPolicy.TYPE_MEDIA - }); - var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel); - return httpChan; -} - -function runNext() { - if (testRan == tests.length) { - do_test_finished(); - return; - } - var channel = setupChannel("/"); - channel.asyncOpen2(listener); -} - -function getFileContents(aFile) { - var fileStream = Cc["@mozilla.org/network/file-input-stream;1"] - .createInstance(Ci.nsIFileInputStream); - fileStream.init(aFile, 1, -1, null); - var bis = Components.classes["@mozilla.org/binaryinputstream;1"] - .createInstance(Components.interfaces.nsIBinaryInputStream); - bis.setInputStream(fileStream); - - var data = bis.readByteArray(bis.available()); - - return data; -} - -function handler(metadata, response) { - response.setStatusLine(metadata.httpVersion, 200, "OK"); - // Send an empty Content-Type, so we are guaranteed to sniff. - response.setHeader("Content-Type", "", false); - var body = getFileContents(do_get_file(tests[testRan].path)); - var bos = new BinaryOutputStream(response.bodyOutputStream); - bos.writeByteArray(body, body.length); -} - -function run_test() { - // We use a custom handler so we can change the header to force sniffing. - httpserver.registerPathHandler("/", handler); - httpserver.start(-1); - do_test_pending(); - try { - runNext(); - } catch (e) { - print("ERROR - " + e + "\n"); - } -} diff --git a/toolkit/components/mediasniffer/test/unit/xpcshell.ini b/toolkit/components/mediasniffer/test/unit/xpcshell.ini deleted file mode 100644 index 5ab4763f9..000000000 --- a/toolkit/components/mediasniffer/test/unit/xpcshell.ini +++ /dev/null @@ -1,19 +0,0 @@ -[DEFAULT] -head = -tail = -skip-if = toolkit == 'android' -support-files = - data/bug1079747.mp4 - data/detodos.mp3 - data/ff-inst.exe - data/file.mkv - data/file.webm - data/fl10.mp2 - data/he_free.mp3 - data/id3tags.mp3 - data/notags-bad.mp3 - data/notags-scan.mp3 - data/notags.mp3 - -[test_mediasniffer.js] -[test_mediasniffer_ext.js] -- cgit v1.2.3