Example #1
PassOwnPtr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperWorld* isolatedWorld, ContentSecurityPolicy* policy)
    JSValue v = exec->argument(0);
    CallData callData;
    CallType callType = getCallData(v, callData);
    if (callType == CallTypeNone) {
        if (policy && !policy->allowEval())
            return nullptr;
        UString string = v.toString(exec)->value(exec);
        if (exec->hadException())
            return nullptr;
        return adoptPtr(new ScheduledAction(ustringToString(string), isolatedWorld));

    // WebERA this calculates a unique indification of the called function scheduled in this action.

    if (callType == CallTypeJS) {
        const SourceCode source = callData.js.functionExecutable->source();
        WTF::String url = WebCore::decodeURLEscapeSequences(WTF::String(source.provider()->url().utf8().data()));

        uint calledLine = source.firstLine();

        return adoptPtr(new ScheduledAction(exec, v, isolatedWorld, url.ascii().data(), calledLine));

    return adoptPtr(new ScheduledAction(exec, v, isolatedWorld, "<native-function>", -1));
MediaPlayer::SupportsType MediaPlayerPrivate::supportsType(const WTF::String& type, const WTF::String& codecs, const KURL& url)
    bool isRTSP = url.protocolIs("rtsp");

    if (!isRTSP && (type.isNull() || type.isEmpty())) {
        LOG(Media, "MediaPlayer does not support type; type is null or empty.");
        return MediaPlayer::IsNotSupported;

    // spec says we should not return "probably" if the codecs string is empty
    if (isRTSP || PlatformPlayer::mimeTypeSupported(type.ascii().data())) {
        LOG(Media, "MediaPlayer supports type %s.", isRTSP ? "rtsp" : type.ascii().data());
        return codecs.isEmpty() ? MediaPlayer::MayBeSupported : MediaPlayer::IsSupported;
    LOG(Media, "MediaPlayer does not support type %s.", type.ascii().data());
    return MediaPlayer::IsNotSupported;
Example #3
// because the debugger can be attached at any time, and also because other
// methods will be called on this debugger for sources that have already been
// detached, we make fake entries for unknown source entries as they are
// encountered, and we retain old sourceID entries until they are replaced
// by new data.  fake entries are handled by the Source constructor.
void DebuggerShell::sourceParsed(ExecState* execState,
                                 SourceProvider* sourceProvider,
                                 int errorLineNumber,
                                 const WTF::String& errorMessage) {
  intptr_t sourceID = sourceProvider->asID();
  Source source = Source(fromWTFString(sourceProvider->url()));
  source.parseID = nextParseID_++;
  source_map_[sourceID] = source;

  // The URL map is used in setting breakpoints.
  // Therefore, it's okay if we overwrite one entry with another.
  // This might happen if we parse both http://a.tld/foo.js and http://b.tld/foo.js ,
  // both of which would clobber the spot occupied by the filename foo.js .
  // This means if you want to break on one or the other, you'll have to
  // specify the full URL.  The convenient mapping for filename won't be useful.
  // But for the common case, filename is very very useful.
  url_map_[source.url] = sourceID;
  url_map_[source.filename] = sourceID;
  parse_id_map_[source.parseID] = sourceID;

  if (errorLineNumber >= 0) {
    WTF::CString error = errorMessage.ascii();
    WTF::CString f = WTF::String::format("Parse failed in %s on line %d: %s",
        source.url.c_str(), errorLineNumber, error.data()).ascii();
  } else {
    if (tracing_ || dumping_source_) {
      WTF::CString f = WTF::String::format("Parsed %s", source.url.c_str()).ascii();
    if (dumping_source_) {
      // NOTE: We only dump first 100 bytes of source.  The point is to know
      // more or less what's in it, not to see all 2MB of JavaScript.
      // It's really most useful for seeing the source of evals full of JSON.
      WTF::CString code = sourceProvider->source().ascii();
      WTF::CString code_clipped(code.data(), code.length() > 100 ? 100 : code.length());
      WTF::CString f = WTF::String::format("Source of %s[%d]: %s", source.url.c_str(), source.parseID, code_clipped.data()).ascii();
Example #4
static inline std::string fromWTFString(const WTF::String& wtf_string) {
  if (wtf_string.isNull()) return std::string();
  WTF::CString cstring = wtf_string.ascii();
  return std::string(cstring.data(), cstring.length());