mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out 3ad7f12bde01 (bug 664179) and 3ab7b95bfcb5 (bug 673296) for Linux debug M1 orange
This commit is contained in:
parent
9f362a60d2
commit
c2f49690ff
@ -51,7 +51,7 @@ interface nsIPrincipal;
|
||||
interface nsIScriptContext;
|
||||
interface nsPIDOMWindow;
|
||||
|
||||
[scriptable, uuid(83dc8c2b-376e-42b3-8bed-1ad6dea7d6d7)]
|
||||
[scriptable, uuid(755e2d2d-a836-4539-83f4-16b51156341f)]
|
||||
interface nsIEventSource : nsISupports
|
||||
{
|
||||
readonly attribute DOMString url;
|
||||
@ -62,11 +62,6 @@ interface nsIEventSource : nsISupports
|
||||
const unsigned short CLOSED = 2;
|
||||
readonly attribute long readyState;
|
||||
|
||||
// if true then cross-site Access-Control requests are made using credentials
|
||||
// such as cookies and authorization headers. Never affects same-site
|
||||
// requests.
|
||||
readonly attribute boolean mozWithCredentials;
|
||||
|
||||
// event handler attributes
|
||||
attribute nsIDOMEventListener onopen;
|
||||
attribute nsIDOMEventListener onmessage;
|
||||
@ -88,14 +83,9 @@ interface nsIEventSource : nsISupports
|
||||
* null.
|
||||
* @param ownerWindow The associated window for the request. May be null.
|
||||
* @param url The EventSource's url. This must not be empty.
|
||||
* @param withCredentials When set to true attempts to make cross-site
|
||||
* Access-Control requests with credentials such as
|
||||
* cookies and authorization headers. Never affects
|
||||
* same-site requests.
|
||||
*/
|
||||
[noscript] void init(in nsIPrincipal principal,
|
||||
in nsIScriptContext scriptContext,
|
||||
in nsPIDOMWindow ownerWindow,
|
||||
in DOMString url,
|
||||
in boolean withCredentials);
|
||||
in DOMString url);
|
||||
};
|
||||
|
@ -62,7 +62,6 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsCrossSiteListenerProxy.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -86,7 +85,6 @@ nsEventSource::nsEventSource() :
|
||||
mFrozen(false),
|
||||
mErrorLoadOnRedirect(false),
|
||||
mGoingToDispatchAllMessages(false),
|
||||
mWithCredentials(false),
|
||||
mLastConvertionResult(NS_OK),
|
||||
mReadyState(nsIEventSource::CONNECTING),
|
||||
mScriptLine(0),
|
||||
@ -167,14 +165,6 @@ nsEventSource::GetReadyState(PRInt32 *aReadyState)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventSource::GetMozWithCredentials(bool *aWithCredentials)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aWithCredentials);
|
||||
*aWithCredentials = mWithCredentials;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define NS_EVENTSRC_IMPL_DOMEVENTLISTENER(_eventlistenername, _eventlistener) \
|
||||
NS_IMETHODIMP \
|
||||
nsEventSource::GetOn##_eventlistenername(nsIDOMEventListener * *aListener) \
|
||||
@ -240,8 +230,7 @@ NS_IMETHODIMP
|
||||
nsEventSource::Init(nsIPrincipal* aPrincipal,
|
||||
nsIScriptContext* aScriptContext,
|
||||
nsPIDOMWindow* aOwnerWindow,
|
||||
const nsAString& aURL,
|
||||
bool aWithCredentials)
|
||||
const nsAString& aURL)
|
||||
{
|
||||
NS_ENSURE_ARG(aPrincipal);
|
||||
|
||||
@ -251,7 +240,6 @@ nsEventSource::Init(nsIPrincipal* aPrincipal,
|
||||
|
||||
mPrincipal = aPrincipal;
|
||||
mScriptContext = aScriptContext;
|
||||
mWithCredentials = aWithCredentials;
|
||||
if (aOwnerWindow) {
|
||||
mOwner = aOwnerWindow->IsOuterWindow() ?
|
||||
aOwnerWindow->GetCurrentInnerWindow() : aOwnerWindow;
|
||||
@ -302,8 +290,8 @@ nsEventSource::Init(nsIPrincipal* aPrincipal,
|
||||
rv = os->AddObserver(this, DOM_WINDOW_THAWED_TOPIC, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString origin;
|
||||
rv = nsContentUtils::GetUTFOrigin(srcURI, origin);
|
||||
nsXPIDLCString origin;
|
||||
rv = mPrincipal->GetOrigin(getter_Copies(origin));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString spec;
|
||||
@ -388,31 +376,7 @@ nsEventSource::Initialize(nsISupports* aOwner,
|
||||
nsCOMPtr<nsIPrincipal> principal = scriptPrincipal->GetPrincipal();
|
||||
NS_ENSURE_STATE(principal);
|
||||
|
||||
bool withCredentialsParam = false;
|
||||
if (aArgc >= 2) {
|
||||
NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aArgv[1]), NS_ERROR_INVALID_ARG);
|
||||
|
||||
JSObject *obj = JSVAL_TO_OBJECT(aArgv[1]);
|
||||
NS_ASSERTION(obj, "obj shouldn't be null!!");
|
||||
|
||||
JSBool hasProperty = JS_FALSE;
|
||||
NS_ENSURE_TRUE(JS_HasProperty(aContext, obj, "mozWithCredentials",
|
||||
&hasProperty), NS_ERROR_FAILURE);
|
||||
|
||||
if (hasProperty) {
|
||||
jsval withCredentialsVal;
|
||||
NS_ENSURE_TRUE(JS_GetProperty(aContext, obj, "mozWithCredentials",
|
||||
&withCredentialsVal), NS_ERROR_FAILURE);
|
||||
|
||||
JSBool withCredentials = JS_FALSE;
|
||||
NS_ENSURE_TRUE(JS_ValueToBoolean(aContext, withCredentialsVal,
|
||||
&withCredentials), NS_ERROR_FAILURE);
|
||||
withCredentialsParam = !!withCredentials;
|
||||
}
|
||||
}
|
||||
|
||||
return Init(principal, scriptContext, ownerWindow,
|
||||
urlParam, withCredentialsParam);
|
||||
return Init(principal, scriptContext, ownerWindow, urlParam);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -922,13 +886,8 @@ nsEventSource::InitChannelAndRequestEventSource()
|
||||
rv = SetupHttpChannel();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIStreamListener> listener =
|
||||
new nsCORSListenerProxy(this, mPrincipal, mHttpChannel,
|
||||
mWithCredentials, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Start reading from the channel
|
||||
return mHttpChannel->AsyncOpen(listener, nsnull);
|
||||
return mHttpChannel->AsyncOpen(this, nsnull);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1214,6 +1173,7 @@ nsEventSource::CheckCanRequestSrc(nsIURI* aSrc)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isSameOrigin = false;
|
||||
bool isValidURI = false;
|
||||
bool isValidContentLoadPolicy = false;
|
||||
bool isValidProtocol = false;
|
||||
@ -1221,6 +1181,8 @@ nsEventSource::CheckCanRequestSrc(nsIURI* aSrc)
|
||||
nsCOMPtr<nsIURI> srcToTest = aSrc ? aSrc : mSrc.get();
|
||||
NS_ENSURE_TRUE(srcToTest, false);
|
||||
|
||||
isSameOrigin = NS_SUCCEEDED(mPrincipal->CheckMayLoad(srcToTest, false));
|
||||
|
||||
PRUint32 aCheckURIFlags =
|
||||
nsIScriptSecurityManager::DISALLOW_INHERIT_PRINCIPAL |
|
||||
nsIScriptSecurityManager::DISALLOW_SCRIPT;
|
||||
@ -1260,7 +1222,8 @@ nsEventSource::CheckCanRequestSrc(nsIURI* aSrc)
|
||||
targetURIScheme.EqualsLiteral("https");
|
||||
}
|
||||
|
||||
return isValidURI && isValidContentLoadPolicy && isValidProtocol;
|
||||
return isSameOrigin && isValidURI && isValidContentLoadPolicy &&
|
||||
isValidProtocol;
|
||||
}
|
||||
|
||||
// static
|
||||
@ -1424,7 +1387,7 @@ nsEventSource::DispatchAllMessageEvents()
|
||||
rv = messageEvent->InitMessageEvent(message->mEventName,
|
||||
false, false,
|
||||
jsData,
|
||||
mOrigin,
|
||||
NS_ConvertUTF8toUTF16(mOrigin),
|
||||
message->mLastEventID, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to init the message event!!!");
|
||||
|
@ -215,7 +215,6 @@ protected:
|
||||
bool mFrozen;
|
||||
bool mErrorLoadOnRedirect;
|
||||
bool mGoingToDispatchAllMessages;
|
||||
bool mWithCredentials;
|
||||
|
||||
// used while reading the input streams
|
||||
nsCOMPtr<nsIUnicodeDecoder> mUnicodeDecoder;
|
||||
@ -244,7 +243,7 @@ protected:
|
||||
nsString mOriginalURL;
|
||||
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
nsString mOrigin;
|
||||
nsCString mOrigin;
|
||||
|
||||
PRUint32 mRedirectFlags;
|
||||
nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
|
||||
|
@ -521,7 +521,6 @@ _TEST_FILES2 = \
|
||||
test_bug692434.html \
|
||||
file_bug692434.xml \
|
||||
test_bug693875.html \
|
||||
file_restrictedEventSource.sjs \
|
||||
$(NULL)
|
||||
|
||||
_CHROME_FILES = \
|
||||
|
@ -1,5 +1,4 @@
|
||||
Access-Control-Allow-Origin: http://mochi.test:8888
|
||||
Access-Control-Allow-Credentials: true
|
||||
Access-Control-Allow-Origin: http://localhost:8888
|
||||
Content-Type: text/event-stream
|
||||
Cache-Control: no-cache, must-revalidate
|
||||
|
||||
|
@ -1,44 +0,0 @@
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
if ((request.queryString == "test=user1_xhr" &&
|
||||
request.hasHeader("Authorization") &&
|
||||
request.getHeader("Authorization") == "Basic dXNlciAxOnBhc3N3b3JkIDE=") ||
|
||||
(request.queryString == "test=user1_evtsrc" &&
|
||||
request.hasHeader("Authorization") &&
|
||||
request.getHeader("Authorization") == "Basic dXNlciAxOnBhc3N3b3JkIDE=" &&
|
||||
request.hasHeader("Cookie") &&
|
||||
request.getHeader("Cookie") == "test=5c")) {
|
||||
response.setStatusLine(null, 200, "OK");
|
||||
response.setHeader("Content-Type", "text/event-stream", false);
|
||||
response.setHeader("Access-Control-Allow-Origin", "http://mochi.test:8888", false);
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true", false);
|
||||
response.setHeader("Cache-Control", "no-cache, must-revalidate", false);
|
||||
if (request.queryString == "test=user1_xhr") {
|
||||
response.setHeader("Set-Cookie", "test=5c", false);
|
||||
}
|
||||
response.write("event: message\ndata: 1\n\n");
|
||||
} else if ((request.queryString == "test=user2_xhr" &&
|
||||
request.hasHeader("Authorization") &&
|
||||
request.getHeader("Authorization") == "Basic dXNlciAyOnBhc3N3b3JkIDI=") ||
|
||||
(request.queryString == "test=user2_evtsrc" &&
|
||||
request.hasHeader("Authorization") &&
|
||||
request.getHeader("Authorization") == "Basic dXNlciAyOnBhc3N3b3JkIDI=" &&
|
||||
request.hasHeader("Cookie") &&
|
||||
request.getHeader("Cookie") == "test=5d")) {
|
||||
response.setStatusLine(null, 200, "OK");
|
||||
response.setHeader("Content-Type", "text/event-stream", false);
|
||||
response.setHeader("Access-Control-Allow-Origin", "http://mochi.test:8888", false);
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true", false);
|
||||
response.setHeader("Cache-Control", "no-cache, must-revalidate", false);
|
||||
if (request.queryString == "test=user2_xhr") {
|
||||
response.setHeader("Set-Cookie", "test=5d", false);
|
||||
}
|
||||
response.write("event: message\ndata: 1\n\n");
|
||||
} else {
|
||||
response.setStatusLine(null, 401, "Unauthorized");
|
||||
response.setHeader("WWW-Authenticate", "basic realm=\"restricted\"", false);
|
||||
response.setHeader("Access-Control-Allow-Origin", "http://mochi.test:8888", false);
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true", false);
|
||||
response.write("Unauthorized");
|
||||
}
|
||||
}
|
@ -32,36 +32,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
|
||||
// --
|
||||
|
||||
var gTestsHaveFinished = [];
|
||||
|
||||
function setTestHasFinished(test_id)
|
||||
{
|
||||
gTestsHaveFinished[test_id] = true;
|
||||
for (var i=0; i < gTestsHaveFinished.length; ++i) {
|
||||
if (!gTestsHaveFinished[i]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function runAllTests() {
|
||||
// these tests run asynchronously, and they will take 8000 ms
|
||||
var all_tests = [
|
||||
doTest1, doTest1_e, doTest2, doTest3, doTest3_b, doTest3_c, doTest3_d,
|
||||
doTest3_e, doTest3_f, doTest3_g, doTest3_h, doTest4, doTest4_b,
|
||||
doTest5, doTest5_b, doTest5_c, doTest5_e, doTest6, doTest7
|
||||
];
|
||||
for (var test_id=0; test_id < all_tests.length; ++test_id) {
|
||||
gTestsHaveFinished[test_id] = false;
|
||||
var fn = all_tests[test_id];
|
||||
fn(test_id);
|
||||
setTimeout(new Function(
|
||||
"if (!gTestsHaveFinished[" + test_id + "]) { " +
|
||||
"ok(false, 'Test " + test_id + " took too long'); " +
|
||||
"setTestHasFinished(" + test_id + "); " +
|
||||
"}"), 15000);
|
||||
}
|
||||
// these tests run asynchronously
|
||||
doTest1(); // this will take 8000 ms
|
||||
doTest2(); // this will take 5000 ms
|
||||
doTest3(); // this will take 1500 ms
|
||||
doTest3_b(); // this will take 1500 ms
|
||||
doTest3_c(); // this will take 1500 ms
|
||||
doTest3_d(); // this will take 1500 ms
|
||||
doTest3_e(); // this will take 1500 ms
|
||||
doTest3_f(); // this will take 1500 ms
|
||||
doTest3_g(); // this will take 1500 ms
|
||||
doTest3_h(); // this will take 1500 ms
|
||||
doTest4(); // this will take 3000 ms
|
||||
doTest4_b(); // this will take 3000 ms
|
||||
doTest5(); // this will take 3000 ms
|
||||
doTest5_b(); // this will take 3000 ms
|
||||
doTest6(); // this will take 2500 ms
|
||||
doTest7(); // this will take 8000 ms
|
||||
}
|
||||
|
||||
function fn_onmessage(e) {
|
||||
@ -82,16 +70,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
var domBranch;
|
||||
var oldPrefVal;
|
||||
|
||||
var gEventSourceObj1 = null, gEventSourceObj1_e;
|
||||
var gEventSourceObj1 = null;
|
||||
var gEventSourceObj2 = null;
|
||||
var gEventSourceObj3_a = null, gEventSourceObj3_b = null,
|
||||
gEventSourceObj3_c = null, gEventSourceObj3_d = null,
|
||||
gEventSourceObj3_e = null, gEventSourceObj3_f = null,
|
||||
gEventSourceObj3_g = null, gEventSourceObj3_h = null;
|
||||
var gEventSourceObj4_a = null, gEventSourceObj4_b = null;
|
||||
var gEventSourceObj5_a = null, gEventSourceObj5_b = null,
|
||||
gEventSourceObj5_c = null, gEventSourceObj5_d = null,
|
||||
gEventSourceObj5_e = null, gEventSourceObj5_f = null;
|
||||
var gEventSourceObj5_a = null, gEventSourceObj5_b = null;
|
||||
var gEventSourceObj6 = null;
|
||||
var gEventSourceObj7 = null;
|
||||
var stress_factor; // used in the setTimeouts in order to help
|
||||
@ -110,17 +96,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
// b) let its fn_onmessage, fn_event_listener_message, and fn_other_event_name functions listeners be hit four times each
|
||||
// c) the close method (we expect readyState == CLOSED)
|
||||
// d) the close method (we expect no message events anymore)
|
||||
// e) if the ctor throws an exception when the second parameter is null
|
||||
|
||||
function doTest1(test_id) {
|
||||
function doTest1() {
|
||||
gEventSourceObj1 = new EventSource("eventsource.resource");
|
||||
ok(gEventSourceObj1.url == "http://mochi.test:8888/tests/content/base/test/eventsource.resource", "Test 1.a failed.");
|
||||
ok(gEventSourceObj1.readyState == 0 || gEventSourceObj1.readyState == 1, "Test 1.a failed.");
|
||||
|
||||
doTest1_b(test_id);
|
||||
doTest1_b();
|
||||
}
|
||||
|
||||
function doTest1_b(test_id) {
|
||||
function doTest1_b() {
|
||||
gEventSourceObj1.hits = [];
|
||||
gEventSourceObj1.hits['fn_onmessage'] = 0;
|
||||
gEventSourceObj1.onmessage = fn_onmessage;
|
||||
@ -134,18 +119,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
bhits = hasBeenHitFor1And2(gEventSourceObj1, 4);
|
||||
ok(bhits, "Test 1.b failed.");
|
||||
|
||||
doTest1_c(test_id);
|
||||
doTest1_c();
|
||||
}, parseInt(6000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest1_c(test_id) {
|
||||
function doTest1_c() {
|
||||
gEventSourceObj1.close();
|
||||
ok(gEventSourceObj1.readyState == 2, "Test 1.c failed.");
|
||||
|
||||
doTest1_d(test_id);
|
||||
doTest1_d();
|
||||
}
|
||||
|
||||
function doTest1_d(test_id) {
|
||||
function doTest1_d() {
|
||||
gEventSourceObj1.hits['fn_onmessage'] = 0;
|
||||
gEventSourceObj1.hits['fn_event_listener_message'] = 0;
|
||||
gEventSourceObj1.hits['fn_other_event_name'] = 0;
|
||||
@ -154,26 +139,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
bhits = hasBeenHitFor1And2(gEventSourceObj1, 1);
|
||||
ok(!bhits, "Test 1.d failed.");
|
||||
gEventSourceObj1.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(2000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest1_e(test_id) {
|
||||
try {
|
||||
gEventSourceObj1_e = new EventSource("eventsource.resource", null);
|
||||
ok(false, "Test 1.e failed");
|
||||
gEventSourceObj1_e.close();
|
||||
} catch (e) {
|
||||
ok(true, "Test 1.e failed");
|
||||
}
|
||||
setTestHasFinished(test_id);
|
||||
}
|
||||
|
||||
// in order to test (2)
|
||||
// a) set a eventsource that give the dom events messages
|
||||
// b) expect trusted events
|
||||
|
||||
function doTest2(test_id) {
|
||||
function doTest2() {
|
||||
var func = function(e) {
|
||||
ok(e.isTrusted, "Test 2 failed");
|
||||
gEventSourceObj2.close();
|
||||
@ -184,7 +157,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
|
||||
setTimeout(function(){ // just to clean...
|
||||
gEventSourceObj2.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(5000*stress_factor));
|
||||
}
|
||||
|
||||
@ -198,7 +170,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
// g) eventsource with invalid NCName char in the event field test
|
||||
// h) DNS error
|
||||
|
||||
function doTest3(test_id) {
|
||||
function doTest3() {
|
||||
gEventSourceObj3_a = new EventSource("http://example.org/tests/content/base/test/eventsource.resource");
|
||||
|
||||
gEventSourceObj3_a.onmessage = fn_onmessage;
|
||||
@ -208,11 +180,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3_a.hits['fn_onmessage'] == 0, "Test 3.a failed");
|
||||
gEventSourceObj3_a.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest3_b(test_id) {
|
||||
function doTest3_b() {
|
||||
var xhr = new XMLHttpRequest;
|
||||
xhr.open("GET", "/dynamic/getMyDirectory.sjs", false);
|
||||
xhr.send();
|
||||
@ -227,7 +198,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3_b.hits['fn_onmessage'] == 0, "Test 3.b failed");
|
||||
gEventSourceObj3_b.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
@ -237,7 +207,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
"data: 1\n\n";
|
||||
}
|
||||
|
||||
function doTest3_c(test_id) {
|
||||
function doTest3_c() {
|
||||
gEventSourceObj3_c = new EventSource("javascript: return jsEvtSource()");
|
||||
|
||||
gEventSourceObj3_c.onmessage = fn_onmessage;
|
||||
@ -247,11 +217,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3_c.hits['fn_onmessage'] == 0, "Test 3.c failed");
|
||||
gEventSourceObj3_c.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest3_d(test_id) {
|
||||
function doTest3_d() {
|
||||
gEventSourceObj3_d = new EventSource("badContentType.eventsource");
|
||||
|
||||
gEventSourceObj3_d.onmessage = fn_onmessage;
|
||||
@ -261,11 +230,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3_d.hits['fn_onmessage'] == 0, "Test 3.d failed");
|
||||
gEventSourceObj3_d.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest3_e(test_id) {
|
||||
function doTest3_e() {
|
||||
gEventSourceObj3_e = new EventSource("badHTTPResponseCode.eventsource");
|
||||
|
||||
gEventSourceObj3_e.onmessage = fn_onmessage;
|
||||
@ -275,11 +243,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3_e.hits['fn_onmessage'] == 0, "Test 3.e failed");
|
||||
gEventSourceObj3_e.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest3_f(test_id) {
|
||||
function doTest3_f() {
|
||||
gEventSourceObj3_f = new EventSource("badMessageEvent.eventsource");
|
||||
|
||||
gEventSourceObj3_f.onmessage = fn_onmessage;
|
||||
@ -289,7 +256,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3_f.hits['fn_onmessage'] == 0, "Test 3.f failed");
|
||||
gEventSourceObj3_f.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
@ -297,7 +263,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
fnInvalidNCName.hits++;
|
||||
}
|
||||
|
||||
function doTest3_g(test_id) {
|
||||
function doTest3_g() {
|
||||
gEventSourceObj3_g = new EventSource("badEventFieldName.eventsource");
|
||||
|
||||
fnInvalidNCName.hits = 0;
|
||||
@ -306,11 +272,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
setTimeout(function() {
|
||||
ok(fnInvalidNCName.hits != 0, "Test 3.g failed");
|
||||
gEventSourceObj3_g.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest3_h(test_id) {
|
||||
function doTest3_h() {
|
||||
gEventSourceObj3_h = new EventSource("http://hdfskjghsbg.jtiyoejowe.dafsgbhjab.com");
|
||||
|
||||
gEventSourceObj3_h.onmessage = fn_onmessage;
|
||||
@ -320,7 +285,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3_h.hits['fn_onmessage'] == 0, "Test 3.h failed");
|
||||
gEventSourceObj3_h.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
@ -345,7 +309,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
gEventSourceObj4_b.removeEventListener('message', fn_onmessage4_b, true);
|
||||
}
|
||||
|
||||
function doTest4(test_id) {
|
||||
function doTest4() {
|
||||
gEventSourceObj4_a = new EventSource("forRemoval.resource");
|
||||
gEventSourceObj4_a.lastData = 0;
|
||||
gEventSourceObj4_a.onmessage = fn_onmessage4_a;
|
||||
@ -353,11 +317,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj4_a.lastData == 2, "Test 4.a failed");
|
||||
gEventSourceObj4_a.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest4_b(test_id)
|
||||
function doTest4_b()
|
||||
{
|
||||
gEventSourceObj4_b = new EventSource("forRemoval.resource");
|
||||
gEventSourceObj4_b.lastData = 0;
|
||||
@ -366,19 +329,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj4_b.lastData == 2, "Test 4.b failed");
|
||||
gEventSourceObj4_b.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
// in order to test (5)
|
||||
// a) valid access-control xsite request
|
||||
// a) valid access-control xsite request (but must fail)
|
||||
// b) invalid access-control xsite request
|
||||
// c) valid access-control xsite request on a restricted page with credentials
|
||||
// d) valid access-control xsite request on a restricted page without credentials
|
||||
// e) valid access-control xsite request on a restricted page when the parameter mozWithCredentials is a getter
|
||||
// f) valid access-control xsite request on a restricted page when the parameter mozWithCredentials is missing
|
||||
|
||||
function doTest5(test_id)
|
||||
function doTest5()
|
||||
{
|
||||
gEventSourceObj5_a = new EventSource("http://example.org/tests/content/base/test/accesscontrol.resource");
|
||||
|
||||
@ -387,13 +345,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
gEventSourceObj5_a.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj5_a.hits['fn_onmessage'] != 0, "Test 5.a failed");
|
||||
ok(gEventSourceObj5_a.hits['fn_onmessage'] == 0, "Test 5.a failed");
|
||||
gEventSourceObj5_a.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest5_b(test_id)
|
||||
function doTest5_b()
|
||||
{
|
||||
gEventSourceObj5_b = new EventSource("http://example.org/tests/content/base/test/invalid_accesscontrol.resource");
|
||||
|
||||
@ -404,117 +361,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj5_b.hits['fn_onmessage'] == 0, "Test 5.b failed");
|
||||
gEventSourceObj5_b.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest5_c(test_id)
|
||||
{
|
||||
// credentials using the auth cache and cookies
|
||||
var xhr = SpecialPowers.createSystemXHR();
|
||||
xhr.withCredentials = true;
|
||||
// also, test mixed mode UI
|
||||
xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", false, "user 1", "password 1");
|
||||
xhr.send();
|
||||
ok(xhr.status == 200, "Failed to set credentials in test 5.c");
|
||||
|
||||
gEventSourceObj5_c = new EventSource("https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_evtsrc",
|
||||
{ mozWithCredentials: true } );
|
||||
ok(gEventSourceObj5_c.mozWithCredentials, "Wrong mozWithCredentials in test 5.c");
|
||||
|
||||
gEventSourceObj5_c.onmessage = function(e) {
|
||||
ok(e.origin == "https://example.com", "Wrong Origin in test 5.c");
|
||||
fn_onmessage(e);
|
||||
};
|
||||
gEventSourceObj5_c.hits = [];
|
||||
gEventSourceObj5_c.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj5_c.hits['fn_onmessage'] > 0, "Test 5.c failed");
|
||||
gEventSourceObj5_c.close();
|
||||
doTest5_d(test_id);
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest5_d(test_id)
|
||||
{
|
||||
var xhr = SpecialPowers.createSystemXHR();
|
||||
xhr.withCredentials = true;
|
||||
xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", false, "user 2", "password 2");
|
||||
xhr.send();
|
||||
ok(xhr.status == 200, "Failed to set credentials in test 5.d");
|
||||
|
||||
gEventSourceObj5_d = new EventSource("https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc");
|
||||
ok(!gEventSourceObj5_d.mozWithCredentials, "Wrong mozWithCredentials in test 5.d");
|
||||
|
||||
gEventSourceObj5_d.onmessage = function(e) {
|
||||
ok(e.origin == "https://example.com", "Wrong Origin in test 5.d");
|
||||
fn_onmessage(e);
|
||||
};
|
||||
gEventSourceObj5_d.hits = [];
|
||||
gEventSourceObj5_d.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj5_d.hits['fn_onmessage'] == 0, "Test 5.d failed");
|
||||
gEventSourceObj5_d.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest5_e(test_id)
|
||||
{
|
||||
// credentials using the auth cache and cookies
|
||||
var xhr = SpecialPowers.createSystemXHR();
|
||||
xhr.withCredentials = true;
|
||||
xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", false, "user 1", "password 1");
|
||||
xhr.send();
|
||||
ok(xhr.status == 200, "Failed to set credentials in test 5.e");
|
||||
|
||||
gEventSourceObj5_e = new EventSource("http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_evtsrc",
|
||||
{ get mozWithCredentials() { return true; } } );
|
||||
ok(gEventSourceObj5_e.mozWithCredentials, "Wrong mozWithCredentials in test 5.e");
|
||||
|
||||
gEventSourceObj5_e.onmessage = function(e) {
|
||||
ok(e.origin == "http://example.org", "Wrong Origin in test 5.e");
|
||||
fn_onmessage(e);
|
||||
};
|
||||
gEventSourceObj5_e.hits = [];
|
||||
gEventSourceObj5_e.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj5_e.hits['fn_onmessage'] > 0, "Test 5.e failed");
|
||||
gEventSourceObj5_e.close();
|
||||
doTest5_f(test_id);
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest5_f(test_id)
|
||||
{
|
||||
var xhr = SpecialPowers.createSystemXHR();
|
||||
xhr.withCredentials = true;
|
||||
xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", false, "user 2", "password 2");
|
||||
xhr.send();
|
||||
ok(xhr.status == 200, "Failed to set credentials in test 5.f");
|
||||
|
||||
gEventSourceObj5_f = new EventSource("http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc",
|
||||
{ });
|
||||
ok(!gEventSourceObj5_f.mozWithCredentials, "Wrong mozWithCredentials in test 5.f");
|
||||
|
||||
gEventSourceObj5_f.onmessage = function(e) {
|
||||
ok(e.origin == "http://example.org", "Wrong Origin in test 5.f");
|
||||
fn_onmessage(e);
|
||||
};
|
||||
gEventSourceObj5_f.hits = [];
|
||||
gEventSourceObj5_f.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj5_f.hits['fn_onmessage'] == 0, "Test 5.f failed");
|
||||
gEventSourceObj5_f.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest6(test_id)
|
||||
function doTest6()
|
||||
{
|
||||
gEventSourceObj6 = new EventSource("somedatas.resource");
|
||||
var fn_somedata = function(e) {
|
||||
@ -537,11 +387,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
|
||||
setTimeout(function() {
|
||||
gEventSourceObj6.close();
|
||||
setTestHasFinished(test_id);
|
||||
}, parseInt(2500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest7(test_id)
|
||||
function doTest7()
|
||||
{
|
||||
gEventSourceObj7 = new EventSource("delayedServerEvents.sjs");
|
||||
gEventSourceObj7.msg_received = [];
|
||||
@ -559,11 +408,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
|
||||
SpecialPowers.setBoolPref("dom.server-events.enabled", oldPrefVal);
|
||||
document.getElementById('waitSpan').innerHTML = '';
|
||||
setTestHasFinished(test_id);
|
||||
SimpleTest.finish();
|
||||
}, parseInt(8000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest(test_id)
|
||||
function doTest()
|
||||
{
|
||||
oldPrefVal = SpecialPowers.getBoolPref("dom.server-events.enabled");
|
||||
SpecialPowers.setBoolPref("dom.server-events.enabled", true);
|
||||
|
Loading…
Reference in New Issue
Block a user