I just ran this code on the demo on the webpage, and it turned the editor purple. So it might be that your problem is elsewhere.
CodeMirror.defineOption("bg", null, function(cm, val) {
cm.display.wrapper.style.background = val
})
editor.setOption("bg", "purple")
One possibility is that the way you’re loading the addon is causing it to load a separate CodeMirror module from the one your editor is using, and register its options there. Thus, your editor won’t see it. Add a console.log to the top of codemirror.js to find out how often it is being loaded.