Changeset 211818 in webkit


Ignore:
Timestamp:
Feb 7, 2017 10:24:49 AM (7 years ago)
Author:
Yusuke Suzuki
Message:

Unreviewed, manual roll out of r211777
https://bugs.webkit.org/show_bug.cgi?id=167457

Source/JavaScriptCore:

  • jsc.cpp:

(GlobalObject::moduleLoaderImportModule):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncImportModule):

Source/WebCore:

  • bindings/js/ScriptModuleLoader.cpp:

(WebCore::ScriptModuleLoader::importModule):

LayoutTests:

Later, I'll reland it with the deterministic tests.

  • inspector/controller/resources/cappuccino.js: Removed.
  • inspector/controller/resources/cocoa.js: Removed.
  • inspector/controller/resources/drink.js: Removed.
  • inspector/controller/runtime-controller-expected.txt:
  • inspector/controller/runtime-controller.html:
Location:
trunk
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r211807 r211818  
     12017-02-07  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Unreviewed, manual roll out of r211777
     4        https://bugs.webkit.org/show_bug.cgi?id=167457
     5
     6        Later, I'll reland it with the deterministic tests.
     7
     8        * inspector/controller/resources/cappuccino.js: Removed.
     9        * inspector/controller/resources/cocoa.js: Removed.
     10        * inspector/controller/resources/drink.js: Removed.
     11        * inspector/controller/runtime-controller-expected.txt:
     12        * inspector/controller/runtime-controller.html:
     13
    1142017-02-07  Antoine Quint  <graouts@apple.com>
    215
  • trunk/LayoutTests/inspector/controller/runtime-controller-expected.txt

    r211777 r211818  
    77CONSOLE MESSAGE: line 9: Rejection
    88CONSOLE MESSAGE: line 7: %o
    9 CONSOLE MESSAGE: line 7: %o
    10 CONSOLE MESSAGE: line 9: TypeError: Module specifier does not start with "/", "./", or "../".
    11 CONSOLE MESSAGE: line 9: TypeError: Importing a module script failed.
    12 CONSOLE MESSAGE: line 6: Cocoa is Sweet.
    13 CONSOLE MESSAGE: line 7: %o
    14 CONSOLE MESSAGE: line 6: Cocoa is Sweet. Cappuccino is Awesome.
    159CONSOLE MESSAGE: line 7: %o
    1610Tests for RuntimeManager operations.
     
    6559PASS: Exception. Should not get transformed and produce a SyntaxError.
    6660
    67 -- Running test case: RuntimeManager.prototype.evaluateInInspectedWindow.ImportFromConsole
    68 Source: await import('')
    69 PASS: Transformed. Should log the value or an exception.
    70 Source: await import('./not-found.js')
    71 PASS: Transformed. Should log the value or an exception.
    72 Source: await import('./resources/cocoa.js').then((cocoa) => console.log(`${cocoa.name} is ${cocoa.taste}.`))
    73 PASS: Transformed. Should log the value or an exception.
    74 Source: await import('./resources/drink.js').then((ns) => console.log(`${ns.Cocoa.name} is ${ns.Cocoa.taste}. ${ns.Cappuccino.name} is ${ns.Cappuccino.taste}.`))
    75 PASS: Transformed. Should log the value or an exception.
    76 
  • trunk/LayoutTests/inspector/controller/runtime-controller.html

    r211777 r211818  
    125125    });
    126126
    127     suite.addTestCase({
    128         name: "RuntimeManager.prototype.evaluateInInspectedWindow.ImportFromConsole",
    129         description: "Test evaluating an import expression from console.",
    130         test(resolve, reject) {
    131             function testSource(expression) {
    132                 WebInspector.runtimeManager.evaluateInInspectedWindow(expression, {objectGroup: "test"}, (result, wasThrown) => {
    133                     InspectorTest.log("Source: " + expression);
    134                     InspectorTest.expectThat(result.isUndefined(), "Transformed. Should log the value or an exception.");
    135                 });
    136             }
    137 
    138             testSource("await import('')");
    139             testSource("await import('./not-found.js')");
    140             testSource("await import('./resources/cocoa.js').then((cocoa) => console.log(`${cocoa.name} is ${cocoa.taste}.`))");
    141             testSource("await import('./resources/drink.js').then((ns) => console.log(`${ns.Cocoa.name} is ${ns.Cocoa.taste}. ${ns.Cappuccino.name} is ${ns.Cappuccino.taste}.`))");
    142 
    143             InspectorBackend.runAfterPendingDispatches(resolve);
    144         }
    145     });
    146 
    147127    suite.runTestCasesAndFinish();
    148128}
  • trunk/Source/JavaScriptCore/ChangeLog

    r211777 r211818  
     12017-02-07  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Unreviewed, manual roll out of r211777
     4        https://bugs.webkit.org/show_bug.cgi?id=167457
     5
     6        * jsc.cpp:
     7        (GlobalObject::moduleLoaderImportModule):
     8        * runtime/JSGlobalObjectFunctions.cpp:
     9        (JSC::globalFuncImportModule):
     10
    1112017-02-07  Yusuke Suzuki  <utatane.tea@gmail.com>
    212
  • trunk/Source/JavaScriptCore/jsc.cpp

    r211777 r211818  
    15521552    };
    15531553
    1554     if (sourceOrigin.isNull())
    1555         return rejectPromise(createError(exec, ASCIILiteral("Could not resolve the module specifier.")));
    1556 
    15571554    auto referrer = sourceOrigin.string();
    15581555    auto moduleName = moduleNameValue->value(exec);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r211777 r211818  
    945945
    946946    auto sourceOrigin = exec->callerSourceOrigin();
     947    if (sourceOrigin.isNull()) {
     948        promise->reject(exec, createError(exec, ASCIILiteral("Could not resolve the module specifier.")));
     949        return JSValue::encode(promise->promise());
     950    }
     951
    947952    RELEASE_ASSERT(exec->argumentCount() == 1);
    948953    auto* specifier = exec->uncheckedArgument(0).toString(exec);
  • trunk/Source/WebCore/ChangeLog

    r211815 r211818  
     12017-02-07  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Unreviewed, manual roll out of r211777
     4        https://bugs.webkit.org/show_bug.cgi?id=167457
     5
     6        * bindings/js/ScriptModuleLoader.cpp:
     7        (WebCore::ScriptModuleLoader::importModule):
     8
    192017-02-07  Carlos Garcia Campos  <cgarcia@igalia.com>
    210
  • trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp

    r211777 r211818  
    219219    auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(jsGlobalObject);
    220220
    221     // If SourceOrigin and/or CachedScriptFetcher is null, we import the module with the default fetcher.
    222     // SourceOrigin can be null if the source code is not coupled with the script file.
    223     // The examples,
    224     //     1. The code evaluated by the inspector.
    225     //     2. The other unusual code execution like the evaluation through the NPAPI.
    226     //     3. The code from injected bundle's script.
    227     //     4. The code from extension script.
    228     URL baseURL;
    229     RefPtr<JSC::ScriptFetcher> scriptFetcher;
    230     if (sourceOrigin.isNull()) {
    231         baseURL = m_document.baseURL();
    232         scriptFetcher = CachedScriptFetcher::create(m_document.charset());
    233     } else {
    234         baseURL = URL(URL(), sourceOrigin.string());
    235         if (!baseURL.isValid())
    236             return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Importer module key is not a Symbol or a String."));
    237 
    238         if (sourceOrigin.fetcher())
    239             scriptFetcher = sourceOrigin.fetcher();
    240         else
    241             scriptFetcher = CachedScriptFetcher::create(m_document.charset());
    242     }
    243     ASSERT(baseURL.isValid());
    244     ASSERT(scriptFetcher);
     221    // FIXME: setTimeout and setInterval with "string()" should propagate SourceOrigin.
     222    // https://webkit.org/b/167097
     223    ASSERT_WITH_MESSAGE(!sourceOrigin.isNull(), "If SourceOrigin is null, this function is not invoked.");
     224    if (!sourceOrigin.fetcher())
     225        return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Could not use import operator in this context."));
     226
     227    URL baseURL(URL(), sourceOrigin.string());
     228    if (!baseURL.isValid())
     229        return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Importer module key is not Symbol or String."));
    245230
    246231    auto specifier = moduleName->value(exec);
     
    249234        return rejectPromise(state, globalObject, TypeError, result.error());
    250235
    251     return JSC::importModule(exec, JSC::Identifier::fromString(&vm, result->string()), JSC::JSScriptFetcher::create(vm, WTFMove(scriptFetcher) ));
     236    return JSC::importModule(exec, JSC::Identifier::fromString(&vm, result->string()), JSC::JSScriptFetcher::create(vm, sourceOrigin.fetcher() ));
    252237}
    253238
Note: See TracChangeset for help on using the changeset viewer.