From 3c9f8cb8000d65bb51db3f665d557604748616c4 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Fri, 28 Feb 2014 15:01:47 +1300 Subject: [PATCH 01/62] Bug 975270 - Fire 'emptied' and 'abort' asynchronously in media load algorithm, as per spec. r=roc --- content/html/content/src/HTMLMediaElement.cpp | 4 +- content/media/test/mochitest.ini | 1 + .../media/test/test_reset_events_async.html | 58 +++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 content/media/test/test_reset_events_async.html diff --git a/content/html/content/src/HTMLMediaElement.cpp b/content/html/content/src/HTMLMediaElement.cpp index ad05fac7d0b..ff41e516574 100644 --- a/content/html/content/src/HTMLMediaElement.cpp +++ b/content/html/content/src/HTMLMediaElement.cpp @@ -617,7 +617,7 @@ void HTMLMediaElement::AbortExistingLoads() if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_LOADING || mNetworkState == nsIDOMHTMLMediaElement::NETWORK_IDLE) { - DispatchEvent(NS_LITERAL_STRING("abort")); + DispatchAsyncEvent(NS_LITERAL_STRING("abort")); } mError = nullptr; @@ -648,7 +648,7 @@ void HTMLMediaElement::AbortExistingLoads() // change will be reflected in the controls. FireTimeUpdate(false); } - DispatchEvent(NS_LITERAL_STRING("emptied")); + DispatchAsyncEvent(NS_LITERAL_STRING("emptied")); } // We may have changed mPaused, mAutoplaying, mNetworkState and other diff --git a/content/media/test/mochitest.ini b/content/media/test/mochitest.ini index cf4607b19c6..b572f9a212f 100644 --- a/content/media/test/mochitest.ini +++ b/content/media/test/mochitest.ini @@ -356,6 +356,7 @@ support-files = [test_reactivate.html] [test_readyState.html] [test_referer.html] +[test_reset_events_async.html] [test_replay_metadata.html] [test_seek2.html] [test_seek_out_of_range.html] diff --git a/content/media/test/test_reset_events_async.html b/content/media/test/test_reset_events_async.html new file mode 100644 index 00000000000..d47f33d324c --- /dev/null +++ b/content/media/test/test_reset_events_async.html @@ -0,0 +1,58 @@ + + + + + + Test for Bug + + + + + + +Mozilla Bug +

+ +
+
+ + From 6f75686d2cfe7c64d4898c25da18d09636951558 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Tue, 4 Mar 2014 09:58:06 +0100 Subject: [PATCH 02/62] Bug 977900: Add collide method back in Array.scatterPar; r=shu --- js/src/builtin/Array.js | 7 +++++++ js/src/jit-test/tests/parallel/bug977900.js | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 js/src/jit-test/tests/parallel/bug977900.js diff --git a/js/src/builtin/Array.js b/js/src/builtin/Array.js index 122e3daafd3..222a3c2b416 100644 --- a/js/src/builtin/Array.js +++ b/js/src/builtin/Array.js @@ -890,6 +890,13 @@ function ArrayScatterPar(targets, defaultValue, conflictFunc, length, mode) { return buffer; } + function collide(elem1, elem2) { + if (conflictFunc === undefined) + ThrowError(JSMSG_PAR_ARRAY_SCATTER_CONFLICT); + + return conflictFunc(elem1, elem2); + } + function checkTarget(i, t) { if (TO_INT32(t) !== t) ThrowError(JSMSG_PAR_ARRAY_SCATTER_BAD_TARGET, i); diff --git a/js/src/jit-test/tests/parallel/bug977900.js b/js/src/jit-test/tests/parallel/bug977900.js new file mode 100644 index 00000000000..6fe52e258ad --- /dev/null +++ b/js/src/jit-test/tests/parallel/bug977900.js @@ -0,0 +1,5 @@ +if (!getBuildConfiguration().parallelJS) + quit(); + +function chooseMax(a, b) { return a>b?a:b;}; +var a = [1,2].scatterPar([0,0], -1, chooseMax); From 235d795790aa8485b5ee93b51c66d70cc6713ed1 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Tue, 4 Mar 2014 10:00:30 +0100 Subject: [PATCH 03/62] Bug 978714: Initialize codeIsProtected_ in Odin; r=luke --- js/src/jit-test/tests/asm.js/testBug978714.js | 9 +++++++++ js/src/jit/AsmJSModule.cpp | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 js/src/jit-test/tests/asm.js/testBug978714.js diff --git a/js/src/jit-test/tests/asm.js/testBug978714.js b/js/src/jit-test/tests/asm.js/testBug978714.js new file mode 100644 index 00000000000..06dec506a63 --- /dev/null +++ b/js/src/jit-test/tests/asm.js/testBug978714.js @@ -0,0 +1,9 @@ +if (!getBuildConfiguration().parallelJS) + quit(); + +var y = Array.buildPar(9, function() {}); +Array.prototype.every.call(y, (function() { + "use asm"; + function f() {} + return f +})) diff --git a/js/src/jit/AsmJSModule.cpp b/js/src/jit/AsmJSModule.cpp index dd5f570d8be..82f2e8919eb 100644 --- a/js/src/jit/AsmJSModule.cpp +++ b/js/src/jit/AsmJSModule.cpp @@ -347,7 +347,8 @@ AsmJSModule::AsmJSModule(ScriptSource *scriptSource, uint32_t charsBegin) dynamicallyLinked_(false), loadedFromCache_(false), charsBegin_(charsBegin), - scriptSource_(scriptSource) + scriptSource_(scriptSource), + codeIsProtected_(false) { mozilla::PodZero(&pod); scriptSource_->incref(); From 4a6d5a5ad682ece29021d0865da0e1321d2220e2 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Tue, 25 Feb 2014 14:21:59 +0100 Subject: [PATCH 04/62] Bug 946618 - Add native tests for cubeb (build system bits). r=glandium,kinetik --- layout/media/symbols.def.in | 1 + media/libcubeb/moz.build | 1 + media/libcubeb/src/moz.build | 2 ++ media/libcubeb/tests/Makefile.in | 26 ++++++++++++++++++++++++++ media/libcubeb/tests/moz.build | 19 +++++++++++++++++++ media/libcubeb/update.sh | 6 ++++++ 6 files changed, 55 insertions(+) create mode 100644 media/libcubeb/tests/Makefile.in create mode 100644 media/libcubeb/tests/moz.build diff --git a/layout/media/symbols.def.in b/layout/media/symbols.def.in index 1f07980ffa9..d7e90b4396a 100644 --- a/layout/media/symbols.def.in +++ b/layout/media/symbols.def.in @@ -132,6 +132,7 @@ speex_resampler_reset_mem speex_resampler_strerror cubeb_destroy cubeb_init +cubeb_get_backend_id cubeb_get_max_channel_count cubeb_get_min_latency cubeb_get_preferred_sample_rate diff --git a/media/libcubeb/moz.build b/media/libcubeb/moz.build index e9b8e10b831..7fd2825404a 100644 --- a/media/libcubeb/moz.build +++ b/media/libcubeb/moz.build @@ -5,4 +5,5 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DIRS += ['include', 'src'] +TEST_TOOL_DIRS += ['tests'] diff --git a/media/libcubeb/src/moz.build b/media/libcubeb/src/moz.build index 46d79adb0a1..c629863a306 100644 --- a/media/libcubeb/src/moz.build +++ b/media/libcubeb/src/moz.build @@ -4,6 +4,8 @@ # 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/. +LIBRARY_NAME = 'cubeb' + SOURCES += [ 'cubeb.c', ] diff --git a/media/libcubeb/tests/Makefile.in b/media/libcubeb/tests/Makefile.in new file mode 100644 index 00000000000..b16ee8aa1b5 --- /dev/null +++ b/media/libcubeb/tests/Makefile.in @@ -0,0 +1,26 @@ +# -*- Mode: makefile; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- # +# 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/. + +ifeq ($(OS_ARCH),WINNT) + # On windows, the WASAPI backend needs the resampler we have in + # /media/libspeex_resampler, so we can't get away with just linking cubeb's .o + LIBS = $(call EXPAND_LIBNAME_PATH,gkmedias,$(DEPTH)/layout/media) \ + $(NULL) +else + # Otherwise, we can just grab all the compiled .o and compile against that, + # linking the appriopriate libraries. + LIBS = $(call EXPAND_LIBNAME_PATH,cubeb,$(DEPTH)/media/libcubeb/src) + ifeq ($(OS_TARGET),Darwin) + LIBS += -framework AudioUnit -framework CoreAudio + else + ifeq ($(OS_TARGET), OpenBSD) + LIBS += -lsndio + else + LIBS += $(MOZ_ALSA_LIBS) \ + $(MOZ_PULSEAUDIO_LIBS) + endif + endif + LIBS += $(NULL) +endif diff --git a/media/libcubeb/tests/moz.build b/media/libcubeb/tests/moz.build new file mode 100644 index 00000000000..4f531e0f03b --- /dev/null +++ b/media/libcubeb/tests/moz.build @@ -0,0 +1,19 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + +CPP_UNIT_TESTS += [ + 'test_audio.cpp', + 'test_latency.cpp', + 'test_sanity.cpp', + 'test_tone.cpp' +] + +LOCAL_INCLUDES += [ + '../include' +] + +FAIL_ON_WARNINGS = True + diff --git a/media/libcubeb/update.sh b/media/libcubeb/update.sh index 5d012b7301a..1d055dece22 100644 --- a/media/libcubeb/update.sh +++ b/media/libcubeb/update.sh @@ -18,6 +18,12 @@ cp $1/src/android/sles_definitions.h src/android cp $1/LICENSE . cp $1/README . cp $1/AUTHORS . +cp $1/test/common.h tests/common.h +cp $1/test/test_audio.c tests/test_audio.cpp +cp $1/test/test_tone.c tests/test_tone.cpp +cp $1/test/test_sanity.c tests/test_sanity.cpp +cp $1/test/test_latency.c tests/test_latency.cpp + if [ -d $1/.git ]; then rev=$(cd $1 && git rev-parse --verify HEAD) dirty=$(cd $1 && git diff-index --name-only HEAD) From 63c8e598d437e1685e111083bb23cae0b4fad3ea Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Thu, 27 Feb 2014 16:26:24 +0100 Subject: [PATCH 05/62] Bug 946618 - Update libcubeb from upstream to pick up new tests. r=kinetik --- media/libcubeb/README_MOZILLA | 2 +- media/libcubeb/tests/common.h | 30 ++ media/libcubeb/tests/test_audio.cpp | 174 ++++++++++ media/libcubeb/tests/test_latency.cpp | 39 +++ media/libcubeb/tests/test_sanity.cpp | 466 ++++++++++++++++++++++++++ media/libcubeb/tests/test_tone.cpp | 117 +++++++ 6 files changed, 827 insertions(+), 1 deletion(-) create mode 100644 media/libcubeb/tests/common.h create mode 100644 media/libcubeb/tests/test_audio.cpp create mode 100644 media/libcubeb/tests/test_latency.cpp create mode 100644 media/libcubeb/tests/test_sanity.cpp create mode 100644 media/libcubeb/tests/test_tone.cpp diff --git a/media/libcubeb/README_MOZILLA b/media/libcubeb/README_MOZILLA index 1caf0347907..3c8330da59a 100644 --- a/media/libcubeb/README_MOZILLA +++ b/media/libcubeb/README_MOZILLA @@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system. The cubeb git repository is: git://github.com/kinetiknz/cubeb.git -The git commit ID used was e8df12d770c6299640540e91cec13dc81efc9bbe. +The git commit ID used was bb0437c060a85a4f1f11b962a53ca0af02801967. diff --git a/media/libcubeb/tests/common.h b/media/libcubeb/tests/common.h new file mode 100644 index 00000000000..47cc28cc7f4 --- /dev/null +++ b/media/libcubeb/tests/common.h @@ -0,0 +1,30 @@ +/* + * Copyright © 2013 Sebastien Alaiwan + * + * This program is made available under an ISC-style license. See the + * accompanying file LICENSE for details. + */ + +#if defined( _WIN32) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#else +#include +#endif + +void delay(unsigned int ms) +{ +#if defined(_WIN32) + Sleep(ms); +#else + sleep(ms / 1000); + usleep(ms % 1000 * 1000); +#endif +} + +#if !defined(M_PI) +#define M_PI 3.14159265358979323846 +#endif + diff --git a/media/libcubeb/tests/test_audio.cpp b/media/libcubeb/tests/test_audio.cpp new file mode 100644 index 00000000000..5dfa468d18d --- /dev/null +++ b/media/libcubeb/tests/test_audio.cpp @@ -0,0 +1,174 @@ +/* + * Copyright © 2013 Sebastien Alaiwan + * + * This program is made available under an ISC-style license. See the + * accompanying file LICENSE for details. + */ + +/* libcubeb api/function exhaustive test. Plays a series of tones in different + * conditions. */ +#ifdef NDEBUG +#undef NDEBUG +#endif +#define _XOPEN_SOURCE 500 +#include +#include +#include +#include + +#include "cubeb/cubeb.h" +#include "common.h" + +#define MAX_NUM_CHANNELS 32 + +#if !defined(M_PI) +#define M_PI 3.14159265358979323846 +#endif + +#define NELEMS(x) ((int) (sizeof(x) / sizeof(x[0]))) +#define VOLUME 0.2 + +float get_frequency(int channel_index) +{ + return 220.0f * (channel_index+1); +} + +/* store the phase of the generated waveform */ +typedef struct { + int num_channels; + float phase[MAX_NUM_CHANNELS]; + float sample_rate; +} synth_state; + +synth_state* synth_create(int num_channels, float sample_rate) +{ + synth_state* synth = (synth_state *) malloc(sizeof(synth_state)); + for(int i=0;i < MAX_NUM_CHANNELS;++i) + synth->phase[i] = 0.0f; + synth->num_channels = num_channels; + synth->sample_rate = sample_rate; + return synth; +} + +void synth_destroy(synth_state* synth) +{ + free(synth); +} + +void synth_run_float(synth_state* synth, float* audiobuffer, long nframes) +{ + for(int c=0;c < synth->num_channels;++c) { + float freq = get_frequency(c); + float phase_inc = 2.0 * M_PI * freq / synth->sample_rate; + for(long n=0;n < nframes;++n) { + audiobuffer[n*synth->num_channels+c] = sin(synth->phase[c]) * VOLUME; + synth->phase[c] += phase_inc; + } + } +} + +long data_cb_float(cubeb_stream *stream, void *user, void *buffer, long nframes) +{ + synth_state *synth = (synth_state *)user; + synth_run_float(synth, (float*)buffer, nframes); + return nframes; +} + +void synth_run_16bit(synth_state* synth, short* audiobuffer, long nframes) +{ + for(int c=0;c < synth->num_channels;++c) { + float freq = get_frequency(c); + float phase_inc = 2.0 * M_PI * freq / synth->sample_rate; + for(long n=0;n < nframes;++n) { + audiobuffer[n*synth->num_channels+c] = sin(synth->phase[c]) * VOLUME * 32767.0f; + synth->phase[c] += phase_inc; + } + } +} + +long data_cb_short(cubeb_stream *stream, void *user, void *buffer, long nframes) +{ + synth_state *synth = (synth_state *)user; + synth_run_16bit(synth, (short*)buffer, nframes); + return nframes; +} + +void state_cb(cubeb_stream *stream, void *user, cubeb_state state) +{ +} + +int run_test(int num_channels, int sampling_rate, int is_float) +{ + int ret = CUBEB_OK; + + cubeb *ctx = NULL; + synth_state* synth = NULL; + cubeb_stream *stream = NULL; + + ret = cubeb_init(&ctx, "Cubeb audio test"); + if (ret != CUBEB_OK) { + fprintf(stderr, "Error initializing cubeb library\n"); + goto cleanup; + } + + fprintf(stderr, "Testing %d channel(s), %d Hz, %s (%s)\n", num_channels, sampling_rate, is_float ? "float" : "short", cubeb_get_backend_id(ctx)); + + cubeb_stream_params params; + params.format = is_float ? CUBEB_SAMPLE_FLOAT32NE : CUBEB_SAMPLE_S16NE; + params.rate = sampling_rate; + params.channels = num_channels; + + synth = synth_create(params.channels, params.rate); + if (synth == NULL) { + fprintf(stderr, "Out of memory\n"); + goto cleanup; + } + + ret = cubeb_stream_init(ctx, &stream, "test tone", params, + 250, is_float ? data_cb_float : data_cb_short, state_cb, synth); + if (ret != CUBEB_OK) { + fprintf(stderr, "Error initializing cubeb stream: %d\n", ret); + goto cleanup; + } + + cubeb_stream_start(stream); + delay(200); + cubeb_stream_stop(stream); + +cleanup: + cubeb_stream_destroy(stream); + cubeb_destroy(ctx); + synth_destroy(synth); + + return ret; +} + +int main(int argc, char *argv[]) +{ + int channel_values[] = { + 1, + 2, + 4, + 5, + 6, + }; + + int freq_values[] = { + 24000, + 44100, + 48000, + }; + + for(int j=0;j < NELEMS(channel_values);++j) { + for(int i=0;i < NELEMS(freq_values);++i) { + assert(channel_values[j] < MAX_NUM_CHANNELS); + fprintf(stderr, "--------------------------\n"); + run_test(channel_values[j], freq_values[i], 0); + run_test(channel_values[j], freq_values[i], 1); + } + } + + return CUBEB_OK; +} + + diff --git a/media/libcubeb/tests/test_latency.cpp b/media/libcubeb/tests/test_latency.cpp new file mode 100644 index 00000000000..eb145f64640 --- /dev/null +++ b/media/libcubeb/tests/test_latency.cpp @@ -0,0 +1,39 @@ +#ifdef NDEBUG +#undef NDEBUG +#endif +#include +#include +#include + +int main(int argc, char * argv[]) +{ + cubeb * ctx = NULL; + int rv; + uint32_t max_channels; + uint32_t preferred_rate; + uint32_t latency_ms; + + rv = cubeb_init(&ctx, "Cubeb audio test"); + assert(rv == CUBEB_OK && "Cubeb init failed."); + + rv = cubeb_get_max_channel_count(ctx, &max_channels); + assert(rv == CUBEB_OK && "Could not query the max channe count."); + assert(max_channels > 0 && "Invalid max channel count."); + + rv = cubeb_get_preferred_sample_rate(ctx, &preferred_rate); + assert(rv == CUBEB_OK && "Could not query the preferred sample rate."); + assert(preferred_rate && "Invalid preferred sample rate."); + + cubeb_stream_params params = { + CUBEB_SAMPLE_FLOAT32NE, + preferred_rate, + max_channels + }; + rv = cubeb_get_min_latency(ctx, params, &latency_ms); + assert(rv == CUBEB_OK && "Could not query the minimal latency."); + assert(latency_ms && "Invalid minimal latency."); + + cubeb_destroy(ctx); + + return EXIT_SUCCESS; +} diff --git a/media/libcubeb/tests/test_sanity.cpp b/media/libcubeb/tests/test_sanity.cpp new file mode 100644 index 00000000000..ed83d37be0e --- /dev/null +++ b/media/libcubeb/tests/test_sanity.cpp @@ -0,0 +1,466 @@ +/* + * Copyright © 2011 Mozilla Foundation + * + * This program is made available under an ISC-style license. See the + * accompanying file LICENSE for details. + */ +#ifdef NDEBUG +#undef NDEBUG +#endif +#define _XOPEN_SOURCE 500 +#include "cubeb/cubeb.h" +#include +#include +#include +#include +#include "common.h" + +#define STREAM_LATENCY 100 +#define STREAM_RATE 44100 +#define STREAM_CHANNELS 1 +#define STREAM_FORMAT CUBEB_SAMPLE_S16LE + +static int dummy; +static uint64_t total_frames_written; +static int delay_callback; + +static long +test_data_callback(cubeb_stream * stm, void * user_ptr, void * p, long nframes) +{ + assert(stm && user_ptr == &dummy && p && nframes > 0); + memset(p, 0, nframes * sizeof(short)); + total_frames_written += nframes; + if (delay_callback) { + delay(10); + } + return nframes; +} + +void +test_state_callback(cubeb_stream * stm, void * user_ptr, cubeb_state state) +{ +} + +static void +test_init_destroy_context(void) +{ + int r; + cubeb * ctx; + + r = cubeb_init(&ctx, "test_sanity"); + assert(r == 0 && ctx); + + cubeb_destroy(ctx); +} + +static void +test_init_destroy_multiple_contexts(void) +{ + int i; + int r; + cubeb * ctx[4]; + + for (i = 0; i < 4; ++i) { + r = cubeb_init(&ctx[i], NULL); + assert(r == 0 && ctx[i]); + } + + /* destroy in a different order */ + cubeb_destroy(ctx[2]); + cubeb_destroy(ctx[0]); + cubeb_destroy(ctx[3]); + cubeb_destroy(ctx[1]); +} + +static void +test_init_destroy_stream(void) +{ + int r; + cubeb * ctx; + cubeb_stream * stream; + cubeb_stream_params params; + + r = cubeb_init(&ctx, "test_sanity"); + assert(r == 0 && ctx); + + params.format = STREAM_FORMAT; + params.rate = STREAM_RATE; + params.channels = STREAM_CHANNELS; + + r = cubeb_stream_init(ctx, &stream, "test", params, STREAM_LATENCY, + test_data_callback, test_state_callback, &dummy); + assert(r == 0 && stream); + + cubeb_stream_destroy(stream); + cubeb_destroy(ctx); +} + +static void +test_init_destroy_multiple_streams(void) +{ + int i; + int r; + cubeb * ctx; + cubeb_stream * stream[16]; + cubeb_stream_params params; + + r = cubeb_init(&ctx, "test_sanity"); + assert(r == 0 && ctx); + + params.format = STREAM_FORMAT; + params.rate = STREAM_RATE; + params.channels = STREAM_CHANNELS; + + for (i = 0; i < 16; ++i) { + r = cubeb_stream_init(ctx, &stream[i], "test", params, STREAM_LATENCY, + test_data_callback, test_state_callback, &dummy); + assert(r == 0 && stream[i]); + } + + for (i = 0; i < 16; ++i) { + cubeb_stream_destroy(stream[i]); + } + + cubeb_destroy(ctx); +} + +static void +test_init_start_stop_destroy_multiple_streams(int early, int delay_ms) +{ + int i; + int r; + cubeb * ctx; + cubeb_stream * stream[16]; + cubeb_stream_params params; + + r = cubeb_init(&ctx, "test_sanity"); + assert(r == 0 && ctx); + + params.format = STREAM_FORMAT; + params.rate = STREAM_RATE; + params.channels = STREAM_CHANNELS; + + for (i = 0; i < 16; ++i) { + r = cubeb_stream_init(ctx, &stream[i], "test", params, STREAM_LATENCY, + test_data_callback, test_state_callback, &dummy); + assert(r == 0 && stream[i]); + if (early) { + r = cubeb_stream_start(stream[i]); + assert(r == 0); + } + } + + + if (!early) { + for (i = 0; i < 16; ++i) { + r = cubeb_stream_start(stream[i]); + assert(r == 0); + } + } + + if (delay_ms) { + delay(delay_ms); + } + + if (!early) { + for (i = 0; i < 16; ++i) { + r = cubeb_stream_stop(stream[i]); + assert(r == 0); + } + } + + for (i = 0; i < 16; ++i) { + if (early) { + r = cubeb_stream_stop(stream[i]); + assert(r == 0); + } + cubeb_stream_destroy(stream[i]); + } + + cubeb_destroy(ctx); +} + +static void +test_init_destroy_multiple_contexts_and_streams(void) +{ + int i, j; + int r; + cubeb * ctx[4]; + cubeb_stream * stream[16]; + cubeb_stream_params params; + + params.format = STREAM_FORMAT; + params.rate = STREAM_RATE; + params.channels = STREAM_CHANNELS; + + for (i = 0; i < 4; ++i) { + r = cubeb_init(&ctx[i], "test_sanity"); + assert(r == 0 && ctx[i]); + + for (j = 0; j < 4; ++j) { + r = cubeb_stream_init(ctx[i], &stream[i * 4 + j], "test", params, STREAM_LATENCY, + test_data_callback, test_state_callback, &dummy); + assert(r == 0 && stream[i * 4 + j]); + } + } + + for (i = 0; i < 4; ++i) { + for (j = 0; j < 4; ++j) { + cubeb_stream_destroy(stream[i * 4 + j]); + } + cubeb_destroy(ctx[i]); + } +} + +static void +test_basic_stream_operations(void) +{ + int r; + cubeb * ctx; + cubeb_stream * stream; + cubeb_stream_params params; + uint64_t position; + + r = cubeb_init(&ctx, "test_sanity"); + assert(r == 0 && ctx); + + params.format = STREAM_FORMAT; + params.rate = STREAM_RATE; + params.channels = STREAM_CHANNELS; + + r = cubeb_stream_init(ctx, &stream, "test", params, STREAM_LATENCY, + test_data_callback, test_state_callback, &dummy); + assert(r == 0 && stream); + + /* position and volume before stream has started */ + r = cubeb_stream_get_position(stream, &position); + assert(r == 0 && position == 0); + + r = cubeb_stream_start(stream); + assert(r == 0); + + /* position and volume after while stream running */ + r = cubeb_stream_get_position(stream, &position); + assert(r == 0); + + r = cubeb_stream_stop(stream); + assert(r == 0); + + /* position and volume after stream has stopped */ + r = cubeb_stream_get_position(stream, &position); + assert(r == 0); + + cubeb_stream_destroy(stream); + cubeb_destroy(ctx); +} + +static void +test_stream_position(void) +{ + int i; + int r; + cubeb * ctx; + cubeb_stream * stream; + cubeb_stream_params params; + uint64_t position, last_position; + + total_frames_written = 0; + + r = cubeb_init(&ctx, "test_sanity"); + assert(r == 0 && ctx); + + params.format = STREAM_FORMAT; + params.rate = STREAM_RATE; + params.channels = STREAM_CHANNELS; + + r = cubeb_stream_init(ctx, &stream, "test", params, STREAM_LATENCY, + test_data_callback, test_state_callback, &dummy); + assert(r == 0 && stream); + + /* stream position should not advance before starting playback */ + r = cubeb_stream_get_position(stream, &position); + assert(r == 0 && position == 0); + + delay(500); + + r = cubeb_stream_get_position(stream, &position); + assert(r == 0 && position == 0); + + /* stream position should advance during playback */ + r = cubeb_stream_start(stream); + assert(r == 0); + + /* XXX let start happen */ + delay(500); + + /* stream should have prefilled */ + assert(total_frames_written > 0); + + r = cubeb_stream_get_position(stream, &position); + assert(r == 0); + last_position = position; + + delay(500); + + r = cubeb_stream_get_position(stream, &position); + assert(r == 0); + assert(position >= last_position); + last_position = position; + + /* stream position should not exceed total frames written */ + for (i = 0; i < 5; ++i) { + r = cubeb_stream_get_position(stream, &position); + assert(r == 0); + assert(position >= last_position); + assert(position <= total_frames_written); + last_position = position; + delay(500); + } + + assert(last_position != 0); + + /* stream position should not advance after stopping playback */ + r = cubeb_stream_stop(stream); + assert(r == 0); + + /* XXX allow stream to settle */ + delay(500); + + r = cubeb_stream_get_position(stream, &position); + assert(r == 0); + last_position = position; + + delay(500); + + r = cubeb_stream_get_position(stream, &position); + assert(r == 0); + assert(position == last_position); + + cubeb_stream_destroy(stream); + cubeb_destroy(ctx); +} + +static int do_drain; +static int got_drain; + +static long +test_drain_data_callback(cubeb_stream * stm, void * user_ptr, void * p, long nframes) +{ + assert(stm && user_ptr == &dummy && p && nframes > 0); + if (do_drain == 1) { + do_drain = 2; + return 0; + } + /* once drain has started, callback must never be called again */ + assert(do_drain != 2); + memset(p, 0, nframes * sizeof(short)); + total_frames_written += nframes; + return nframes; +} + +void +test_drain_state_callback(cubeb_stream * stm, void * user_ptr, cubeb_state state) +{ + if (state == CUBEB_STATE_DRAINED) { + assert(!got_drain); + got_drain = 1; + } +} + +static void +test_drain(void) +{ + int r; + cubeb * ctx; + cubeb_stream * stream; + cubeb_stream_params params; + uint64_t position; + + total_frames_written = 0; + + r = cubeb_init(&ctx, "test_sanity"); + assert(r == 0 && ctx); + + params.format = STREAM_FORMAT; + params.rate = STREAM_RATE; + params.channels = STREAM_CHANNELS; + + r = cubeb_stream_init(ctx, &stream, "test", params, STREAM_LATENCY, + test_drain_data_callback, test_drain_state_callback, &dummy); + assert(r == 0 && stream); + + r = cubeb_stream_start(stream); + assert(r == 0); + + delay(500); + + do_drain = 1; + + for (;;) { + r = cubeb_stream_get_position(stream, &position); + assert(r == 0); + if (got_drain) { + break; + } else { + // Latency passed to cubeb_stream_init is not really honored on OSX and + // winmm, skip this test. + const char * backend_id = cubeb_get_backend_id(ctx); + if (strcmp(backend_id, "audiounit") != 0 && + strcmp(backend_id, "winmm") != 0) { + /* Position should roughly be equal to the number of written frames. We + * need to take the latency into account. */ + int latency = (STREAM_LATENCY * STREAM_RATE) / 1000; + assert(position + latency <= total_frames_written); + } + } + delay(500); + } + + r = cubeb_stream_get_position(stream, &position); + assert(r == 0); + assert(got_drain); + + // Disabled due to failures in the ALSA backend. + //assert(position == total_frames_written); + + cubeb_stream_destroy(stream); + cubeb_destroy(ctx); +} + +static void +progress(void) +{ + printf("."); + fflush(stdout); +} + +int +main(int argc, char * argv[]) +{ + test_init_destroy_context(); progress(); + test_init_destroy_multiple_contexts(); progress(); + test_init_destroy_stream(); progress(); + test_init_destroy_multiple_streams(); progress(); + test_init_destroy_multiple_contexts_and_streams(); progress(); + test_basic_stream_operations(); progress(); + test_stream_position(); progress(); + delay_callback = 0; + test_init_start_stop_destroy_multiple_streams(0, 0); progress(); + test_init_start_stop_destroy_multiple_streams(1, 0); progress(); + test_init_start_stop_destroy_multiple_streams(0, 150); progress(); + test_init_start_stop_destroy_multiple_streams(1, 150); progress(); + delay_callback = 1; + test_init_start_stop_destroy_multiple_streams(0, 0); progress(); + test_init_start_stop_destroy_multiple_streams(1, 0); progress(); + test_init_start_stop_destroy_multiple_streams(0, 150); progress(); + test_init_start_stop_destroy_multiple_streams(1, 150); progress(); + delay_callback = 0; + test_drain(); +/* + to implement: + test_eos_during_prefill(); + test_stream_destroy_pending_drain(); +*/ + printf("\n"); + return 0; +} diff --git a/media/libcubeb/tests/test_tone.cpp b/media/libcubeb/tests/test_tone.cpp new file mode 100644 index 00000000000..c3e6cc75fac --- /dev/null +++ b/media/libcubeb/tests/test_tone.cpp @@ -0,0 +1,117 @@ +/* + * Copyright © 2011 Mozilla Foundation + * + * This program is made available under an ISC-style license. See the + * accompanying file LICENSE for details. + */ + +/* libcubeb api/function test. Plays a simple tone. */ +#ifdef NDEBUG +#undef NDEBUG +#endif +#define _XOPEN_SOURCE 500 +#include +#include +#include +#include + +#include "cubeb/cubeb.h" +#include "common.h" + +#define SAMPLE_FREQUENCY 48000 + +/* store the phase of the generated waveform */ +struct cb_user_data { + long position; +}; + +long data_cb(cubeb_stream *stream, void *user, void *buffer, long nframes) +{ + struct cb_user_data *u = (struct cb_user_data *)user; + short *b = (short *)buffer; + int i; + + if (stream == NULL || u == NULL) + return CUBEB_ERROR; + + /* generate our test tone on the fly */ + for (i = 0; i < nframes; i++) { + /* North American dial tone */ + b[i] = 16000*sin(2*M_PI*(i + u->position)*350/SAMPLE_FREQUENCY); + b[i] += 16000*sin(2*M_PI*(i + u->position)*440/SAMPLE_FREQUENCY); + /* European dial tone */ + /*b[i] = 30000*sin(2*M_PI*(i + u->position)*425/SAMPLE_FREQUENCY);*/ + } + /* remember our phase to avoid clicking on buffer transitions */ + /* we'll still click if position overflows */ + u->position += nframes; + + return nframes; +} + +void state_cb(cubeb_stream *stream, void *user, cubeb_state state) +{ + struct cb_user_data *u = (struct cb_user_data *)user; + + if (stream == NULL || u == NULL) + return; + + switch (state) { + case CUBEB_STATE_STARTED: + printf("stream started\n"); break; + case CUBEB_STATE_STOPPED: + printf("stream stopped\n"); break; + case CUBEB_STATE_DRAINED: + printf("stream drained\n"); break; + default: + printf("unknown stream state %d\n", state); + } + + return; +} + +int main(int argc, char *argv[]) +{ + cubeb *ctx; + cubeb_stream *stream; + cubeb_stream_params params; + struct cb_user_data *user_data; + int ret; + + ret = cubeb_init(&ctx, "Cubeb tone example"); + if (ret != CUBEB_OK) { + fprintf(stderr, "Error initializing cubeb library\n"); + return ret; + } + + params.format = CUBEB_SAMPLE_S16NE; + params.rate = SAMPLE_FREQUENCY; + params.channels = 1; + + user_data = (struct cb_user_data *) malloc(sizeof(*user_data)); + if (user_data == NULL) { + fprintf(stderr, "Error allocating user data\n"); + return CUBEB_ERROR; + } + user_data->position = 0; + + ret = cubeb_stream_init(ctx, &stream, "Cubeb tone (mono)", params, + 250, data_cb, state_cb, user_data); + if (ret != CUBEB_OK) { + fprintf(stderr, "Error initializing cubeb stream\n"); + return ret; + } + + cubeb_stream_start(stream); + delay(500); + cubeb_stream_stop(stream); + + cubeb_stream_destroy(stream); + cubeb_destroy(ctx); + + assert(user_data->position); + + free(user_data); + + return CUBEB_OK; +} From 7e51f55960ef7d4c1125fd321231a98655ad06d6 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Tue, 4 Mar 2014 09:26:06 +0000 Subject: [PATCH 06/62] bug 969814 - build freetype with support for color bitmap (png) glyphs within opentype fonts. r=ted,jrmuizel --- configure.in | 6 ++++-- media/libpng/mozpngconf.h | 27 ++++++++++++++++-------- widget/gonk/libdisplay/BootAnimation.cpp | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/configure.in b/configure.in index 1e8fb551ea9..a515d34e8ea 100644 --- a/configure.in +++ b/configure.in @@ -952,7 +952,7 @@ MOZ_JPEG_CFLAGS= MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)' MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)' -MOZ_PNG_CFLAGS= +MOZ_PNG_CFLAGS="-I$_objdir/dist/include" # needed for freetype compilation MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)' MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)' @@ -8927,8 +8927,10 @@ if test "$MOZ_TREE_FREETYPE"; then export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS" export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS" export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS" + export LIBPNG_CFLAGS="$MOZ_PNG_CFLAGS" + export LIBPNG_LDFLAGS="$MOZ_PNG_LIBS" export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in" - ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes --without-png" + ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes" if ! test -e modules; then mkdir modules diff --git a/media/libpng/mozpngconf.h b/media/libpng/mozpngconf.h index 0b5c7420ab3..101c9ef247d 100644 --- a/media/libpng/mozpngconf.h +++ b/media/libpng/mozpngconf.h @@ -66,19 +66,25 @@ #define PNG_READ_SCALE_16_TO_8_SUPPORTED #define PNG_READ_TRANSFORMS_SUPPORTED -/* necessary for boot animation code */ +/* necessary for freetype color bitmap support (Android & B2G) + and boot animation code (Gonk) */ +#if defined(ANDROID) || defined(FT_CONFIG_OPTION_USE_PNG) +#define PNG_READ_PACK_SUPPORTED +#define PNG_READ_FILLER_SUPPORTED +#define PNG_READ_STRIP_16_TO_8_SUPPORTED +#define PNG_READ_USER_TRANSFORM_SUPPORTED +#define PNG_SEQUENTIAL_READ_SUPPORTED +#endif + +/* necessary for boot animation code (Gonk) */ #ifdef MOZ_WIDGET_GONK #define PNG_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED #define PNG_EASY_ACCESS_SUPPORTED #define PNG_READ_BGR_SUPPORTED -#define PNG_READ_FILLER_SUPPORTED #define PNG_READ_GRAY_TO_RGB_SUPPORTED -#define PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_STRIP_ALPHA_SUPPORTED -#define PNG_READ_USER_TRANSFORM_SUPPORTED -#define PNG_SEQUENTIAL_READ_SUPPORTED #endif #define PNG_WRITE_SUPPORTED @@ -109,11 +115,8 @@ #define PNG_SETJMP_SUPPORTED #define PNG_STDIO_SUPPORTED #define PNG_TEXT_SUPPORTED - -#ifdef PR_LOGGING #define PNG_ERROR_TEXT_SUPPORTED #define PNG_WARNINGS_SUPPORTED -#endif /* Mangle names of exported libpng functions so different libpng versions can coexist. It is recommended that if you do this, you give your @@ -644,9 +647,11 @@ #define png_realloc_array MOZ_PNG_realloc_array #define png_zstream_error MOZ_PNG_zstream_error +/* needed by FreeType's PNG support */ +#define png_error MOZ_PNG_error + #if defined(PR_LOGGING) && defined(PNG_WARNINGS_SUPPORTED) #define png_warning MOZ_PNG_warning -#define png_error MOZ_PNG_error #define png_chunk_error MOZ_PNG_chunk_err #define png_fixed_error MOZ_PNG_fixed_err #define png_formatted_warning MOZ_PNG_formatted_warning @@ -656,4 +661,8 @@ #define png_warning_parameter_unsigned MOZ_PNG_warn_param_unsigned #endif +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +#define png_set_packing MOZ_PNG_set_packing +#endif + #endif /* MOZPNGCONF_H */ diff --git a/widget/gonk/libdisplay/BootAnimation.cpp b/widget/gonk/libdisplay/BootAnimation.cpp index a30175a4bdb..49e47623244 100644 --- a/widget/gonk/libdisplay/BootAnimation.cpp +++ b/widget/gonk/libdisplay/BootAnimation.cpp @@ -267,7 +267,7 @@ RawReader(png_structp png_ptr, png_bytep data, png_size_t length) { RawReadState *state = (RawReadState *)png_get_io_ptr(png_ptr); if (length > (state->length - state->offset)) - png_err(png_ptr); + png_error(png_ptr, "PNG read overrun"); memcpy(data, state->start + state->offset, length); state->offset += length; From 809027efa03596168b65837303af617a7c5bcbcb Mon Sep 17 00:00:00 2001 From: Georg Fritzsche Date: Mon, 3 Mar 2014 17:10:51 +0100 Subject: [PATCH 07/62] Bug 978045 - Move plugin tests in browser/base/content/tests/general to browser/base/content/tests/plugins. r=jaws --HG-- rename : browser/base/content/test/general/blockNoPlugins.xml => browser/base/content/test/plugins/blockNoPlugins.xml rename : browser/base/content/test/general/blockPluginHard.xml => browser/base/content/test/plugins/blockPluginHard.xml rename : browser/base/content/test/general/blockPluginVulnerableNoUpdate.xml => browser/base/content/test/plugins/blockPluginVulnerableNoUpdate.xml rename : browser/base/content/test/general/blockPluginVulnerableUpdatable.xml => browser/base/content/test/plugins/blockPluginVulnerableUpdatable.xml rename : browser/base/content/test/general/browser_CTP_context_menu.js => browser/base/content/test/plugins/browser_CTP_context_menu.js rename : browser/base/content/test/general/browser_CTP_crashreporting.js => browser/base/content/test/plugins/browser_CTP_crashreporting.js rename : browser/base/content/test/general/browser_CTP_data_urls.js => browser/base/content/test/plugins/browser_CTP_data_urls.js rename : browser/base/content/test/general/browser_CTP_drag_drop.js => browser/base/content/test/plugins/browser_CTP_drag_drop.js rename : browser/base/content/test/general/browser_CTP_hide_overlay.js => browser/base/content/test/plugins/browser_CTP_hide_overlay.js rename : browser/base/content/test/general/browser_CTP_multi_allow.js => browser/base/content/test/plugins/browser_CTP_multi_allow.js rename : browser/base/content/test/general/browser_CTP_nonplugins.js => browser/base/content/test/plugins/browser_CTP_nonplugins.js rename : browser/base/content/test/general/browser_CTP_notificationBar.js => browser/base/content/test/plugins/browser_CTP_notificationBar.js rename : browser/base/content/test/general/browser_CTP_outsideScrollArea.js => browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js rename : browser/base/content/test/general/browser_CTP_resize.js => browser/base/content/test/plugins/browser_CTP_resize.js rename : browser/base/content/test/general/browser_bug743421.js => browser/base/content/test/plugins/browser_bug743421.js rename : browser/base/content/test/general/browser_bug744745.js => browser/base/content/test/plugins/browser_bug744745.js rename : browser/base/content/test/general/browser_bug752516.js => browser/base/content/test/plugins/browser_bug752516.js rename : browser/base/content/test/general/browser_bug787619.js => browser/base/content/test/plugins/browser_bug787619.js rename : browser/base/content/test/general/browser_bug797677.js => browser/base/content/test/plugins/browser_bug797677.js rename : browser/base/content/test/general/browser_bug812562.js => browser/base/content/test/plugins/browser_bug812562.js rename : browser/base/content/test/general/browser_bug818118.js => browser/base/content/test/plugins/browser_bug818118.js rename : browser/base/content/test/general/browser_bug820497.js => browser/base/content/test/plugins/browser_bug820497.js rename : browser/base/content/test/general/browser_clearplugindata.html => browser/base/content/test/plugins/browser_clearplugindata.html rename : browser/base/content/test/general/browser_clearplugindata.js => browser/base/content/test/plugins/browser_clearplugindata.js rename : browser/base/content/test/general/browser_clearplugindata_noage.html => browser/base/content/test/plugins/browser_clearplugindata_noage.html rename : browser/base/content/test/general/browser_pageInfo_plugins.js => browser/base/content/test/plugins/browser_pageInfo_plugins.js rename : browser/base/content/test/general/browser_pluginCrashCommentAndURL.js => browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js rename : browser/base/content/test/general/browser_pluginnotification.js => browser/base/content/test/plugins/browser_pluginnotification.js rename : browser/base/content/test/general/browser_pluginplaypreview.js => browser/base/content/test/plugins/browser_pluginplaypreview.js rename : browser/base/content/test/general/browser_pluginplaypreview2.js => browser/base/content/test/plugins/browser_pluginplaypreview2.js rename : browser/base/content/test/general/browser_plugins_added_dynamically.js => browser/base/content/test/plugins/browser_plugins_added_dynamically.js rename : browser/base/content/test/general/plugin_add_dynamically.html => browser/base/content/test/plugins/plugin_add_dynamically.html rename : browser/base/content/test/general/plugin_alternate_content.html => browser/base/content/test/plugins/plugin_alternate_content.html rename : browser/base/content/test/general/plugin_big.html => browser/base/content/test/plugins/plugin_big.html rename : browser/base/content/test/general/plugin_both.html => browser/base/content/test/plugins/plugin_both.html rename : browser/base/content/test/general/plugin_both2.html => browser/base/content/test/plugins/plugin_both2.html rename : browser/base/content/test/general/plugin_bug744745.html => browser/base/content/test/plugins/plugin_bug744745.html rename : browser/base/content/test/general/plugin_bug749455.html => browser/base/content/test/plugins/plugin_bug749455.html rename : browser/base/content/test/general/plugin_bug752516.html => browser/base/content/test/plugins/plugin_bug752516.html rename : browser/base/content/test/general/plugin_bug787619.html => browser/base/content/test/plugins/plugin_bug787619.html rename : browser/base/content/test/general/plugin_bug797677.html => browser/base/content/test/plugins/plugin_bug797677.html rename : browser/base/content/test/general/plugin_bug820497.html => browser/base/content/test/plugins/plugin_bug820497.html rename : browser/base/content/test/general/plugin_clickToPlayAllow.html => browser/base/content/test/plugins/plugin_clickToPlayAllow.html rename : browser/base/content/test/general/plugin_clickToPlayDeny.html => browser/base/content/test/plugins/plugin_clickToPlayDeny.html rename : browser/base/content/test/general/pluginCrashCommentAndURL.html => browser/base/content/test/plugins/plugin_crashCommentAndURL.html rename : browser/base/content/test/general/plugin_data_url.html => browser/base/content/test/plugins/plugin_data_url.html rename : browser/base/content/test/general/plugin_hidden_to_visible.html => browser/base/content/test/plugins/plugin_hidden_to_visible.html rename : browser/base/content/test/general/plugin_outsideScrollArea.html => browser/base/content/test/plugins/plugin_outsideScrollArea.html rename : browser/base/content/test/general/plugin_overlayed.html => browser/base/content/test/plugins/plugin_overlayed.html rename : browser/base/content/test/general/plugin_positioned.html => browser/base/content/test/plugins/plugin_positioned.html rename : browser/base/content/test/general/plugin_small.html => browser/base/content/test/plugins/plugin_small.html rename : browser/base/content/test/general/plugin_syncRemoved.html => browser/base/content/test/plugins/plugin_syncRemoved.html rename : browser/base/content/test/general/plugin_test.html => browser/base/content/test/plugins/plugin_test.html rename : browser/base/content/test/general/plugin_test2.html => browser/base/content/test/plugins/plugin_test2.html rename : browser/base/content/test/general/plugin_test3.html => browser/base/content/test/plugins/plugin_test3.html rename : browser/base/content/test/general/plugin_two_types.html => browser/base/content/test/plugins/plugin_two_types.html rename : browser/base/content/test/general/plugin_unknown.html => browser/base/content/test/plugins/plugin_unknown.html --- browser/base/content/test/general/browser.ini | 60 ---------- .../{general => plugins}/blockNoPlugins.xml | 0 .../{general => plugins}/blockPluginHard.xml | 0 .../blockPluginVulnerableNoUpdate.xml | 0 .../blockPluginVulnerableUpdatable.xml | 0 browser/base/content/test/plugins/browser.ini | 64 ++++++++++ .../browser_CTP_context_menu.js | 0 .../browser_CTP_crashreporting.js | 0 .../browser_CTP_data_urls.js | 0 .../browser_CTP_drag_drop.js | 0 .../browser_CTP_hide_overlay.js | 0 .../browser_CTP_multi_allow.js | 0 .../browser_CTP_nonplugins.js | 0 .../browser_CTP_notificationBar.js | 0 .../browser_CTP_outsideScrollArea.js | 0 .../browser_CTP_resize.js | 0 .../{general => plugins}/browser_bug743421.js | 3 +- .../{general => plugins}/browser_bug744745.js | 0 .../{general => plugins}/browser_bug752516.js | 0 .../{general => plugins}/browser_bug787619.js | 0 .../{general => plugins}/browser_bug797677.js | 0 .../{general => plugins}/browser_bug812562.js | 0 .../{general => plugins}/browser_bug818118.js | 0 .../{general => plugins}/browser_bug820497.js | 0 .../browser_clearplugindata.html | 0 .../browser_clearplugindata.js | 7 +- .../browser_clearplugindata_noage.html | 0 .../browser_pageInfo_plugins.js | 0 .../browser_pluginCrashCommentAndURL.js | 2 +- .../browser_pluginnotification.js | 0 .../browser_pluginplaypreview.js | 0 .../browser_pluginplaypreview2.js | 0 .../browser_plugins_added_dynamically.js | 3 +- browser/base/content/test/plugins/head.js | 110 ++++++++++++++++++ .../plugin_add_dynamically.html | 0 .../plugin_alternate_content.html | 0 .../test/{general => plugins}/plugin_big.html | 0 .../{general => plugins}/plugin_both.html | 0 .../{general => plugins}/plugin_both2.html | 0 .../plugin_bug744745.html | 0 .../plugin_bug749455.html | 0 .../plugin_bug752516.html | 0 .../plugin_bug787619.html | 0 .../plugin_bug797677.html | 0 .../plugin_bug820497.html | 0 .../plugin_clickToPlayAllow.html | 0 .../plugin_clickToPlayDeny.html | 0 .../plugin_crashCommentAndURL.html} | 0 .../{general => plugins}/plugin_data_url.html | 0 .../plugin_hidden_to_visible.html | 0 .../plugin_outsideScrollArea.html | 0 .../plugin_overlayed.html | 0 .../plugin_positioned.html | 0 .../{general => plugins}/plugin_small.html | 0 .../plugin_syncRemoved.html | 0 .../{general => plugins}/plugin_test.html | 0 .../{general => plugins}/plugin_test2.html | 0 .../{general => plugins}/plugin_test3.html | 0 .../plugin_two_types.html | 0 .../{general => plugins}/plugin_unknown.html | 0 browser/base/content/test/social/head.js | 2 +- browser/base/moz.build | 1 + 62 files changed, 186 insertions(+), 66 deletions(-) rename browser/base/content/test/{general => plugins}/blockNoPlugins.xml (100%) rename browser/base/content/test/{general => plugins}/blockPluginHard.xml (100%) rename browser/base/content/test/{general => plugins}/blockPluginVulnerableNoUpdate.xml (100%) rename browser/base/content/test/{general => plugins}/blockPluginVulnerableUpdatable.xml (100%) create mode 100644 browser/base/content/test/plugins/browser.ini rename browser/base/content/test/{general => plugins}/browser_CTP_context_menu.js (100%) rename browser/base/content/test/{general => plugins}/browser_CTP_crashreporting.js (100%) rename browser/base/content/test/{general => plugins}/browser_CTP_data_urls.js (100%) rename browser/base/content/test/{general => plugins}/browser_CTP_drag_drop.js (100%) rename browser/base/content/test/{general => plugins}/browser_CTP_hide_overlay.js (100%) rename browser/base/content/test/{general => plugins}/browser_CTP_multi_allow.js (100%) rename browser/base/content/test/{general => plugins}/browser_CTP_nonplugins.js (100%) rename browser/base/content/test/{general => plugins}/browser_CTP_notificationBar.js (100%) rename browser/base/content/test/{general => plugins}/browser_CTP_outsideScrollArea.js (100%) rename browser/base/content/test/{general => plugins}/browser_CTP_resize.js (100%) rename browser/base/content/test/{general => plugins}/browser_bug743421.js (97%) rename browser/base/content/test/{general => plugins}/browser_bug744745.js (100%) rename browser/base/content/test/{general => plugins}/browser_bug752516.js (100%) rename browser/base/content/test/{general => plugins}/browser_bug787619.js (100%) rename browser/base/content/test/{general => plugins}/browser_bug797677.js (100%) rename browser/base/content/test/{general => plugins}/browser_bug812562.js (100%) rename browser/base/content/test/{general => plugins}/browser_bug818118.js (100%) rename browser/base/content/test/{general => plugins}/browser_bug820497.js (100%) rename browser/base/content/test/{general => plugins}/browser_clearplugindata.html (100%) rename browser/base/content/test/{general => plugins}/browser_clearplugindata.js (93%) rename browser/base/content/test/{general => plugins}/browser_clearplugindata_noage.html (100%) rename browser/base/content/test/{general => plugins}/browser_pageInfo_plugins.js (100%) rename browser/base/content/test/{general => plugins}/browser_pluginCrashCommentAndURL.js (99%) rename browser/base/content/test/{general => plugins}/browser_pluginnotification.js (100%) rename browser/base/content/test/{general => plugins}/browser_pluginplaypreview.js (100%) rename browser/base/content/test/{general => plugins}/browser_pluginplaypreview2.js (100%) rename browser/base/content/test/{general => plugins}/browser_plugins_added_dynamically.js (98%) create mode 100644 browser/base/content/test/plugins/head.js rename browser/base/content/test/{general => plugins}/plugin_add_dynamically.html (100%) rename browser/base/content/test/{general => plugins}/plugin_alternate_content.html (100%) rename browser/base/content/test/{general => plugins}/plugin_big.html (100%) rename browser/base/content/test/{general => plugins}/plugin_both.html (100%) rename browser/base/content/test/{general => plugins}/plugin_both2.html (100%) rename browser/base/content/test/{general => plugins}/plugin_bug744745.html (100%) rename browser/base/content/test/{general => plugins}/plugin_bug749455.html (100%) rename browser/base/content/test/{general => plugins}/plugin_bug752516.html (100%) rename browser/base/content/test/{general => plugins}/plugin_bug787619.html (100%) rename browser/base/content/test/{general => plugins}/plugin_bug797677.html (100%) rename browser/base/content/test/{general => plugins}/plugin_bug820497.html (100%) rename browser/base/content/test/{general => plugins}/plugin_clickToPlayAllow.html (100%) rename browser/base/content/test/{general => plugins}/plugin_clickToPlayDeny.html (100%) rename browser/base/content/test/{general/pluginCrashCommentAndURL.html => plugins/plugin_crashCommentAndURL.html} (100%) rename browser/base/content/test/{general => plugins}/plugin_data_url.html (100%) rename browser/base/content/test/{general => plugins}/plugin_hidden_to_visible.html (100%) rename browser/base/content/test/{general => plugins}/plugin_outsideScrollArea.html (100%) rename browser/base/content/test/{general => plugins}/plugin_overlayed.html (100%) rename browser/base/content/test/{general => plugins}/plugin_positioned.html (100%) rename browser/base/content/test/{general => plugins}/plugin_small.html (100%) rename browser/base/content/test/{general => plugins}/plugin_syncRemoved.html (100%) rename browser/base/content/test/{general => plugins}/plugin_test.html (100%) rename browser/base/content/test/{general => plugins}/plugin_test2.html (100%) rename browser/base/content/test/{general => plugins}/plugin_test3.html (100%) rename browser/base/content/test/{general => plugins}/plugin_two_types.html (100%) rename browser/base/content/test/{general => plugins}/plugin_unknown.html (100%) diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index aae3d6c517c..5c7d3c7c9b9 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -6,15 +6,9 @@ support-files = app_bug575561.html app_subframe_bug575561.html authenticate.sjs - blockNoPlugins.xml - blockPluginHard.xml - blockPluginVulnerableNoUpdate.xml - blockPluginVulnerableUpdatable.xml browser_bug479408_sample.html browser_bug678392-1.html browser_bug678392-2.html - browser_clearplugindata.html - browser_clearplugindata_noage.html browser_registerProtocolHandler_notification.html browser_star_hsts.sjs browser_tab_dragdrop2_frame1.xul @@ -65,32 +59,6 @@ support-files = offlineQuotaNotification.cacheManifest offlineQuotaNotification.html page_style_sample.html - plugin_add_dynamically.html - plugin_alternate_content.html - plugin_big.html - plugin_both.html - plugin_both2.html - plugin_bug744745.html - plugin_bug749455.html - plugin_bug752516.html - plugin_bug787619.html - plugin_bug797677.html - plugin_bug820497.html - plugin_clickToPlayAllow.html - plugin_clickToPlayDeny.html - plugin_data_url.html - plugin_hidden_to_visible.html - plugin_outsideScrollArea.html - plugin_overlayed.html - plugin_positioned.html - plugin_small.html - plugin_syncRemoved.html - plugin_test.html - plugin_test2.html - plugin_test3.html - plugin_two_types.html - plugin_unknown.html - pluginCrashCommentAndURL.html print_postdata.sjs redirect_bug623155.sjs test-mixedcontent-securityerrors.html @@ -111,18 +79,6 @@ support-files = test_no_mcb_on_http_site_font2.css xul_tooltiptext.xhtml -[browser_CTP_context_menu.js] -skip-if = toolkit == "gtk2" || toolkit == "gtk3" # browser_CTP_context_menu.js fails intermittently on Linux (bug 909342) -[browser_CTP_crashreporting.js] -run-if = crashreporter -[browser_CTP_data_urls.js] -[browser_CTP_drag_drop.js] -[browser_CTP_hide_overlay.js] -[browser_CTP_multi_allow.js] -[browser_CTP_nonplugins.js] -[browser_CTP_notificationBar.js] -[browser_CTP_outsideScrollArea.js] -[browser_CTP_resize.js] [browser_URLBarSetURI.js] [browser_aboutAccounts.js] skip-if = os == "linux" # Bug 958026 @@ -229,21 +185,13 @@ skip-if = os == "mac" # Intermittent failures, bug 925225 [browser_bug724239.js] [browser_bug734076.js] [browser_bug735471.js] -[browser_bug743421.js] -[browser_bug744745.js] [browser_bug749738.js] -[browser_bug752516.js] [browser_bug763468_perwindowpb.js] [browser_bug767836_perwindowpb.js] [browser_bug771331.js] [browser_bug783614.js] -[browser_bug787619.js] -[browser_bug797677.js] -[browser_bug812562.js] [browser_bug816527.js] [browser_bug817947.js] -[browser_bug818118.js] -[browser_bug820497.js] [browser_bug822367.js] [browser_bug832435.js] [browser_bug839103.js] @@ -252,7 +200,6 @@ skip-if = os == "mac" # Intermittent failures, bug 925225 [browser_bug902156.js] [browser_bug906190.js] [browser_canonizeURL.js] -[browser_clearplugindata.js] [browser_contentAreaClick.js] [browser_contextSearchTabPosition.js] skip-if = os == "mac" # bug 967013, bug 926729 @@ -288,16 +235,9 @@ skip-if = os != "win" # The Fitts Law menu button is only supported on Windows ( [browser_offlineQuotaNotification.js] [browser_overflowScroll.js] [browser_pageInfo.js] -[browser_pageInfo_plugins.js] [browser_page_style_menu.js] [browser_pinnedTabs.js] [browser_plainTextLinks.js] -[browser_pluginnotification.js] -[browser_pluginplaypreview.js] -[browser_pluginplaypreview2.js] -[browser_pluginCrashCommentAndURL.js] -run-if = crashreporter -[browser_plugins_added_dynamically.js] [browser_popupNotification.js] skip-if = toolkit == "windows" # Disabled on Windows due to frequent failures (bugs 825739, 841341) [browser_popupUI.js] diff --git a/browser/base/content/test/general/blockNoPlugins.xml b/browser/base/content/test/plugins/blockNoPlugins.xml similarity index 100% rename from browser/base/content/test/general/blockNoPlugins.xml rename to browser/base/content/test/plugins/blockNoPlugins.xml diff --git a/browser/base/content/test/general/blockPluginHard.xml b/browser/base/content/test/plugins/blockPluginHard.xml similarity index 100% rename from browser/base/content/test/general/blockPluginHard.xml rename to browser/base/content/test/plugins/blockPluginHard.xml diff --git a/browser/base/content/test/general/blockPluginVulnerableNoUpdate.xml b/browser/base/content/test/plugins/blockPluginVulnerableNoUpdate.xml similarity index 100% rename from browser/base/content/test/general/blockPluginVulnerableNoUpdate.xml rename to browser/base/content/test/plugins/blockPluginVulnerableNoUpdate.xml diff --git a/browser/base/content/test/general/blockPluginVulnerableUpdatable.xml b/browser/base/content/test/plugins/blockPluginVulnerableUpdatable.xml similarity index 100% rename from browser/base/content/test/general/blockPluginVulnerableUpdatable.xml rename to browser/base/content/test/plugins/blockPluginVulnerableUpdatable.xml diff --git a/browser/base/content/test/plugins/browser.ini b/browser/base/content/test/plugins/browser.ini new file mode 100644 index 00000000000..3ec41bde80b --- /dev/null +++ b/browser/base/content/test/plugins/browser.ini @@ -0,0 +1,64 @@ +[DEFAULT] +support-files = + blockNoPlugins.xml + blockPluginHard.xml + blockPluginVulnerableNoUpdate.xml + blockPluginVulnerableUpdatable.xml + browser_clearplugindata.html + browser_clearplugindata_noage.html + head.js + plugin_add_dynamically.html + plugin_alternate_content.html + plugin_big.html + plugin_both.html + plugin_both2.html + plugin_bug744745.html + plugin_bug749455.html + plugin_bug752516.html + plugin_bug787619.html + plugin_bug797677.html + plugin_bug820497.html + plugin_clickToPlayAllow.html + plugin_clickToPlayDeny.html + plugin_data_url.html + plugin_hidden_to_visible.html + plugin_outsideScrollArea.html + plugin_overlayed.html + plugin_positioned.html + plugin_small.html + plugin_syncRemoved.html + plugin_test.html + plugin_test2.html + plugin_test3.html + plugin_two_types.html + plugin_unknown.html + plugin_crashCommentAndURL.html + +[browser_bug743421.js] +[browser_bug744745.js] +[browser_bug752516.js] +[browser_bug787619.js] +[browser_bug797677.js] +[browser_bug812562.js] +[browser_bug818118.js] +[browser_bug820497.js] +[browser_clearplugindata.js] +[browser_CTP_context_menu.js] +skip-if = toolkit == "gtk2" || toolkit == "gtk3" # browser_CTP_context_menu.js fails intermittently on Linux (bug 909342) +[browser_CTP_crashreporting.js] +run-if = crashreporter +[browser_CTP_data_urls.js] +[browser_CTP_drag_drop.js] +[browser_CTP_hide_overlay.js] +[browser_CTP_multi_allow.js] +[browser_CTP_nonplugins.js] +[browser_CTP_notificationBar.js] +[browser_CTP_outsideScrollArea.js] +[browser_CTP_resize.js] +[browser_pageInfo_plugins.js] +[browser_pluginnotification.js] +[browser_pluginplaypreview.js] +[browser_pluginplaypreview2.js] +[browser_pluginCrashCommentAndURL.js] +run-if = crashreporter +[browser_plugins_added_dynamically.js] diff --git a/browser/base/content/test/general/browser_CTP_context_menu.js b/browser/base/content/test/plugins/browser_CTP_context_menu.js similarity index 100% rename from browser/base/content/test/general/browser_CTP_context_menu.js rename to browser/base/content/test/plugins/browser_CTP_context_menu.js diff --git a/browser/base/content/test/general/browser_CTP_crashreporting.js b/browser/base/content/test/plugins/browser_CTP_crashreporting.js similarity index 100% rename from browser/base/content/test/general/browser_CTP_crashreporting.js rename to browser/base/content/test/plugins/browser_CTP_crashreporting.js diff --git a/browser/base/content/test/general/browser_CTP_data_urls.js b/browser/base/content/test/plugins/browser_CTP_data_urls.js similarity index 100% rename from browser/base/content/test/general/browser_CTP_data_urls.js rename to browser/base/content/test/plugins/browser_CTP_data_urls.js diff --git a/browser/base/content/test/general/browser_CTP_drag_drop.js b/browser/base/content/test/plugins/browser_CTP_drag_drop.js similarity index 100% rename from browser/base/content/test/general/browser_CTP_drag_drop.js rename to browser/base/content/test/plugins/browser_CTP_drag_drop.js diff --git a/browser/base/content/test/general/browser_CTP_hide_overlay.js b/browser/base/content/test/plugins/browser_CTP_hide_overlay.js similarity index 100% rename from browser/base/content/test/general/browser_CTP_hide_overlay.js rename to browser/base/content/test/plugins/browser_CTP_hide_overlay.js diff --git a/browser/base/content/test/general/browser_CTP_multi_allow.js b/browser/base/content/test/plugins/browser_CTP_multi_allow.js similarity index 100% rename from browser/base/content/test/general/browser_CTP_multi_allow.js rename to browser/base/content/test/plugins/browser_CTP_multi_allow.js diff --git a/browser/base/content/test/general/browser_CTP_nonplugins.js b/browser/base/content/test/plugins/browser_CTP_nonplugins.js similarity index 100% rename from browser/base/content/test/general/browser_CTP_nonplugins.js rename to browser/base/content/test/plugins/browser_CTP_nonplugins.js diff --git a/browser/base/content/test/general/browser_CTP_notificationBar.js b/browser/base/content/test/plugins/browser_CTP_notificationBar.js similarity index 100% rename from browser/base/content/test/general/browser_CTP_notificationBar.js rename to browser/base/content/test/plugins/browser_CTP_notificationBar.js diff --git a/browser/base/content/test/general/browser_CTP_outsideScrollArea.js b/browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js similarity index 100% rename from browser/base/content/test/general/browser_CTP_outsideScrollArea.js rename to browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js diff --git a/browser/base/content/test/general/browser_CTP_resize.js b/browser/base/content/test/plugins/browser_CTP_resize.js similarity index 100% rename from browser/base/content/test/general/browser_CTP_resize.js rename to browser/base/content/test/plugins/browser_CTP_resize.js diff --git a/browser/base/content/test/general/browser_bug743421.js b/browser/base/content/test/plugins/browser_bug743421.js similarity index 97% rename from browser/base/content/test/general/browser_bug743421.js rename to browser/base/content/test/plugins/browser_bug743421.js index 6bfae640537..0df83fe80ff 100644 --- a/browser/base/content/test/general/browser_bug743421.js +++ b/browser/base/content/test/plugins/browser_bug743421.js @@ -1,4 +1,5 @@ -const gTestRoot = "http://mochi.test:8888/browser/browser/base/content/test/general/"; +var rootDir = getRootDirectory(gTestPath); +const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://mochi.test:8888/"); var gTestBrowser = null; var gNextTest = null; diff --git a/browser/base/content/test/general/browser_bug744745.js b/browser/base/content/test/plugins/browser_bug744745.js similarity index 100% rename from browser/base/content/test/general/browser_bug744745.js rename to browser/base/content/test/plugins/browser_bug744745.js diff --git a/browser/base/content/test/general/browser_bug752516.js b/browser/base/content/test/plugins/browser_bug752516.js similarity index 100% rename from browser/base/content/test/general/browser_bug752516.js rename to browser/base/content/test/plugins/browser_bug752516.js diff --git a/browser/base/content/test/general/browser_bug787619.js b/browser/base/content/test/plugins/browser_bug787619.js similarity index 100% rename from browser/base/content/test/general/browser_bug787619.js rename to browser/base/content/test/plugins/browser_bug787619.js diff --git a/browser/base/content/test/general/browser_bug797677.js b/browser/base/content/test/plugins/browser_bug797677.js similarity index 100% rename from browser/base/content/test/general/browser_bug797677.js rename to browser/base/content/test/plugins/browser_bug797677.js diff --git a/browser/base/content/test/general/browser_bug812562.js b/browser/base/content/test/plugins/browser_bug812562.js similarity index 100% rename from browser/base/content/test/general/browser_bug812562.js rename to browser/base/content/test/plugins/browser_bug812562.js diff --git a/browser/base/content/test/general/browser_bug818118.js b/browser/base/content/test/plugins/browser_bug818118.js similarity index 100% rename from browser/base/content/test/general/browser_bug818118.js rename to browser/base/content/test/plugins/browser_bug818118.js diff --git a/browser/base/content/test/general/browser_bug820497.js b/browser/base/content/test/plugins/browser_bug820497.js similarity index 100% rename from browser/base/content/test/general/browser_bug820497.js rename to browser/base/content/test/plugins/browser_bug820497.js diff --git a/browser/base/content/test/general/browser_clearplugindata.html b/browser/base/content/test/plugins/browser_clearplugindata.html similarity index 100% rename from browser/base/content/test/general/browser_clearplugindata.html rename to browser/base/content/test/plugins/browser_clearplugindata.html diff --git a/browser/base/content/test/general/browser_clearplugindata.js b/browser/base/content/test/plugins/browser_clearplugindata.js similarity index 93% rename from browser/base/content/test/general/browser_clearplugindata.js rename to browser/base/content/test/plugins/browser_clearplugindata.js index 6b57150606f..69b601815bd 100644 --- a/browser/base/content/test/general/browser_clearplugindata.js +++ b/browser/base/content/test/plugins/browser_clearplugindata.js @@ -3,9 +3,12 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ +var rootDir = getRootDirectory(gTestPath); +const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://mochi.test:8888/"); + // Test clearing plugin data using sanitize.js. -const testURL1 = "http://mochi.test:8888/browser/browser/base/content/test/general/browser_clearplugindata.html"; -const testURL2 = "http://mochi.test:8888/browser/browser/base/content/test/general/browser_clearplugindata_noage.html"; +const testURL1 = gHttpTestRoot + "browser_clearplugindata.html"; +const testURL2 = gHttpTestRoot + "browser_clearplugindata_noage.html"; let tempScope = {}; Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader) diff --git a/browser/base/content/test/general/browser_clearplugindata_noage.html b/browser/base/content/test/plugins/browser_clearplugindata_noage.html similarity index 100% rename from browser/base/content/test/general/browser_clearplugindata_noage.html rename to browser/base/content/test/plugins/browser_clearplugindata_noage.html diff --git a/browser/base/content/test/general/browser_pageInfo_plugins.js b/browser/base/content/test/plugins/browser_pageInfo_plugins.js similarity index 100% rename from browser/base/content/test/general/browser_pageInfo_plugins.js rename to browser/base/content/test/plugins/browser_pageInfo_plugins.js diff --git a/browser/base/content/test/general/browser_pluginCrashCommentAndURL.js b/browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js similarity index 99% rename from browser/base/content/test/general/browser_pluginCrashCommentAndURL.js rename to browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js index b15cc34351f..493657cb3fd 100644 --- a/browser/base/content/test/general/browser_pluginCrashCommentAndURL.js +++ b/browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js @@ -4,7 +4,7 @@ Cu.import("resource://gre/modules/Services.jsm"); -const CRASH_URL = "http://example.com/browser/browser/base/content/test/general/pluginCrashCommentAndURL.html"; +const CRASH_URL = "http://example.com/browser/browser/base/content/test/plugins/plugin_crashCommentAndURL.html"; const SERVER_URL = "http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs"; diff --git a/browser/base/content/test/general/browser_pluginnotification.js b/browser/base/content/test/plugins/browser_pluginnotification.js similarity index 100% rename from browser/base/content/test/general/browser_pluginnotification.js rename to browser/base/content/test/plugins/browser_pluginnotification.js diff --git a/browser/base/content/test/general/browser_pluginplaypreview.js b/browser/base/content/test/plugins/browser_pluginplaypreview.js similarity index 100% rename from browser/base/content/test/general/browser_pluginplaypreview.js rename to browser/base/content/test/plugins/browser_pluginplaypreview.js diff --git a/browser/base/content/test/general/browser_pluginplaypreview2.js b/browser/base/content/test/plugins/browser_pluginplaypreview2.js similarity index 100% rename from browser/base/content/test/general/browser_pluginplaypreview2.js rename to browser/base/content/test/plugins/browser_pluginplaypreview2.js diff --git a/browser/base/content/test/general/browser_plugins_added_dynamically.js b/browser/base/content/test/plugins/browser_plugins_added_dynamically.js similarity index 98% rename from browser/base/content/test/general/browser_plugins_added_dynamically.js rename to browser/base/content/test/plugins/browser_plugins_added_dynamically.js index 84a056c7f33..20450d60de9 100644 --- a/browser/base/content/test/general/browser_plugins_added_dynamically.js +++ b/browser/base/content/test/plugins/browser_plugins_added_dynamically.js @@ -1,4 +1,5 @@ -const gTestRoot = "http://mochi.test:8888/browser/browser/base/content/test/general/"; +var rootDir = getRootDirectory(gTestPath); +const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://mochi.test:8888/"); let gTestBrowser = null; let gNextTest = null; diff --git a/browser/base/content/test/plugins/head.js b/browser/base/content/test/plugins/head.js new file mode 100644 index 00000000000..43c9ba1db97 --- /dev/null +++ b/browser/base/content/test/plugins/head.js @@ -0,0 +1,110 @@ +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +XPCOMUtils.defineLazyModuleGetter(this, "Promise", + "resource://gre/modules/commonjs/sdk/core/promise.js"); +XPCOMUtils.defineLazyModuleGetter(this, "Task", + "resource://gre/modules/Task.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", + "resource://gre/modules/PlacesUtils.jsm"); + +function whenDelayedStartupFinished(aWindow, aCallback) { + Services.obs.addObserver(function observer(aSubject, aTopic) { + if (aWindow == aSubject) { + Services.obs.removeObserver(observer, aTopic); + executeSoon(aCallback); + } + }, "browser-delayed-startup-finished", false); +} + +function findChromeWindowByURI(aURI) { + let windows = Services.wm.getEnumerator(null); + while (windows.hasMoreElements()) { + let win = windows.getNext(); + if (win.location.href == aURI) + return win; + } + return null; +} + +function waitForCondition(condition, nextTest, errorMsg) { + var tries = 0; + var interval = setInterval(function() { + if (tries >= 30) { + ok(false, errorMsg); + moveOn(); + } + var conditionPassed; + try { + conditionPassed = condition(); + } catch (e) { + ok(false, e + "\n" + e.stack); + conditionPassed = false; + } + if (conditionPassed) { + moveOn(); + } + tries++; + }, 100); + var moveOn = function() { clearInterval(interval); nextTest(); }; +} + +function getTestPlugin(aName) { + var pluginName = aName || "Test Plug-in"; + var ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); + var tags = ph.getPluginTags(); + + // Find the test plugin + for (var i = 0; i < tags.length; i++) { + if (tags[i].name == pluginName) + return tags[i]; + } + ok(false, "Unable to find plugin"); + return null; +} + +// call this to set the test plugin(s) initially expected enabled state. +// it will automatically be reset to it's previous value after the test +// ends +function setTestPluginEnabledState(newEnabledState, pluginName) { + var plugin = getTestPlugin(pluginName); + var oldEnabledState = plugin.enabledState; + plugin.enabledState = newEnabledState; + SimpleTest.registerCleanupFunction(function() { + getTestPlugin(pluginName).enabledState = oldEnabledState; + }); +} + +// after a test is done using the plugin doorhanger, we should just clear +// any permissions that may have crept in +function clearAllPluginPermissions() { + let perms = Services.perms.enumerator; + while (perms.hasMoreElements()) { + let perm = perms.getNext(); + if (perm.type.startsWith('plugin')) { + Services.perms.remove(perm.host, perm.type); + } + } +} + +function updateBlocklist(aCallback) { + var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"] + .getService(Ci.nsITimerCallback); + var observer = function() { + Services.obs.removeObserver(observer, "blocklist-updated"); + SimpleTest.executeSoon(aCallback); + }; + Services.obs.addObserver(observer, "blocklist-updated", false); + blocklistNotifier.notify(null); +} + +var _originalTestBlocklistURL = null; +function setAndUpdateBlocklist(aURL, aCallback) { + if (!_originalTestBlocklistURL) + _originalTestBlocklistURL = Services.prefs.getCharPref("extensions.blocklist.url"); + Services.prefs.setCharPref("extensions.blocklist.url", aURL); + updateBlocklist(aCallback); +} + +function resetBlocklist() { + Services.prefs.setCharPref("extensions.blocklist.url", _originalTestBlocklistURL); +} diff --git a/browser/base/content/test/general/plugin_add_dynamically.html b/browser/base/content/test/plugins/plugin_add_dynamically.html similarity index 100% rename from browser/base/content/test/general/plugin_add_dynamically.html rename to browser/base/content/test/plugins/plugin_add_dynamically.html diff --git a/browser/base/content/test/general/plugin_alternate_content.html b/browser/base/content/test/plugins/plugin_alternate_content.html similarity index 100% rename from browser/base/content/test/general/plugin_alternate_content.html rename to browser/base/content/test/plugins/plugin_alternate_content.html diff --git a/browser/base/content/test/general/plugin_big.html b/browser/base/content/test/plugins/plugin_big.html similarity index 100% rename from browser/base/content/test/general/plugin_big.html rename to browser/base/content/test/plugins/plugin_big.html diff --git a/browser/base/content/test/general/plugin_both.html b/browser/base/content/test/plugins/plugin_both.html similarity index 100% rename from browser/base/content/test/general/plugin_both.html rename to browser/base/content/test/plugins/plugin_both.html diff --git a/browser/base/content/test/general/plugin_both2.html b/browser/base/content/test/plugins/plugin_both2.html similarity index 100% rename from browser/base/content/test/general/plugin_both2.html rename to browser/base/content/test/plugins/plugin_both2.html diff --git a/browser/base/content/test/general/plugin_bug744745.html b/browser/base/content/test/plugins/plugin_bug744745.html similarity index 100% rename from browser/base/content/test/general/plugin_bug744745.html rename to browser/base/content/test/plugins/plugin_bug744745.html diff --git a/browser/base/content/test/general/plugin_bug749455.html b/browser/base/content/test/plugins/plugin_bug749455.html similarity index 100% rename from browser/base/content/test/general/plugin_bug749455.html rename to browser/base/content/test/plugins/plugin_bug749455.html diff --git a/browser/base/content/test/general/plugin_bug752516.html b/browser/base/content/test/plugins/plugin_bug752516.html similarity index 100% rename from browser/base/content/test/general/plugin_bug752516.html rename to browser/base/content/test/plugins/plugin_bug752516.html diff --git a/browser/base/content/test/general/plugin_bug787619.html b/browser/base/content/test/plugins/plugin_bug787619.html similarity index 100% rename from browser/base/content/test/general/plugin_bug787619.html rename to browser/base/content/test/plugins/plugin_bug787619.html diff --git a/browser/base/content/test/general/plugin_bug797677.html b/browser/base/content/test/plugins/plugin_bug797677.html similarity index 100% rename from browser/base/content/test/general/plugin_bug797677.html rename to browser/base/content/test/plugins/plugin_bug797677.html diff --git a/browser/base/content/test/general/plugin_bug820497.html b/browser/base/content/test/plugins/plugin_bug820497.html similarity index 100% rename from browser/base/content/test/general/plugin_bug820497.html rename to browser/base/content/test/plugins/plugin_bug820497.html diff --git a/browser/base/content/test/general/plugin_clickToPlayAllow.html b/browser/base/content/test/plugins/plugin_clickToPlayAllow.html similarity index 100% rename from browser/base/content/test/general/plugin_clickToPlayAllow.html rename to browser/base/content/test/plugins/plugin_clickToPlayAllow.html diff --git a/browser/base/content/test/general/plugin_clickToPlayDeny.html b/browser/base/content/test/plugins/plugin_clickToPlayDeny.html similarity index 100% rename from browser/base/content/test/general/plugin_clickToPlayDeny.html rename to browser/base/content/test/plugins/plugin_clickToPlayDeny.html diff --git a/browser/base/content/test/general/pluginCrashCommentAndURL.html b/browser/base/content/test/plugins/plugin_crashCommentAndURL.html similarity index 100% rename from browser/base/content/test/general/pluginCrashCommentAndURL.html rename to browser/base/content/test/plugins/plugin_crashCommentAndURL.html diff --git a/browser/base/content/test/general/plugin_data_url.html b/browser/base/content/test/plugins/plugin_data_url.html similarity index 100% rename from browser/base/content/test/general/plugin_data_url.html rename to browser/base/content/test/plugins/plugin_data_url.html diff --git a/browser/base/content/test/general/plugin_hidden_to_visible.html b/browser/base/content/test/plugins/plugin_hidden_to_visible.html similarity index 100% rename from browser/base/content/test/general/plugin_hidden_to_visible.html rename to browser/base/content/test/plugins/plugin_hidden_to_visible.html diff --git a/browser/base/content/test/general/plugin_outsideScrollArea.html b/browser/base/content/test/plugins/plugin_outsideScrollArea.html similarity index 100% rename from browser/base/content/test/general/plugin_outsideScrollArea.html rename to browser/base/content/test/plugins/plugin_outsideScrollArea.html diff --git a/browser/base/content/test/general/plugin_overlayed.html b/browser/base/content/test/plugins/plugin_overlayed.html similarity index 100% rename from browser/base/content/test/general/plugin_overlayed.html rename to browser/base/content/test/plugins/plugin_overlayed.html diff --git a/browser/base/content/test/general/plugin_positioned.html b/browser/base/content/test/plugins/plugin_positioned.html similarity index 100% rename from browser/base/content/test/general/plugin_positioned.html rename to browser/base/content/test/plugins/plugin_positioned.html diff --git a/browser/base/content/test/general/plugin_small.html b/browser/base/content/test/plugins/plugin_small.html similarity index 100% rename from browser/base/content/test/general/plugin_small.html rename to browser/base/content/test/plugins/plugin_small.html diff --git a/browser/base/content/test/general/plugin_syncRemoved.html b/browser/base/content/test/plugins/plugin_syncRemoved.html similarity index 100% rename from browser/base/content/test/general/plugin_syncRemoved.html rename to browser/base/content/test/plugins/plugin_syncRemoved.html diff --git a/browser/base/content/test/general/plugin_test.html b/browser/base/content/test/plugins/plugin_test.html similarity index 100% rename from browser/base/content/test/general/plugin_test.html rename to browser/base/content/test/plugins/plugin_test.html diff --git a/browser/base/content/test/general/plugin_test2.html b/browser/base/content/test/plugins/plugin_test2.html similarity index 100% rename from browser/base/content/test/general/plugin_test2.html rename to browser/base/content/test/plugins/plugin_test2.html diff --git a/browser/base/content/test/general/plugin_test3.html b/browser/base/content/test/plugins/plugin_test3.html similarity index 100% rename from browser/base/content/test/general/plugin_test3.html rename to browser/base/content/test/plugins/plugin_test3.html diff --git a/browser/base/content/test/general/plugin_two_types.html b/browser/base/content/test/plugins/plugin_two_types.html similarity index 100% rename from browser/base/content/test/general/plugin_two_types.html rename to browser/base/content/test/plugins/plugin_two_types.html diff --git a/browser/base/content/test/general/plugin_unknown.html b/browser/base/content/test/plugins/plugin_unknown.html similarity index 100% rename from browser/base/content/test/general/plugin_unknown.html rename to browser/base/content/test/plugins/plugin_unknown.html diff --git a/browser/base/content/test/social/head.js b/browser/base/content/test/social/head.js index 0edfd174774..e18e762af69 100644 --- a/browser/base/content/test/social/head.js +++ b/browser/base/content/test/social/head.js @@ -325,7 +325,7 @@ function resetBlocklist(aCallback) { // XXX - this has "forked" from the head.js helpers in our parent directory :( // But let's reuse their blockNoPlugins.xml. Later, we should arrange to // use their head.js helpers directly - let noBlockedURL = "http://example.com/browser/browser/base/content/test/general/blockNoPlugins.xml"; + let noBlockedURL = "http://example.com/browser/browser/base/content/test/plugins/blockNoPlugins.xml"; setAndUpdateBlocklist(noBlockedURL, function() { Services.prefs.setCharPref("extensions.blocklist.url", _originalTestBlocklistURL); if (aCallback) diff --git a/browser/base/moz.build b/browser/base/moz.build index 9a3d31aaf36..64b0f6fd20f 100644 --- a/browser/base/moz.build +++ b/browser/base/moz.build @@ -15,6 +15,7 @@ MOCHITEST_CHROME_MANIFESTS += [ BROWSER_CHROME_MANIFESTS += [ 'content/test/general/browser.ini', 'content/test/newtab/browser.ini', + 'content/test/plugins/browser.ini', 'content/test/social/browser.ini', ] From 7f5ffbaae4ae3f66bd64ecfac04855e019246cf8 Mon Sep 17 00:00:00 2001 From: Georg Fritzsche Date: Fri, 28 Feb 2014 12:24:13 +0100 Subject: [PATCH 08/62] Bug 977543 - CTP overlay is not displayed for iframes/embedded videos. r=jaws --- browser/base/content/browser-plugins.js | 2 +- browser/base/content/test/plugins/browser.ini | 2 + .../test/plugins/browser_CTP_iframe.js | 102 ++++++++++++++++++ .../content/test/plugins/plugin_iframe.html | 9 ++ 4 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 browser/base/content/test/plugins/browser_CTP_iframe.js create mode 100644 browser/base/content/test/plugins/plugin_iframe.html diff --git a/browser/base/content/browser-plugins.js b/browser/base/content/browser-plugins.js index 04c65641ae8..a60ac49d56b 100644 --- a/browser/base/content/browser-plugins.js +++ b/browser/base/content/browser-plugins.js @@ -130,7 +130,7 @@ var gPluginHandler = { return false; } - let contentWindow = plugin.ownerDocument.defaultView.top; + let contentWindow = plugin.ownerDocument.defaultView; let cwu = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindowUtils); diff --git a/browser/base/content/test/plugins/browser.ini b/browser/base/content/test/plugins/browser.ini index 3ec41bde80b..537a46b4b80 100644 --- a/browser/base/content/test/plugins/browser.ini +++ b/browser/base/content/test/plugins/browser.ini @@ -22,6 +22,7 @@ support-files = plugin_clickToPlayDeny.html plugin_data_url.html plugin_hidden_to_visible.html + plugin_iframe.html plugin_outsideScrollArea.html plugin_overlayed.html plugin_positioned.html @@ -50,6 +51,7 @@ run-if = crashreporter [browser_CTP_data_urls.js] [browser_CTP_drag_drop.js] [browser_CTP_hide_overlay.js] +[browser_CTP_iframe.js] [browser_CTP_multi_allow.js] [browser_CTP_nonplugins.js] [browser_CTP_notificationBar.js] diff --git a/browser/base/content/test/plugins/browser_CTP_iframe.js b/browser/base/content/test/plugins/browser_CTP_iframe.js new file mode 100644 index 00000000000..9b96807b265 --- /dev/null +++ b/browser/base/content/test/plugins/browser_CTP_iframe.js @@ -0,0 +1,102 @@ +let rootDir = getRootDirectory(gTestPath); +const gTestRoot = rootDir; +const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); + +let gTestBrowser = null; +let gNextTest = null; + +Components.utils.import("resource://gre/modules/Services.jsm"); + +function test() { + waitForExplicitFinish(); + registerCleanupFunction(function() { + clearAllPluginPermissions(); + Services.prefs.clearUserPref("extensions.blocklist.suppressUI"); + }); + Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true); + + let newTab = gBrowser.addTab(); + gBrowser.selectedTab = newTab; + gTestBrowser = gBrowser.selectedBrowser; + gTestBrowser.addEventListener("load", pageLoad, true); + + Services.prefs.setBoolPref("plugins.click_to_play", true); + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); + + prepareTest(delayTest(runAfterPluginBindingAttached(test1)), gHttpTestRoot + "plugin_iframe.html"); +} + +function finishTest() { + clearAllPluginPermissions(); + gTestBrowser.removeEventListener("load", pageLoad, true); + gBrowser.removeCurrentTab(); + window.focus(); + finish(); +} + +function pageLoad() { + gNextTest(); +} + +function prepareTest(nextTest, url) { + gNextTest = nextTest; + gTestBrowser.contentWindow.location = url; +} + +// Delay executing a test for one load event to wait for frame loads. +function delayTest(nextTest) { + return () => { + gNextTest = nextTest; + } +} + +// Due to layout being async, "PluginBindAttached" may trigger later. +// This wraps a function to force a layout flush, thus triggering it, +// and schedules the function execution so they're definitely executed +// afterwards. +function runAfterPluginBindingAttached(func) { + return () => { + let frame = gTestBrowser.contentDocument.getElementById("frame"); + let doc = frame.contentDocument; + let elems = doc.getElementsByTagName('embed'); + if (elems.length < 1) { + elems = doc.getElementsByTagName('object'); + } + elems[0].clientTop; + executeSoon(func); + }; +} + +// Tests that the overlays are visible and actionable if the plugin is in an iframe. +function test1() { + let frame = gTestBrowser.contentDocument.getElementById("frame"); + let doc = frame.contentDocument; + let plugin = doc.getElementById("test"); + ok(plugin, "Test 1, Found plugin in page"); + + let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); + ok(overlay.classList.contains("visible"), "Test 1, Plugin overlay should exist, not be hidden"); + let closeIcon = doc.getAnonymousElementByAttribute(plugin, "anonid", "closeIcon") + + EventUtils.synthesizeMouseAtCenter(closeIcon, {}, frame.contentWindow); + let condition = () => !overlay.classList.contains("visible"); + waitForCondition(condition, test2, "Test 1, Waited too long for the overlay to become invisible."); +} + +function test2() { + prepareTest(delayTest(runAfterPluginBindingAttached(test3)), gHttpTestRoot + "plugin_iframe.html"); +} + +function test3() { + let frame = gTestBrowser.contentDocument.getElementById("frame"); + let doc = frame.contentDocument; + let plugin = doc.getElementById("test"); + ok(plugin, "Test 3, Found plugin in page"); + + let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); + ok(overlay.classList.contains("visible"), "Test 3, Plugin overlay should exist, not be hidden"); + + EventUtils.synthesizeMouseAtCenter(plugin, {}, frame.contentWindow); + let condition = () => PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); + waitForCondition(condition, finishTest, "Test 3, Waited too long for the doorhanger to pop up."); +} diff --git a/browser/base/content/test/plugins/plugin_iframe.html b/browser/base/content/test/plugins/plugin_iframe.html new file mode 100644 index 00000000000..239c9a7719e --- /dev/null +++ b/browser/base/content/test/plugins/plugin_iframe.html @@ -0,0 +1,9 @@ + + + + + + +