void fillMessagePortArray(JSC::ExecState* exec, JSC::JSValue value, MessagePortArray& portArray) { // Convert from the passed-in JS array-like object to a MessagePortArray. // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec. if (value.isUndefinedOrNull()) { portArray.resize(0); return; } // Validation of sequence types, per WebIDL spec 4.1.13. unsigned length; JSObject* object = toJSSequence(exec, value, length); if (exec->hadException()) return; portArray.resize(length); for (unsigned i = 0 ; i < length; ++i) { JSValue value = object->get(exec, i); if (exec->hadException()) return; // Validation of non-null objects, per HTML5 spec 8.3.3. if (value.isUndefinedOrNull()) { setDOMException(exec, INVALID_STATE_ERR); return; } // Validation of Objects implementing an interface, per WebIDL spec 4.1.15. RefPtr<MessagePort> port = toMessagePort(value); if (!port) { throwTypeError(exec); return; } portArray[i] = port.release(); } }
PassRefPtr<JSCustomXPathNSResolver> JSCustomXPathNSResolver::create(JSC::ExecState* exec, JSC::JSValue value) { if (value.isUndefinedOrNull()) return 0; JSObject* resolverObject = value.getObject(); if (!resolverObject) { setDOMException(exec, TYPE_MISMATCH_ERR); return 0; } return adoptRef(new JSCustomXPathNSResolver(resolverObject, asJSDOMWindow(exec->dynamicGlobalObject()))); }
void selectIndexSetter(HTMLSelectElement* select, JSC::ExecState* exec, unsigned index, JSC::JSValue value) { if (value.isUndefinedOrNull()) select->removeByIndex(index); else { ExceptionCode ec = 0; HTMLOptionElement* option = toHTMLOptionElement(value); if (!option) ec = TYPE_MISMATCH_ERR; else select->setOption(index, option, ec); setDOMException(exec, ec); } }
void fillMessagePortArray(JSC::ExecState* exec, JSC::JSValue value, MessagePortArray& portArray, ArrayBufferArray& arrayBuffers) { // Convert from the passed-in JS array-like object to a MessagePortArray. // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec. if (value.isUndefinedOrNull()) { portArray.resize(0); arrayBuffers.resize(0); return; } // Validation of sequence types, per WebIDL spec 4.1.13. unsigned length = 0; JSObject* object = toJSSequence(exec, value, length); if (exec->hadException()) return; for (unsigned i = 0 ; i < length; ++i) { JSValue value = object->get(exec, i); if (exec->hadException()) return; // Validation of non-null objects, per HTML5 spec 10.3.3. if (value.isUndefinedOrNull()) { setDOMException(exec, INVALID_STATE_ERR); return; } // Validation of Objects implementing an interface, per WebIDL spec 4.1.15. RefPtr<MessagePort> port = toMessagePort(value); if (port) { // Check for duplicate ports. if (portArray.contains(port)) { #if MODIFY(ENGINE) //[2014.03.05][infraware][jungong16] : fix to issue. http://www.w3.org/TR/webmessaging/#dom-window-postmessage setDOMException(exec, DATA_CLONE_ERR); #else setDOMException(exec, INVALID_STATE_ERR); #endif return; } portArray.append(port.release()); } else { RefPtr<ArrayBuffer> arrayBuffer = toArrayBuffer(value); if (arrayBuffer) arrayBuffers.append(arrayBuffer); else { throwTypeError(exec); return; } } } }
void fillMessagePortArray(JSC::ExecState* exec, JSC::JSValue value, MessagePortArray& portArray, ArrayBufferArray& arrayBuffers) { // Convert from the passed-in JS array-like object to a MessagePortArray. // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec. if (value.isUndefinedOrNull()) { portArray.resize(0); arrayBuffers.resize(0); return; } // Validation of sequence types, per WebIDL spec 4.1.13. unsigned length = 0; JSObject* object = toJSSequence(exec, value, length); if (exec->hadException()) return; for (unsigned i = 0 ; i < length; ++i) { JSValue value = object->get(exec, i); if (exec->hadException()) return; // Validation of non-null objects, per HTML5 spec 10.3.3. if (value.isUndefinedOrNull()) { setDOMException(exec, INVALID_STATE_ERR); return; } // Validation of Objects implementing an interface, per WebIDL spec 4.1.15. RefPtr<MessagePort> port = JSMessagePort::toWrapped(value); if (port) { // Check for duplicate ports. if (portArray.contains(port)) { setDOMException(exec, INVALID_STATE_ERR); return; } portArray.append(port.release()); } else { RefPtr<ArrayBuffer> arrayBuffer = toArrayBuffer(value); if (arrayBuffer) arrayBuffers.append(arrayBuffer); else { throwTypeError(exec); return; } } } }