fix: use document from store context
This commit is contained in:
@ -11,7 +11,11 @@ import { isBrowser } from '../../utils';
|
|||||||
|
|
||||||
const clientSide = isBrowser();
|
const clientSide = isBrowser();
|
||||||
|
|
||||||
const sagaMiddleware = createSagaMiddleware();
|
const sagaMiddleware = createSagaMiddleware({
|
||||||
|
context: {
|
||||||
|
document: clientSide ? document : {}
|
||||||
|
}
|
||||||
|
});
|
||||||
const epicMiddleware = createEpicMiddleware({
|
const epicMiddleware = createEpicMiddleware({
|
||||||
dependencies: {
|
dependencies: {
|
||||||
window: clientSide ? window : {},
|
window: clientSide ? window : {},
|
||||||
|
@ -4,7 +4,8 @@ import {
|
|||||||
call,
|
call,
|
||||||
takeLatest,
|
takeLatest,
|
||||||
takeEvery,
|
takeEvery,
|
||||||
fork
|
fork,
|
||||||
|
getContext
|
||||||
} from 'redux-saga/effects';
|
} from 'redux-saga/effects';
|
||||||
import { delay, channel } from 'redux-saga';
|
import { delay, channel } from 'redux-saga';
|
||||||
|
|
||||||
@ -99,15 +100,16 @@ function* executeJSChallengeSaga(state, proxyLogger) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTestFrame(ctx, proxyLogger) {
|
function createTestFrame(document, ctx, proxyLogger) {
|
||||||
return new Promise(resolve =>
|
return new Promise(resolve =>
|
||||||
createTestFramer(document, resolve, proxyLogger)(ctx)
|
createTestFramer(document, resolve, proxyLogger)(ctx)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function* executeDOMChallengeSaga(state, proxyLogger) {
|
function* executeDOMChallengeSaga(state, proxyLogger) {
|
||||||
|
const document = yield getContext('document');
|
||||||
const ctx = yield call(buildDOMChallenge, state);
|
const ctx = yield call(buildDOMChallenge, state);
|
||||||
yield call(createTestFrame, ctx, proxyLogger);
|
yield call(createTestFrame, document, ctx, proxyLogger);
|
||||||
// wait for a code execution on a "ready" event in jQuery challenges
|
// wait for a code execution on a "ready" event in jQuery challenges
|
||||||
yield delay(100);
|
yield delay(100);
|
||||||
|
|
||||||
@ -118,8 +120,9 @@ function* executeDOMChallengeSaga(state, proxyLogger) {
|
|||||||
|
|
||||||
// TODO: use a web worker
|
// TODO: use a web worker
|
||||||
function* executeBackendChallengeSaga(state, proxyLogger) {
|
function* executeBackendChallengeSaga(state, proxyLogger) {
|
||||||
|
const document = yield getContext('document');
|
||||||
const ctx = yield call(buildBackendChallenge, state);
|
const ctx = yield call(buildBackendChallenge, state);
|
||||||
yield call(createTestFrame, ctx, proxyLogger);
|
yield call(createTestFrame, document, ctx, proxyLogger);
|
||||||
|
|
||||||
return yield call(executeTests, (testString, testTimeout) =>
|
return yield call(executeTests, (testString, testTimeout) =>
|
||||||
runTestInTestFrame(document, testString, testTimeout)
|
runTestInTestFrame(document, testString, testTimeout)
|
||||||
@ -166,6 +169,7 @@ function* updateMainSaga() {
|
|||||||
}
|
}
|
||||||
const state = yield select();
|
const state = yield select();
|
||||||
const ctx = yield call(buildDOMChallenge, state);
|
const ctx = yield call(buildDOMChallenge, state);
|
||||||
|
const document = yield getContext('document');
|
||||||
const frameMain = yield call(createMainFramer, document);
|
const frameMain = yield call(createMainFramer, document);
|
||||||
yield call(frameMain, ctx);
|
yield call(frameMain, ctx);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Reference in New Issue
Block a user