This is buggy. When you do String.fromCharCode('_') you get '' and try to register an element named -x_, which isn't what you're trying to test. The test result is also wrong, it says failure is an error, but NCNames can't start with - so it is correct to throw in that case.