diff --git a/common/app/routes/Challenges/rechallenge/builders.js b/common/app/routes/Challenges/rechallenge/builders.js index e076440383..3984c83e0d 100644 --- a/common/app/routes/Challenges/rechallenge/builders.js +++ b/common/app/routes/Challenges/rechallenge/builders.js @@ -19,6 +19,20 @@ import { const htmlCatch = '\n\n'; const jsCatch = '\n;/*fcc*/\n'; +const loopProtector = ` + window.loopProtect = parent.loopProtect; + window.__err = null; + window.loopProtect.hit = function(line) { + window.__err = new Error( + 'Potential infinite loop at line ' + + line + + '. To disable loop protection, write:' + + ' // noprotect as the first' + + ' line. Beware that if you do have an infinite loop in your code' + + ' this will crash your browser.' + ); + }; +`; const defaultTemplate = ({ source }) => ` @@ -28,7 +42,7 @@ const defaultTemplate = ({ source }) => ` `; const wrapInScript = partial(transformContents, (content) => ( - `${htmlCatch}` + `${htmlCatch}` )); const wrapInStyle = partial(transformContents, (content) => ( `${htmlCatch}`